-
-
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
Negative .gitignore rules cause xo to pass everything #154
Negative .gitignore rules cause xo to pass everything #154
Comments
I wonder if we could simply filter out patterns starting with |
@sindresorhus I think that will not work because negative matches override positive matches. So, let's say the
, if we strip the globby(['**/*', 'a/b.js'], {ignore: ['a']}) then That is why I was initially suggesting to change const flatten = require('lodash.flatten')
Promise.all([
globby(['**/*'], {ignore: ['a']}), // don't do '!a/b.js' rule just yet...
globby(['a/b.js']) // but use it in second call.
])
.then(matches => flatten(matches)) |
FWIW this has been a problem with globby for a while now. I was writing a build script once and ran into this exact problem. |
@Qix- Sorry, I can't follow you. Did you already solved this problem within your build script? If you did, would you mind sharing your thoughts how this issue should be solved? |
Manually parsing the beginning using something like The inverse could be done here. |
Disclaimer: This is just an idea, I must admit, I do not have enough time to thoroughly figure out the impact of this atm. As far as I can see, we do not need to use the const negate = patterns => patterns.map(p => p.startsWith('!') ? p.substr(1) : '!' + p);
const parseGitignore = patterns => negate(patterns).sort(p => p.startsWith('!') ? 1 : -1);
parseGitignore(['some_folder', '!some_folder/but_not_this_file'])
// => [ 'some_folder/but_not_this_file', '!some_folder' ] |
* split out getGitIgnores from getIgnores * adapt test cases accordingly * extend gitignore test case with negative pattern * invert gitignore patterns and feed sotred as glob instead of opts.ignore fix #154
* split out getGitIgnores from getIgnores * adapt test cases accordingly * extend gitignore test case with negative pattern * invert gitignore patterns and feed sotred as glob instead of opts.ignore fix #154
There is a regression in version 0.17, which in the worst case leads to
xo
ignoring all files and returning exit code 0, even though there are issues in the code. For instance,xo@0.17
will pass all tests in areact-native
project no matter what because the.gitignore
file has entries that start with!
.Test case
Here is a simple example project to demonstrate the issue:
package.json
index.js
.gitignore
## Expected result
Actual result
xo returns no error even though the semicolon is missing.
Running with
xo@0.16
will yield the correct result.Cause
Starting in
0.17
, files in.gitignore
are also ignored inxo
. But there is a difference in howgit
andglobby
parse the ignore list.In
.gitignore
,!a/b.js
means: "Do not ignore this file".In
globby
andglob
, passing!a/b.js
to the ignore option means: "Do ignore all files except this one"The text was updated successfully, but these errors were encountered: