-
Notifications
You must be signed in to change notification settings - Fork 37
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
eslint v6 support #304
Comments
I've had a go at trying to do this and it seems the major issue is that So there are some decisions to be made about how to get around this. |
cc @mysticatea @platinumazure who i think were involved with this eslint change |
Per our document, ESLint may use different configs for each source code file because it supports cascading and glob-based configuration. Because I'm not familiar with this tool, I'm not sure if what decision is proper. |
@mysticatea ideally it would take a directory or a glob; it could even be an array of all found config files within a directory. The intention of the tool is to help manage config files themselves. |
Please mind A config file doesn't 1:1 map to a config object that For now, how about... const glob = require("glob")
const { CLIEngine } = require("eslint")
const engine = new CLIEngine()
function getConfigs(pattern) {
const configs = new Set()
for (const filePath of glob.sync(pattern, { dot: true, matchBase: true })) {
if (!engine.isPathIgnored(filePath)) {
configs.add(engine.getConfigForFile(filePath))
}
}
return configs
}
console.log(getConfigs("lib/*.js")) This should work both of ESLint 6 and older versions. |
This approach definitely seems to work to get the configured rules; unfortunately it doesn't seem to be sufficient to make this package work on eslint 6 :-/ |
My first attempt is here: master...ljharb:eslint_6 |
@ljharb Are there any issues with your first attempt that are preventing a merge? (I'm not able to run the code given my current location/circumstances). My initial thought from looking at the code is that it can report different rules/plugins than the current version since your new code will account for some overrides. The fact that the overrides can have non To ovoid those differences would replacing the current This could match an |
@nosilleg it’s not complete, so it doesn’t work yet. If you have any suggestions and want to make a PR, that would be appreciated :-) |
@ljharb I'm not going to be able to run code for at least a week, so can't do a full PR and test run. Based on the discussions and a read of the code the proposed change would be to simply change this line: https://github.com/sarbbottam/eslint-find-rules/blob/master/src/lib/rule-finder.js#L26 To: return cliEngine.getConfigForFile("./does-not-exist.a9<"); A quick test on RunKit seems to give useful results. https://runkit.com/5d4493461549b300131329cf/5d4493541549b300131329e1 Obviously since I haven't run the code there may be things that I'm missing |
@ljharb I took your branch and added a commit to deal with the test failures. My branch is here. The commit I added is this one. The problem was that eslint 6 tries to resolve plugin module names to file names prior to calling With my commit, all tests pass. |
@lddubeau thanks, that's super appreciated! I'm still getting some failures locally; I'm seeing different failures in CI: https://travis-ci.com/ljharb/eslint-find-rules/builds/121896205 |
@ljharb Glancing quickly at the CI report, shouldn't there be also be a bunch of tests with I see two different failures:
I've force-pushed my branch just now. |
@ljharb At the moment, I'm inclined to think @nosilleg's approach to get the configuration is what we need. Now bear in mind I'm not familiar with the internals of eslint and I'm not familiar at all with It does appear that in eslint 6, This essentially prevents the
Now maybe there's an argument to be made that
|
That's a pretty compelling argument for that approach. Let me pull in your commit. |
Tracking issue for adding eslint v6 to travis-ci and peer deps.
(ref airbnb/javascript#2036)
The text was updated successfully, but these errors were encountered: