Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
New: Add public APIs for config-arrays and file-infos #52
New: Add public APIs for config-arrays and file-infos #52
Changes from 1 commit
5f20955
db3a492
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your proposal.
I agree that exposing ConfigArray is worthful, but I feel that this goal and this proposal is different a bit because ConfigArray doesn't have enough information for that. There are related files to configurations:
--rulesdir
option specified -- it's needed to re-run when we modified local rules..eslintignore
-- it's needed to re-run when we modified.eslintignore
.require("source")
in the above files. -- it's needed to re-run if config files or other files imported other files and the imported files are modified.The
filePath
property of ConfigArray contains 1., 2., and 6. But if we approve #9, it will contain only$CWD/eslint.config.js
because all other files become "the files that are imported byrequire("source")
." Therefore, I guess that thefilePath
property of ConfigArray will be not useful for this purpose.If you want to get only 1., actually, it may be hard to distinguish if the
filePath
property of ConfigArray is 1. or not. Maybe true if the path is$CWD/**
but notnode_modules/**
.It's hard to know the files that are imported by
require("source")
.And Node.js has the cache for imported files. If we don't clear the cache, for example, when we updated plugin versions then the language server may use old plugin code partially and raise cryptic errors. Currently, we can clear the cache with
require.cache
, but if we started to useimport("source")
instead (it's required in order to support ES modules for plugins/configs) in the near future, we will lose the capability to clear the cache. Therefore, I think hard to re-run linting without restarting the Node.js process.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humh...
I totally get your point - adding such a method to the public API, in this case, wouldn't add the desired ability of knowing which files to watch.
import {} from "source";
,import "source";
andimport var = require("source");
, btw, affectrequire.cache
as well so clearing or checking the cache would work out pretty well also for ES modules.Anyway to reach the goal I'm after you'd have to import the plugins and settings and check
require.cache
for changes, right?Sounds like this would require another separate method other than
getConfigArrayForFile
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only if the
"source"
was CJS. If the"source"
is ESM, Node.js caches it only in the internal cache and we cannot access it. Therequire.cache
doesn't include imported ESM files.Currently, ESLint doesn't support ESM, so it may work. However, after we supported ESM, it's going to not work properly.
Yes. I think
getConfigArrayForFile
is not useful for this purpose.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright - so cleaning the cache is of no use as it will stop working at some point anyway...?
Forking a new process might be of no use, too, as this would draw me unable to get the result from
eslint
... Or is there some way to pass JavaScript-objects from/to forked processes or any other alternative?Fine - shall we cover both the
getConfigArrayForFile
and the language-server stuff in this RFC?