-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Support overridable configs #58
Conversation
We had discussed using object hashes for overrides: "overrides": {
"**/foo.js": { "esnext": false }
} I decided against doing it that way, because it gives you no control over merge order if two patterns match the same file. |
There is still debate over exactly what to name some of these options. Once that is settled, I will update this PR (including docs). |
The overrides functionality is really nice! Is it possible to provide a concrete example on the benefit of the array versus the object hashes? It seems like it just makes everything more complex because the order in the array is important. It's because of merge conflicts when more globbing patterns matches the same file, right? But why not apply the most specific rules for that file? "overrides": {
"test/test.js": {"esnext": true},
"test/*.js": { "esnext": false }
} Because Just wanted some more information regarding this :). |
Yes. The array syntax is necessary to support multiple glob patterns anyways: "overrides": [
{
"files": ["test/*.js", "!test/foo.js"]
}
] So I think the array syntax needs to be a part of the final solution no matter what. It might be possible to allow both array and object. To be honest, the array solution was just easier to implement.
I am not sure how to reliably determine "the most specific match". Which of the following more specifically matches
Also, how do we then merge settings? Least specific to most specific? In that case the following is confusing: "overrides": {
"test/test.js": {"esnext": true},
"test/*.js": { "esnext": false, spaces:3}
} If we merge every match, in order of specificity., the settings for I think if we allow the object pattern we should only apply a single "most specific" match (I am still not sure how best to determine that). |
Good point
Not sure either
I don't think that's confusing. But maybe that's just me. In general, whatever gets implemented, as long as it's clearly documented, we're good :). Just wanted to share my opinion. Hopefully others will pick in into this discussion. |
Yeah, I fully intend to document before it gets merged. Still looking for feedback at this point. |
// always use the Babel parser so it won't throw | ||
// on esnext features in normal mode | ||
config.parser = 'babel-eslint'; | ||
config.plugins = ['babel']; |
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.
Also, I noticed that if opts.esnext
is not true
, we overwrite any plugins they might have specified. Should we just be appending/prepending babel to the list?
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.
Oh, noes. That's why 90c95ed#commitcomment-14948953 Good eye! :)
It should be prepended.
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.
@sindresorhus You want me to fix it here or a separate PR from master
?
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.
@jamestalmage Master. I need to do a patch release. :)
If the `esnext` option is `false`, we currently blow away existing plugins, replacing it with only the `babel` plugin. This prepends it. This does not come with a test, as option handling is currently pretty difficult. We can add the appropriate test for this there. Reference: xojs#58 (comment)
@sindresorhus @kevva @vdemedes - Do you guys have any additional feedback? If I get this rebased is it good to merge? |
Good work, looking forward to using this! |
var resolveFrom = require('resolve-from'); | ||
var objectAssign = require('object-assign'); | ||
var homeOrTmp = require('home-or-tmp'); | ||
var mutlimatch = require('multimatch'); |
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.
mutlimatch
=> multimatch
Sorry about the delay. I've just had too many PRs to review. Took a thorough look now and it generally looks fantastic! Also thanks for refactoring the code into a more readable and maintainable state 👌. I added a few minor inline comments, but it's pretty close to be mergeable. Currently, all the individual pieces are tested, but could use a real world integration test in It's 🎄so no rush on this :) |
1cfad64
to
34924f8
Compare
@sindresorhus - this should be all set. I added an undocumented |
@sindresorhus - Are we good to merge here? I would like to avoid rebasing again. Once merged I suggest we let it live on master and test it against a few projects before release. It was a significant refactor followed by a problematic rebase. I'm fairly confident I got it right, but better to practice caution. |
Gonna let it live on master for a few days while I test it on some of my projects. |
...any chance this will be released anytime soon? |
Fixes #22.
This allows for overridable configs based on glob patterns.
Usage is as follows:
The base config is:
For everything in the
test
directory the config is:With the exception of
test/foo.js
which has the following config:It is important to note that overrides are cumulative, and processed in the order specified in the array.
If two overrides match the same file, the latter will takes precedence over the former.