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: [flat config] re-read the eslint.config.js file if it has been changed

See original GitHub issue

ESLint version

8.28.0

What problem do you want to solve?

Hi from JetBrains! WebStorm ESLint integration has a wrapper Node.js process that lives for a long time and calls ESLint.lintText() as needed. ESLint config files might be edited between ESLint.lintText() calls.

In the ‘flat config’ mode, the eslint.config.js files are never re-read from disk. The reason is that they are loaded using import(), which caches the result forever.

So, the problem is that the ESLint results that WebStorm users see do not match the current configuration (eslint.config.js files).

Cleaning require.cache doesn’t help. It looks like there’s no way to drop the internal cache of import().

What do you think is the correct solution?

It would be great if the loadFlatConfigFile() function returned up-to-date result each time even if the config file has been edited between loadFlatConfigFile() invocations. Thank you!

Participation

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

Additional comments

No response

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Dec 3, 2022

PR https://github.com/eslint/eslint/pull/16608. Unfortunatelly, this approach doesn’t seem to work when the config file is a CJS module.

https://github.com/nodejs/node/issues/29812

https://github.com/nodejs/modules/issues/417

0reactions
mdjermanoviccommented, Dec 9, 2022

Yes, per comments from the issues I linked, when import-ing a CJS module Node.js gets file path from the URL and then passes it to the require infrastructure, which then loads and caches the module per the file path. Query strings are lost in the process.

I’ll try the solution @fasttime suggested in https://github.com/eslint/eslint/pull/16608#issuecomment-1337022476, just had to contemplate whether we should reload CJS configs always, like in the eslintrc config system, or only if they’ve changed. I think we should do the latter, so that the behavior is the same as with ESM configs.

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 >
Can't reload eslint configuration file - Stack Overflow
I'm working on a React application (created via Create React App) ... In my src folder I have the file .eslintrc.js which is...
Read more >
Changelog - JavaScript Standard Style
eslint -config-node has been replaced with the up to date fork eslint-config-n . If you have used comments like // eslint-disable-line node/no-deprecated-api you ......
Read more >
Monorepo - CLI | NestJS - A progressive Node.js framework
json that configure and enable various tools for compiling, testing and serving your application. From there, you can modify the starter files, add...
Read more >
eslintconfig
Here's the configuration, which more explanation below. js file as a dedicated configuration file, that way ESLint will use the config file instead...
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