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

docs: Config Migration Guide #17230

Merged
merged 22 commits into from Jul 13, 2023
Merged

Conversation

bpmutter
Copy link
Contributor

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 to eslint.config.js system

Is there anything you'd like reviewers to focus on?

Resolves #17229

@eslint-github-bot
Copy link

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.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.

To Fix: You can fix this problem by running git commit --amend, editing your commit message, and then running git push -f to update this pull request.

Read more about contributing to ESLint here

@netlify
Copy link

netlify bot commented May 28, 2023

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit f34ce54
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/64af4c2c6e03150008cf13df
😎 Deploy Preview https://deploy-preview-17230--docs-eslint.netlify.app/use/configure/migration-guide
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@eslint-github-bot eslint-github-bot bot added the documentation Relates to ESLint's documentation label May 28, 2023
];
```

## Things That Haven’t Changed between Configuration File Formats
Copy link
Contributor Author

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?

Copy link
Member

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.

@Rec0iL99 Rec0iL99 added the accepted There is consensus among the team that this change meets the criteria for inclusion label May 28, 2023
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
@bpmutter bpmutter marked this pull request as ready for review May 31, 2023 01:55
@bpmutter bpmutter requested a review from a team as a code owner May 31, 2023 01:55
@bpmutter
Copy link
Contributor Author

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.
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
* Syntax for adding rules
* Processors
* All functionality. Just the way to configure it has changed.
* The CLI
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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

docs/src/use/configure/migration-guide.md Show resolved Hide resolved
bpmutter and others added 2 commits June 4, 2023 20:50
Co-authored-by: 唯然 <weiran.zsd@outlook.com>
];
```

Also, dotfiles (e.g. `.dotfile.js`) are no longer ignored by default with `eslint.config.js`.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@fasttime fasttime Jun 5, 2023

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.

Copy link
Contributor Author

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.

Copy link
Member

@nzakas nzakas left a 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?

docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved

### Importing Plugins and Custom Parsers

#### .eslintrc
Copy link
Member

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 the plugins object.

docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved

* Syntax for adding rules
* Processors
* All functionality. Just the way to configure it has changed.
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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"?

Copy link
Contributor Author

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
Copy link
Member

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>
@linux-foundation-easycla
Copy link

CLA Missing ID CLA Not Signed

@linux-foundation-easycla
Copy link

CLA Missing ID CLA Not Signed

@bpmutter bpmutter requested a review from nzakas June 11, 2023 22:48
@bpmutter bpmutter requested a review from nzakas June 19, 2023 18:27

A few of the most notable differences between the eslintrc and flat config formats are the following:

### Importing Plugins and Custom Parsers
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rephrased here ff8aa3a

Copy link
Member

@fasttime fasttime Jun 25, 2023

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.

Copy link
Contributor Author

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

Copy link
Member

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>
@nzakas
Copy link
Member

nzakas commented Jun 26, 2023

@bpmutter please check the linting errors

Copy link
Member

@nzakas nzakas left a 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.

Copy link
Member

@fasttime fasttime left a 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.

docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
import babelParser from "@babel/eslint-parser";

export default [
{
Copy link
Member

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],
Copy link
Member

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.

docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
bpmutter and others added 3 commits June 26, 2023 21:39
Co-authored-by: Francesco Trotta <github@fasttime.org>
@bpmutter
Copy link
Contributor Author

all green on the checks now @nzakas and @fasttime

Copy link
Member

@fasttime fasttime left a 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).

docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
@bpmutter bpmutter requested a review from fasttime July 4, 2023 15:24
@bpmutter
Copy link
Contributor Author

bpmutter commented Jul 4, 2023

@fasttime implemented your suggestion, but as "flat config" rather than "eslint.config.js" for consistency w/ the rest of the page.

Copy link
Member

@fasttime fasttime left a 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!

@aladdin-add aladdin-add self-requested a review July 7, 2023 06:03
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
@fasttime
Copy link
Member

No further comments, so we can merge this now.

@fasttime fasttime merged commit 8bcbf11 into eslint:main Jul 13, 2023
22 checks passed
bmish added a commit to bmish/eslint that referenced this pull request Jul 23, 2023
* 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)
  ...
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jan 10, 2024
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change Request: .eslintrc -> eslint.config.js migration guide
7 participants