Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow custom ESLint rules and add get-text-anti-pattern #27591

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

HowardBraham
Copy link
Contributor

@HowardBraham HowardBraham commented Oct 3, 2024

Description

UPDATE October 23: this is ready for comments now, but not ready for merging, waiting on #28041, #28043, and probably more

Allows us to write custom ESLint rules directly in our repo, without using an external NPM package.

I evaluated several packages to do this, including:

eslint-plugin-rulesdir seemed the best for our purposes. I tried for several days to get this working with TypeScript rules, involving @davidmurdoch and @naugtur, but I think it's not going to play nice with LavaMoat. When we upgrade to ESLint 9, we can get rid of eslint-plugin-rulesdir, start using the special "local" plugin, and write TypeScript rules.

get-text-anti-pattern.js serves as an example rule. It's something I've been thinking about for months, for how to combat this prevalent anti-pattern #19870.

Open in GitHub Codespaces

Related issues

Manual testing steps

Screenshots/Recordings

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

github-actions bot commented Oct 3, 2024

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link

socket-security bot commented Oct 3, 2024

package.json Outdated
@@ -546,6 +546,7 @@
"@types/yargs-parser": "^21.0.3",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"@typescript-eslint/utils": "^8.8.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package @typescript-eslint/utils was already implicitly included, but this makes it explicit

Comment on lines -670 to +681
"tsx": "^4.7.1",
"tsx": "^4.19.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tsx package was updated to the latest version in order to support require('tsx/cjs/api').register(tsconfig);

Comment on lines +10 to +12
// Allow TypeScript to be used in Mocha
require: ['tsx/esm'],
'node-option': ['import=tsx'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mocha unit tests used to use ts-node, this updates them to the newest tsx

@HowardBraham HowardBraham self-assigned this Oct 16, 2024
@HowardBraham HowardBraham changed the title feat: allow custom ESLint rules feat: allow custom ESLint rules and add get-text-anti-pattern Oct 16, 2024
Copy link

sonarcloud bot commented Oct 16, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@HowardBraham HowardBraham added the type-tech-debt Technical debt label Oct 17, 2024
.eslintrc.js Outdated
Comment on lines 290 to 295
files: ['test/e2e/**/*.spec.js'],
files: ['test/e2e/**/*.spec.{js,jsx,ts,tsx}'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this caused hundreds of new errors and warnings ☹️

@HowardBraham HowardBraham force-pushed the custom-eslint-rules branch 2 times, most recently from 7ae8a41 to 7e0e2e9 Compare October 18, 2024 09:00
@MetaMask MetaMask deleted a comment from metamaskbot Oct 18, 2024
@HowardBraham HowardBraham force-pushed the custom-eslint-rules branch 2 times, most recently from 2406fe0 to 5dcf6b3 Compare October 18, 2024 19:59
@MetaMask MetaMask deleted a comment from metamaskbot Oct 18, 2024
@HowardBraham HowardBraham added team-tiger Tiger team (for tech debt reduction + performance improvements) contributor experience An issue that impacts, or planned improvement to, the contributor experience. and removed team-contributor-experience labels Oct 18, 2024
@HowardBraham HowardBraham added flaky tests and removed contributor experience An issue that impacts, or planned improvement to, the contributor experience. labels Oct 23, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [9b3104d]
Page Load Metrics (1788 ± 71 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint16042119178413665
domContentLoaded15782049175013565
load15902145178814771
domInteractive148041157
backgroundConnect878342311
firstReactRender44204874521
getState47717199
initialActions00000
loadScripts11481543128711555
setupStore1168302211
uiStartup17652534200419392
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@HowardBraham HowardBraham added the DO-NOT-MERGE Pull requests that should not be merged label Oct 23, 2024
github-merge-queue bot pushed a commit that referenced this pull request Oct 24, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Continuing the work of removing the e2e anti-pattern of finding the
element and then asserting its text.
There are more occurrences, but this work is split in several PRs, for
an easy review and a faster ci.
Once all occurrences have been fixed, we'll be able to merge
@HowardBraham 's [PR
](#27591 adding a
lint rule which prevents introducing it again.


[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28043?quickstart=1)

## **Related issues**

Fixes: (but doesn't yet closes)
#19870

## **Manual testing steps**

1. Check ci

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
vinistevam pushed a commit that referenced this pull request Oct 24, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Continuing the work of removing the e2e anti-pattern of finding the
element and then asserting its text.
There are more occurrences, but this work is split in several PRs, for
an easy review and a faster ci.
Once all occurrences have been fixed, we'll be able to merge
@HowardBraham 's [PR
](#27591 adding a
lint rule which prevents introducing it again.


[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28043?quickstart=1)

## **Related issues**

Fixes: (but doesn't yet closes)
#19870

## **Manual testing steps**

1. Check ci

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
github-merge-queue bot pushed a commit that referenced this pull request Oct 24, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
Continuing the work of removing the e2e anti-pattern of finding the
element and then asserting its text.
There are more occurrences, but this work is split in several PRs, for
an easy review and a faster ci.
Once all occurrences have been fixed, we'll be able to merge
@HowardBraham 's [PR
](#27591 adding a
lint rule which prevents introducing it again.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28062?quickstart=1)

## **Related issues**

Fixes: (but doesn't yet closes)
#19870

## **Manual testing steps**

1. Check ci

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
cryptotavares pushed a commit that referenced this pull request Oct 25, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Continuing the work of removing the e2e anti-pattern of finding the
element and then asserting its text.
There are more occurrences, but this work is split in several PRs, for
an easy review and a faster ci.
Once all occurrences have been fixed, we'll be able to merge
@HowardBraham 's [PR
](#27591 adding a
lint rule which prevents introducing it again.


[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28043?quickstart=1)

## **Related issues**

Fixes: (but doesn't yet closes)
#19870

## **Manual testing steps**

1. Check ci

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
cryptotavares pushed a commit that referenced this pull request Oct 25, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
Continuing the work of removing the e2e anti-pattern of finding the
element and then asserting its text.
There are more occurrences, but this work is split in several PRs, for
an easy review and a faster ci.
Once all occurrences have been fixed, we'll be able to merge
@HowardBraham 's [PR
](#27591 adding a
lint rule which prevents introducing it again.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28062?quickstart=1)

## **Related issues**

Fixes: (but doesn't yet closes)
#19870

## **Manual testing steps**

1. Check ci

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
@HowardBraham HowardBraham added the contributor experience An issue that impacts, or planned improvement to, the contributor experience. label Oct 29, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [5ca9d31]
Page Load Metrics (2038 ± 57 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint18122214203911857
domContentLoaded17992196199011053
load18152214203811857
domInteractive186638105
backgroundConnect1082482713
firstReactRender532051103416
getState663242010
initialActions01000
loadScripts12761645146610450
setupStore1284302311
uiStartup20452805229016981
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor experience An issue that impacts, or planned improvement to, the contributor experience. DO-NOT-MERGE Pull requests that should not be merged flaky tests team-tiger Tiger team (for tech debt reduction + performance improvements) type-tech-debt Technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants