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

chore: consolidate eslint config #627

Merged
merged 4 commits into from Aug 22, 2023
Merged

Conversation

boneskull
Copy link
Contributor

@boneskull boneskull commented Jul 21, 2023

The resulting config is my best guess at the intent of the current configuration. In addition to linting the repo (the "lint everything" commit), this change:

  • Removes all .eslintignore , .eslintrc files or package.json-embedded config and replaces it with a single root .eslintrc.js
  • Removes all lint-related scripts from all workspaces (including depcheck)
  • Removes all dev deps on eslint and its ilk (and ava, since it will come from the workspace root)
  • Upgrades @metamask/eslint-config-nodejs, eslint, eslint-plugin-ava, as well as other plugins used by specific packages; moves them all to workspace root
  • Removes unused/deprecated eslint-plugin-node in lieu of eslint-plugin-n, which the new version of @metamask/eslint-config-nodejs needs
  • Adds a prettier config (in case someone wants to use it; I'd like to add it to our workflow later)

I note that ESLint seemed to be misconfigured before this change; none of the rules specified in the root config were being checked. This means that there are a whole lot of lint fixes that need to be made.

To lint, run npm run lint (which will also run depcheck) from the workspace root. Likewise, lint:fix runs a fix (across the whole repo), and lint:depcheck will use lerna to run lint:depcheck wherever it is defined.

@boneskull
Copy link
Contributor Author

I note that depcheck is not monorepo-aware, and depending on what we want from it, could be replaced with eslint-plugin-import.

@boneskull boneskull self-assigned this Jul 21, 2023
@boneskull boneskull force-pushed the boneskull/consolidate-eslint branch 2 times, most recently from 570d8b4 to 939792a Compare July 21, 2023 22:27
@boneskull
Copy link
Contributor Author

boneskull commented Jul 21, 2023

Worth mentioning there were multiple references to eslint rules from endo's custom config in core/lib/strict-scope-terminator.js. This config doesn't appear anywhere else--I assume it was from a copy/paste--and it wasn't noticed because the aforementioned misconfiguration.

@boneskull boneskull force-pushed the boneskull/consolidate-eslint branch from 939792a to ff6f77e Compare July 25, 2023 20:36
@boneskull boneskull force-pushed the boneskull/consolidate-eslint branch 2 times, most recently from d4a1560 to 95f581c Compare July 25, 2023 23:01
@boneskull boneskull added the chore overhead, tests, dev env, etc. label Jul 25, 2023
@boneskull boneskull force-pushed the boneskull/consolidate-eslint branch 2 times, most recently from f389c76 to 75e5442 Compare July 25, 2023 23:17
@@ -0,0 +1,3 @@
ignores:
# monorepo deps
- "ava"
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

@boneskull boneskull Jul 26, 2023

Choose a reason for hiding this comment

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

because depcheck is not monorepo-aware, ava will be referenced in e.g., lavapack/test/index.js, but it will not appear in the devDependencies of lavapack/package.json.

any dev dep in a workspace which is required from code (unsure if this applies to dev deps only referenced in e.g., package.json's scripts prop) but is only in the workspace root's dev deps would need to be in this ignore property.

@boneskull boneskull force-pushed the boneskull/consolidate-eslint branch from 75e5442 to c283bb0 Compare July 26, 2023 23:01
@boneskull
Copy link
Contributor Author

just gonna retarget this one to #629

@boneskull boneskull changed the base branch from main to boneskull/npm July 27, 2023 01:00
@boneskull boneskull force-pushed the boneskull/consolidate-eslint branch from c283bb0 to 0f27be3 Compare July 27, 2023 01:00
@boneskull boneskull marked this pull request as draft July 27, 2023 07:57
@boneskull boneskull force-pushed the boneskull/consolidate-eslint branch 2 times, most recently from cf45819 to 57df31b Compare July 27, 2023 19:48
@boneskull boneskull marked this pull request as ready for review July 27, 2023 20:16
.eslintrc.js Outdated
'n/no-process-env': 0,
// this rule seems broken
'n/no-unpublished-require': 0,
// we should probably actually fix these three and disable this override.
Copy link
Contributor

Choose a reason for hiding this comment

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

q for later: What's the upside of n/no-process-exit here? Agreed on the two other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure exactly what you're asking. process.exit() can be problematic if any of your code is async, because it exits before the loop is clear. It's safer to just let the event loop die. Anyway; it's in the codebase, and I didn't want to remove it, so I disabled the rule for now.

Copy link
Contributor

@legobeat legobeat left a comment

Choose a reason for hiding this comment

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

Needs a rebase before merge but LGTM otherwise!

This change:

- Removes all `.eslintignore` , `.eslintrc` files or `package.json`-embedded config and replaces it with a single root `.eslintrc.js`
- Removes all lint-related scripts from all workspaces (including `depcheck`)
- Removes all dev deps on `eslint` and its ilk (and `ava`, since it will come from the workspace root)
- Upgrades `@metamask/eslint-config-nodejs`, `eslint`, `eslint-plugin-ava`, as well as other plugins used by specific packages; moves them all to workspace root
- Removes unused/deprecated `eslint-plugin-node` in lieu of `eslint-plugin-n`, which the new version of `@metamask/eslint-config-nodejs` needs
- Adds a prettier config (in case someone wants to use it; I'd like to add it to our workflow later)

I note that ESLint seemed to be misconfigured before this change; none of the rules specified in the root config were being checked.  This means that there are a whole lot of lint fixes that need to be made.

To lint, run `yarn lint` as before (which will also run `depcheck`) from the workspace root.  Likewise, `lint:fix` runs a fix, and `lint:depcheck` will use lerna to run `lint:depcheck` wherever it is defined.
Closes #637

This removes the dep on `@metamask/eslint-config-nodejs` which has a peer dep on `@metamask/eslint-config`.  `npm` will automatically install that module, and that module _itself_ has peer deps which may also conflict with our deps currently or in the future.

Given `@metamask/eslint-config-nodejs` is _intended_ to be used with `@metamask/eslint-config`, we then must drop it.

The ESLint config has been modified to extend both `eslint/recommended` and `eslint-plugin-n/recommended` configs.  Extra rules were copied from `@metamask/eslint-config-nodejs`, but many (such as restrictions on browser-only globals) were not, since these can be trivially addressed by ESLint's `env` configuration (unsure what they are doing where this is a problem).  Since this surfaced a whole lot of new issues--especially in test code and templates--additional overrides were necessary.  Any rules which were removed from the main `rules` prop were likely already enabled in `eslint/recommended`.

# Conflicts:
#	package-lock.json
#	package.json
@legobeat
Copy link
Contributor

5e27065 & 85e402f should be squashed prior to merge

@boneskull boneskull merged commit 1b61289 into main Aug 22, 2023
9 checks passed
@boneskull boneskull deleted the boneskull/consolidate-eslint branch August 22, 2023 23:36
boneskull added a commit to boneskull/LavaMoat that referenced this pull request Feb 6, 2024
This change:

- Removes all `.eslintignore` , `.eslintrc` files or `package.json`-embedded config and replaces it with a single root `.eslintrc.js`
- Removes all lint-related scripts from all workspaces (including `depcheck`)
- Removes all dev deps on `eslint` and its ilk (and `ava`, since it will come from the workspace root)
- Upgrade `eslint`, `eslint-plugin-ava`, as well as other plugins used by specific packages; moves them all to workspace root
- Removes unused/deprecated `eslint-plugin-node` in lieu of `eslint-plugin-n`
- Adds a prettier config (in case someone wants to use it; I'd like to add it to our workflow later)

I note that ESLint seemed to be misconfigured before this change; none of the rules specified in the root config were being checked.  This means that there are a whole lot of lint fixes that need to be made.

To lint, run `yarn lint` as before (which will also run `depcheck`) from the workspace root.  Likewise, `lint:fix` runs a fix, and `lint:depcheck` will use lerna to run `lint:depcheck` wherever it is defined.

chore: remove @metamask/eslint-config-nodejs (LavaMoat#639)

Closes LavaMoat#637

This removes the dep on `@metamask/eslint-config-nodejs` which has a peer dep on `@metamask/eslint-config`.  `npm` will automatically install that module, and that module _itself_ has peer deps which may also conflict with our deps currently or in the future.

Given `@metamask/eslint-config-nodejs` is _intended_ to be used with `@metamask/eslint-config`, we then must drop it.

The ESLint config has been modified to extend both `eslint/recommended` and `eslint-plugin-n/recommended` configs.  Extra rules were copied from `@metamask/eslint-config-nodejs`, but many (such as restrictions on browser-only globals) were not, since these can be trivially addressed by ESLint's `env` configuration (unsure what they are doing where this is a problem).  Since this surfaced a whole lot of new issues--especially in test code and templates--additional overrides were necessary.  Any rules which were removed from the main `rules` prop were likely already enabled in `eslint/recommended`.

chore: lint everything
boneskull added a commit to boneskull/LavaMoat that referenced this pull request Feb 6, 2024
This change:

- Removes all `.eslintignore` , `.eslintrc` files or `package.json`-embedded config and replaces it with a single root `.eslintrc.js`
- Removes all lint-related scripts from all workspaces (including `depcheck`)
- Removes all dev deps on `eslint` and its ilk (and `ava`, since it will come from the workspace root)
- Upgrade `eslint`, `eslint-plugin-ava`, as well as other plugins used by specific packages; moves them all to workspace root
- Removes unused/deprecated `eslint-plugin-node` in lieu of `eslint-plugin-n`
- Adds a prettier config (in case someone wants to use it; I'd like to add it to our workflow later)

I note that ESLint seemed to be misconfigured before this change; none of the rules specified in the root config were being checked.  This means that there are a whole lot of lint fixes that need to be made.

To lint, run `yarn lint` as before (which will also run `depcheck`) from the workspace root.  Likewise, `lint:fix` runs a fix, and `lint:depcheck` will use lerna to run `lint:depcheck` wherever it is defined.

chore: remove @metamask/eslint-config-nodejs (LavaMoat#639)

Closes LavaMoat#637

This removes the dep on `@metamask/eslint-config-nodejs` which has a peer dep on `@metamask/eslint-config`.  `npm` will automatically install that module, and that module _itself_ has peer deps which may also conflict with our deps currently or in the future.

Given `@metamask/eslint-config-nodejs` is _intended_ to be used with `@metamask/eslint-config`, we then must drop it.

The ESLint config has been modified to extend both `eslint/recommended` and `eslint-plugin-n/recommended` configs.  Extra rules were copied from `@metamask/eslint-config-nodejs`, but many (such as restrictions on browser-only globals) were not, since these can be trivially addressed by ESLint's `env` configuration (unsure what they are doing where this is a problem).  Since this surfaced a whole lot of new issues--especially in test code and templates--additional overrides were necessary.  Any rules which were removed from the main `rules` prop were likely already enabled in `eslint/recommended`.

chore: lint everything
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore overhead, tests, dev env, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants