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
docs: Config Migration Guide #17230
docs: Config Migration Guide #17230
Conversation
Hi @bpmutter!, thanks for the Pull Request The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.
To Fix: You can fix this problem by running Read more about contributing to ESLint here |
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
b1f42a9
to
0226f89
Compare
]; | ||
``` | ||
|
||
## Things That Haven’t Changed between Configuration File Formats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to reviewer: other notable things which should be highlighted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should put this section first, to let people know "these are the things you don't have to worry about".
I think it's also helpful to point out that globals
are configured the same way, just in a different location.
implemented your feedback @fasttime and @aladdin-add + some copy eidts! also put PR up for formal review since you've taken a look |
|
||
## Start Using `eslint.config.js` | ||
|
||
As of ESLint v9.0.0, the `eslint.config.js` file format is the default configuration file format. If you are using ESLint v9.0.0 or later, you can start using the `eslint.config.js` file format without any additional configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit misleading to me - eslint v9 has not been released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the intention is for this guide to be published when v9 comes out. Please correct me if I'm wrong, and I can adjust the text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll release this prior to v9 to encourage people to start the transition.
* Syntax for adding rules | ||
* Processors | ||
* All functionality. Just the way to configure it has changed. | ||
* The CLI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as stated in the rfc, the following cli options will be no longer supported:
--rulesdir
--ext
--resolve-plugins-relative-to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--no-eslintrc
has been replaced with --no-config-lookup
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added new CLI changes section
Co-authored-by: 唯然 <weiran.zsd@outlook.com>
]; | ||
``` | ||
|
||
Also, dotfiles (e.g. `.dotfile.js`) are no longer ignored by default with `eslint.config.js`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re the dotfiles: in a later tsc meeting, we've decided to keep it as-is:
https://github.com/eslint/tsc-meetings/pull/378/files#diff-86bfb8d4387c1278423e2710f8108a542396d2bc131cce91479a7b3fbfec23e5R27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re the dotfiles: in a later tsc meeting, we've decided to keep it as-is: https://github.com/eslint/tsc-meetings/pull/378/files#diff-86bfb8d4387c1278423e2710f8108a542396d2bc131cce91479a7b3fbfec23e5R27
I think that resolution is about glob patterns, so for example "ignores": "src/**"
shall not ignore files whose name starts with a dot. If ignores
patterns are not specified, by default, dot-files are linted as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure if i fully understand but will refactor and y'all can comment on if it needs further refinement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good start! I think we should think a bit more about how people will want to use this and maybe make high-level headings for each key in eslintrc? That way, people could work their way down the TOC to find what they need?
|
||
### Importing Plugins and Custom Parsers | ||
|
||
#### .eslintrc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be helpful to summarize the difference under each header and then show the examples without headers. Maybe something like:
In eslintrc, plugins are loaded by specifying the name of the plugin in the
plugins
array; in flat config, you'll need to import the plugin object and then assign it to a property in theplugins
object.
|
||
* Syntax for adding rules | ||
* Processors | ||
* All functionality. Just the way to configure it has changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what "all functionality" means here. I think we can remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by this, i mean "how ESLint lints files and reports errors". just the way to set up the configuration has changed.
i'll play w the phrasing a bit here.
|
||
While all the above mentioned features have changed from `.eslintrc` to `eslint.config.js` configurations, the following has stayed the same: | ||
|
||
* Syntax for adding rules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean syntax for configuring rules?
You don't use "syntax" elsewhere, so maybe just "Rule configuration"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i meant 'adding rules to the configuration file', so i think saying 'Rule configuration' expresses that more concisely.
]; | ||
``` | ||
|
||
## Things That Haven’t Changed between Configuration File Formats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should put this section first, to let people know "these are the things you don't have to worry about".
I think it's also helpful to point out that globals
are configured the same way, just in a different location.
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
|
|
|
||
A few of the most notable differences between the eslintrc and flat config formats are the following: | ||
|
||
### Importing Plugins and Custom Parsers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, the key difference is that in eslintrc files, plugins are specified by a string and loaded from a package by ESLint itself. On the other hand, with the flat config, it's the config file that is responsible for loading a plugin as an object (with require()
or import()
), and it's this object that is passed to ESLint.
Ultimately, with the flat config, the plugin doesn't have to be loaded from a package; it can be created by any programmatic means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rephrased here ff8aa3a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user guide lists migration instructions for all major versions up to 8.0.0. I was thinking that in order to maintain the current convention, this file should be named migrating-to-9.0.0.md
or migrate-to-9.0.0.md
.
I can't say if it would be good to add a link to this new guide now or wait until version 9.0.0 is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would defer to the ESLint team on this naming and framing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fasttime this would separate from the major version migration guides as it will span multiple versions.
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
@bpmutter please check the linting errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to be in good shape. Once we clean up the linting errors, I think we're good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noted a few typos and other minor details. The rest looks good.
import babelParser from "@babel/eslint-parser"; | ||
|
||
export default [ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 107-113 are missing one indentation space. Can you check, please?
// Override the recommended config | ||
{ | ||
rules: { | ||
indent: ["error", 2], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 174 and 175 are missing one indentation space.
Co-authored-by: Francesco Trotta <github@fasttime.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just two more suggestions from my side (missed that yesterday).
@fasttime implemented your suggestion, but as "flat config" rather than " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I would like to leave this open a few more days so everybody has a chance to review.
Thanks for this useful piece of documentation @bpmutter!
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
No further comments, so we can merge this now. |
* main: (101 commits) docs: Migrating `eslint-env` configuration comments (eslint#17390) Merge pull request from GHSA-qwh7-v8hg-w8rh feat: adds option for allowing empty object patterns as parameter (eslint#17365) fix: FlatESLint#getRulesMetaForResults shouldn't throw on unknown rules (eslint#17393) docs: fix Ignoring Files section in config migration guide (eslint#17392) docs: Update README feat: Improve config error messages (eslint#17385) fix: Update no-loop-func to not overlap with no-undef (eslint#17358) docs: Update README docs: Update README 8.45.0 Build: changelog update for 8.45.0 chore: package.json update for @eslint/js release docs: add playground links to correct and incorrect code blocks (eslint#17306) docs: Expand rule option schema docs (eslint#17198) docs: Config Migration Guide (eslint#17230) docs: Update README fix: Fix suggestion message in `no-useless-escape` (eslint#17339) docs: Update README chore: update eslint-config-eslint exports (eslint#17336) ...
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[x] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Added a page about migrating from the
.eslintrc
config system toeslint.config.js
systemIs there anything you'd like reviewers to focus on?
Resolves #17229