question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mdjermanoviccommented, Sep 27, 2022

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.
1reaction
nzakascommented, 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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLint's new config system, Part 2: Introduction to flat config
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Configuration Files (New) - ESLint - Pluggable JavaScript Linter
To opt-in, place an eslint.config.js file in the root of your project or set the ESLINT_USE_FLAT_CONFIG environment variable to true . To opt-out,...
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
ESLint supports adding shared settings into configuration files. Plugins use settings to specify the information that should be shared across all of its...
Read more >
Command Line Interface - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Configuring ESLint - ESLint - Pluggable JavaScript Linter
There are two primary ways to configure ESLint: Configuration Comments - use JavaScript comments to embed configuration information directly into a file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found