Change Request: [flat config] re-read the eslint.config.js file if it has been changed
See original GitHub issueESLint 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:
- Created 10 months ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
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
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 therequire
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.