Page MenuHomePhabricator

[monorepo] eslint all the js with a single version-pinned flat config
Needs ReviewPublic

Authored by bytesofman on Wed, Mar 5, 18:32.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Summary

All of the js sub-repos in the monorepo have their own lint settings. For eslint before 9, this was best practice. It is difficult to find a "one size fits all" lint approach for JS, since nodejs has different rules from vanilla js, react has its own special rules, the browser has different globals vs node, different test engines also have different globals, different standards have different syntax, some repos have a good reason to use multiple standards, etc.

We want all js to be linted. And we want there to be a maintainable and as-standardized-as-possible approach.

With eslint 9, the "flat config" is introduced which allows a single config file to handle various rulesets across a monorepo. We implement this approach here, deleting all legacy lint settings (many of which were never implemented in arc lint).

We correct all lint issues discovered by this implementation now that arc lint is picking everything up.

Test Plan

CI for all lint changes, arc lint --everything

Event Timeline

Tail of the build log:

5 vulnerabilities (4 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> ecash-agora@2.0.0 build
> tsc && tsc -p ./tsconfig.build.json

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated eslint@8.56.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.

added 1403 packages, and audited 3180 packages in 23s

274 packages are looking for funding
  run `npm fund` for details

9 vulnerabilities (8 moderate, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

> cashtab@3.17.4 build
> node scripts/build.js

node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module 'eslint-webpack-plugin'
Require stack:
- /work/cashtab/config/webpack.config.js
- /work/cashtab/scripts/build.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/work/cashtab/config/webpack.config.js:21:22)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/work/cashtab/config/webpack.config.js',
    '/work/cashtab/scripts/build.js'
  ]
}

Node.js v20.18.3
Build cashtab-tests failed with exit code 1

dep back in, improve exclusions in arclint

Tail of the build log:

5 vulnerabilities (4 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> ecash-agora@2.0.0 build
> tsc && tsc -p ./tsconfig.build.json

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated eslint@8.56.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.

added 1406 packages, and audited 2846 packages in 24s

274 packages are looking for funding
  run `npm fund` for details

9 vulnerabilities (8 moderate, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

> cashtab@3.17.4 build
> node scripts/build.js

node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module 'eslint-config-react-app/base'
Require stack:
- /work/cashtab/config/webpack.config.js
- /work/cashtab/scripts/build.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Function.resolve (node:internal/modules/helpers:190:19)
    at module.exports (/work/cashtab/config/webpack.config.js:787:37)
    at Object.<anonymous> (/work/cashtab/scripts/build.js:54:16)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/work/cashtab/config/webpack.config.js',
    '/work/cashtab/scripts/build.js'
  ]
}

Node.js v20.18.3
Build cashtab-tests failed with exit code 1

disable eslint plugin for webpack build

emack requested changes to this revision.Thu, Mar 6, 07:21
emack added a subscriber: emack.

/modules/chronik-client/.prettierignore and /.prettierignore be removed as it's similar to .eslintignore

On another note, I'm getting the following from arc lint --everything

image.png (245×1 px, 37 KB)

However, arc lint on the cashtab folder runs fine, which doesn't seem to be a local issue?

image.png (55×512 px, 9 KB)

This revision now requires changes to proceed.Thu, Mar 6, 07:21

/modules/chronik-client/.prettierignore and /.prettierignore be removed as it's similar to .eslintignore

On another note, I'm getting the following from arc lint --everything

image.png (245×1 px, 37 KB)

However, arc lint on the cashtab folder runs fine, which doesn't seem to be a local issue?

image.png (55×512 px, 9 KB)

arc lint on the cashtab folder is the same as arc lint anywhere else: it lints the current commit.

Regarding the mypy issue, what are your mypy and python versions ?

/modules/chronik-client/.prettierignore and /.prettierignore be removed as it's similar to .eslintignore

On another note, I'm getting the following from arc lint --everything

image.png (245×1 px, 37 KB)

However, arc lint on the cashtab folder runs fine, which doesn't seem to be a local issue?

image.png (55×512 px, 9 KB)

will leave these for now as this commit focuses on eslint only

will do another commit to bump the prettier version / standardize prettier rules ... even then tho, we may end up keeping local .prettierignore files. afaik prettier does not have this same "flat config" monorepo-friendly option like eslint.