feat(linter): major improvements to ESLint support#3763
feat(linter): major improvements to ESLint support#3763JamesHenry wants to merge 1 commit intonrwl:masterfrom
Conversation
Nx Cloud ReportCI ran the following commands. Click to see the status, the terminal output, and the build insights.
Sent with 💌 from NxCloud. |
b8e7082 to
f352e9d
Compare
3e7c50a to
596851a
Compare
6861feb to
5894c40
Compare
|
@JamesHenry what do you think about using JavaScript versions of eslint config instead of JSON? I like to comment in those config files and from what I read on this internet I am not alone. |
|
@pf1gura JSON ESLint config files support comments, both in editors and when included in a lint run via the command line (whether directly or wrapped in a builder). So that major pro of JS is already covered. The major con of JS files is that they are incredibly difficult to support from an automated tooling perspective. With JSON we can easily statically analyse them and write migrations to update them automatically when you upgrade Nx. With JS we can't and so you will need to support making any recommended changes yourself. So, in summary, you can use JS files if you want to, they will work, but they come at a cost. |
|
@JamesHenry Your comment makes a lot of sense. Comments in config files were my only argument to use JS files (and I did not know that JSON config supports comments 🤦). That makes things a lot easier 😄 Disregard my message then. I looked at the PR and everything else looks great. Awesome work. Hope it gets merged soon. |
|
@pf1gura No problem - it's not the common case for comments to be supported in JSON of course, so it is a natural assumption for you to make, but the ESLint team decide to support comments in their JSON config files so that is something we can leverage! |
|
Going to close this as there is now only one major part of this PR that needs to be tackled separately (config changes towards |
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
This PR includes some major improvements to how ESLint is supported in Nx and paves the way for much better Angular + ESLint support, in particular, in a follow up PR.
SPLIT OUT AND MERGED AS #3834
## New builder for ESLintThe current ESLint builder that ships with Nx is a port of a port of the TSLint builder from angular-devkit. This originally made sense as a starting point to get things working.However, that initial implementation has shown its limitations and it is doing a bunch of work that, whilst appropriate in the TSLint case, is not appropriate in the ESLint case.This PR adds a new builder implementation alongside the existing one. This will give us the easiest path to providing the new functionality without requiring users to migrate straight away (although this PR will also provide an automated migration). By having two separate implementations, we can avoid having a single, complex implementation with a messy and hard to validate schema definition for the builder.This new builder should resolve:- #3310- #2784## Updated dependencies and ESLint config file type- Currently Nx is using an outdated version of ESLint and therefore missing out on bug fixes and performance improvements. This PR updates to the latest major version of ESLint (v7).- Currently Nx is using heavily outdated versions of@typescript-eslintdependencies, and therefore missing out on bug fixes and performance improvements. This PR updates those deps to the latest we can whilst still matching the supported TypeScript version (3.x).Fixes:- #3715SPLIT OUT AND MERGED AS #3847
## ESLint config file type- Currently Nx creates.eslintrcfiles which are deprecated by ESLint. In that file they supported YAML and JSON, but Nx only ever uses JSON, so this PR moves to use.eslintrc.jsonfiles, and has an automated migration for any old.eslintrcthat contain JSON.Fixes:- #2833SPLIT OUT AND MERGED AS #3852
## Root ESLint Config does not trigger affected logic for projects- Currently changes to the root .eslintrc/.eslintrc.json file does not cause anything to be affected when it should be a very high potential impact change for the lint taget.Fixes:- #2858ESLint config itself
This PR updates how ESLint is fundamentally configured to lean on
overridesfor each type of file that needs to be supported.Other notes: