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

Change Request: Allow manually opting into flat config without an eslint.config.js #16349

Closed
1 task done
TomerAberbach opened this issue Sep 25, 2022 · 5 comments · Fixed by #16356
Closed
1 task done
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 core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects

Comments

@TomerAberbach
Copy link
Contributor

ESLint version

v8.24.0

What problem do you want to solve?

Right now you have to create an eslint.config.js file to use flat config. It would be nice if flat configs could be passed on the command line using the -c or --config argument. The docs currently make it sound like it should work, but it doesn't.

What do you think is the correct solution?

I can think of two options:

  1. A CLI argument like --use-flat-config that would make ESLint treat the config as a flat config
  2. Assume a config is a flat config if it's ESM because the legacy config files can't be ESM

I think I prefer option 1 because option 2 doesn't support CJS flat configs, which I think are allowed?

Participation

  • I am willing to submit a pull request for this change.

Additional comments

No response

@TomerAberbach TomerAberbach added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Sep 25, 2022
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Sep 25, 2022
@TomerAberbach TomerAberbach changed the title Change Request: Allow manually opting into flat config via CLI arguments Change Request: Allow manually opting into flat config without an eslint.config.js Sep 26, 2022
@TomerAberbach
Copy link
Contributor Author

I realized the CLI options are differentiated based on whether flat config is being used so maybe this could be configured by an environment variable instead

@nzakas nzakas moved this from Needs Triage to Feedback Needed in Triage Sep 26, 2022
@nzakas
Copy link
Member

nzakas commented Sep 26, 2022

Thanks for the feedback. The docs are confusing -- they were written with the end state of flat config in mind.

I'm not opposed to adding an environment variable (it was discussed before). Let's see what the rest of the team thinks.

@mdjermanovic mdjermanovic removed the triage An ESLint team member will look at this issue soon label Sep 27, 2022
@mdjermanovic
Copy link
Member

I'm not opposed to adding an environment variable either.

Do we want it to also include an option to opt-out of flat config even if eslint.config.js is present?

  • ESLINT_USE_FLAT_CONFIG=true - forces flat config mode regardless of the presence of eslint.config.js (--config would be loaded as a flat config file; it would error if there is no eslint.config.js and --config was not specified).
  • ESLINT_USE_FLAT_CONFIG=false - forces eslintrc mode regardless of the presence of eslint.config.js.
  • Not defined or any other value - works the same as now, presence of eslint.config.js determines the mode.

@nzakas
Copy link
Member

nzakas commented Sep 28, 2022

Do we want it to also include an option to opt-out of flat config even if eslint.config.js is present?

That seems like a good idea. It would certainly make compatibility testing a lot easier.

I like the proposal so marking as accepted.

@TomerAberbach would you like to submit a PR for this?

@nzakas nzakas moved this from Feedback Needed to Ready to Implement in Triage Sep 28, 2022
@nzakas nzakas added the accepted There is consensus among the team that this change meets the criteria for inclusion label Sep 28, 2022
@TomerAberbach
Copy link
Contributor Author

Do we want it to also include an option to opt-out of flat config even if eslint.config.js is present?

That seems like a good idea. It would certainly make compatibility testing a lot easier.

I like the proposal so marking as accepted.

@TomerAberbach would you like to submit a PR for this?

Yup! See #16356 😃

Triage automation moved this from Ready to Implement to Complete Oct 13, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Apr 12, 2023
@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 Apr 12, 2023
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 core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects
Archived in project
Triage
Complete
Development

Successfully merging a pull request may close this issue.

3 participants