-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
IgnoredPaths option "dotfiles" causes issue with relative paths #5314
Comments
Hi @rawalter21, thanks for the issue. It looks like there's not enough information for us to know how to help you. If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions. If it's something else, please just provide as much additional information as possible. Thanks! |
Sorry, I'm not sure I follow exactly what you mean. Could you provide a few examples of files being ignored and patterns that cause it? |
Here is some more info to help debug this:
This is an example file path that is being used by eslint:
I was only able to get this, and the other files, to appear by adding:
to the .eslintrc.json file. Otherwise eslint would ignore all of the files as they all begin with '../' and output nothing. In terms of directory structure, we have a top level folder structure that looks like this:
and within gulp_builder is gulpfile.js which contains the task I pasted above. All of the javascript files are within app_storefront_core/cartridge/js/** |
@rawalter21 can you confirm that this isn't just a problem with |
From what I can gather, it sounds like |
I apologize for not adding this earlier but here is the offending code (eslint/lib/ignored-paths.js line 162) that was added in commit #3948:
You are correct in that this is techincally a gulp-eslint issue but there was no issue until the above code was added. What is happening is that the ".*" pattern is causing the relative paths given by gulp-eslint to be ignored. I understand why this pattern was added (to ignore files that start with a period) but maybe the pattern could be updated to ignore the beginning dot on relative paths if thats possible. We were able to work around the problem by adding the option:
to the list of options given to eslint but this should only be a temporary fix. If there is no way around this I will start an issue on the gulp-eslint project to have them fix the issue if possible. |
@rawalter21 unless you can confirm that this is a problem using ESLint outside of Gulp, then the best course of action is to followup with gulp-eslint. |
In this case it would always be a problem if you passed in relative paths (as opposed to absolute paths) no matter how ESLint is used assuming the paths start with a dot. So its not just an issue with gulp-eslint. If the assumption is that ESLint will only take absolute paths or relative paths that don't start with a dot then yes, it is a problem that needs to be resolved on the gulp-eslint side. Really though, the path shouldn't even matter when the ignore check is done as it should only be checking the file and not the whole path but currently it is not. |
I also can confirm that this problem happens with all relative paths due to the pattern |
I'll create a repository and try to reproduce this tonight. |
Turns out the offending code is invoked only by autoconfig, which I didn't realize until I crawled through the source code (and which nobody has yet mentioned). I can reproduce when trying to use autoconfig. This repository shows the bug in action. Follow the steps in README.md to recreate this bug. As far as I'm concerned, this is a real bug. I don't know much about globbing but I'm wondering if the I'm not sure how gulp-eslint factors into this-- the command in the comment above seems like it should be linting, not running autoconfig. That issue should be sent to gulp-eslint. |
Interesting. I think I've actually ran into this before, but didn't pay enough attention to notice it. Is it possible to reproduce this without autoconfig? I think autoconfig uses slightly different pattern matching then core itself. |
I couldn't reproduce with ordinary linting runs. I can keep trying. Are there other ways to specify paths to lint besides CLI args? |
Not that I know of, how about navigating into |
Autoconfig uses the same glob-utils that the rest of core does, but maybe it's an issue with the cwd. I'll do some investigating. |
@ilyavolodin Tried that earlier, it doesn't reproduce the issue. |
I've done a little more digging and I'm starting to understand this. What @rawalter21 said in his first comment is correct, we have a very simple test for "dotfiles" (which is anything starting with a Now that I'm starting to understand the code and the issue, I should be able to come up with some kind of solution this weekend. |
@IanVS If we reconcile cli-engine to use the same glob-utils function, will that introduce the issue in linting as well? |
Not to worry, I'll make sure it doesn't. 😁 |
Status update: so far I've done a lot of investigating, cleaned up the tests, and added a failing test for this issue: eslint/tests/lib/ignored-paths.js Line 355 in 8f07d0a
Now hopefully I'll be able to make progress on actually solving it tomorrow. |
@IanVS Great to hear! Do you still want me to keep my repository around, or may I remove it? |
You can remove it. Thanks for the demonstration. On Sun, Feb 28, 2016, 18:37 Kevin Partington notifications@github.com
|
Another update: I made some more progress on branch issue5314, and although all the |
Squashed commits: 28b1368 Clean up tests fe805b5 Further test cleanup c8e45c8 Pull out and fix path resolution for ignored-paths 4647bfc Use process.cwd() at time of construction fb8f2fa Do not ignore files with `../` as dotfiles ba2cf77 Consistently use resolved paths abe6279 Clean up cli.js tests 1a347bb Deal with relative file paths
Squashed commits: 28b1368 Clean up tests fe805b5 Further test cleanup c8e45c8 Pull out and fix path resolution for ignored-paths 4647bfc Use process.cwd() at time of construction fb8f2fa Do not ignore files with `../` as dotfiles ba2cf77 Consistently use resolved paths abe6279 Clean up cli.js tests 1a347bb Deal with relative file paths
Squashed commits: 28b1368 Clean up tests fe805b5 Further test cleanup c8e45c8 Pull out and fix path resolution for ignored-paths 4647bfc Use process.cwd() at time of construction fb8f2fa Do not ignore files with `../` as dotfiles ba2cf77 Consistently use resolved paths abe6279 Clean up cli.js tests 1a347bb Deal with relative file paths f02b1ba5ac9b8204d4d96b7067cf0c0ece3a1525 Shim path.isAbsolute for node 0.10 Shim path.isAbsolute for node 0.10
Squashed commits: 28b1368 Clean up tests fe805b5 Further test cleanup c8e45c8 Pull out and fix path resolution for ignored-paths 4647bfc Use process.cwd() at time of construction fb8f2fa Do not ignore files with `../` as dotfiles ba2cf77 Consistently use resolved paths abe6279 Clean up cli.js tests 1a347bb Deal with relative file paths f02b1ba5ac9b8204d4d96b7067cf0c0ece3a1525 Shim path.isAbsolute for node 0.10 8510d639523675e0e14c51fa7ef09c4910ba166b Test for file existence before directory check
Squashed commits: 28b1368 Clean up tests fe805b5 Further test cleanup c8e45c8 Pull out and fix path resolution for ignored-paths 4647bfc Use process.cwd() at time of construction fb8f2fa Do not ignore files with `../` as dotfiles ba2cf77 Consistently use resolved paths abe6279 Clean up cli.js tests 1a347bb Deal with relative file paths f02b1ba5ac9b8204d4d96b7067cf0c0ece3a1525 Shim path.isAbsolute for node 0.10 8510d639523675e0e14c51fa7ef09c4910ba166b Test for file existence before directory check 05ff54994f012269945c5712fd98ca1e1f4b1cf1 Use path-is-absolute ponyfill
Squashed commits: 28b1368 Clean up tests fe805b5 Further test cleanup c8e45c8 Pull out and fix path resolution for ignored-paths 4647bfc Use process.cwd() at time of construction fb8f2fa Do not ignore files with `../` as dotfiles ba2cf77 Consistently use resolved paths abe6279 Clean up cli.js tests 1a347bb Deal with relative file paths f02b1ba5ac9b8204d4d96b7067cf0c0ece3a1525 Shim path.isAbsolute for node 0.10 8510d639523675e0e14c51fa7ef09c4910ba166b Test for file existence before directory check 05ff54994f012269945c5712fd98ca1e1f4b1cf1 Use path-is-absolute ponyfill
Squashed commits: 28b1368 Clean up tests fe805b5 Further test cleanup c8e45c8 Pull out and fix path resolution for ignored-paths 4647bfc Use process.cwd() at time of construction fb8f2fa Do not ignore files with `../` as dotfiles ba2cf77 Consistently use resolved paths abe6279 Clean up cli.js tests 1a347bb Deal with relative file paths f02b1ba5ac9b8204d4d96b7067cf0c0ece3a1525 Shim path.isAbsolute for node 0.10 8510d639523675e0e14c51fa7ef09c4910ba166b Test for file existence before directory check 05ff54994f012269945c5712fd98ca1e1f4b1cf1 Use path-is-absolute ponyfill 34e9a1571bbe686cca7d3e924f4d4b94f9ec4b0c Avoid process.chdir in glob-util tests
Squashed commits: 28b1368 Clean up tests fe805b5 Further test cleanup c8e45c8 Pull out and fix path resolution for ignored-paths 4647bfc Use process.cwd() at time of construction fb8f2fa Do not ignore files with `../` as dotfiles ba2cf77 Consistently use resolved paths abe6279 Clean up cli.js tests 1a347bb Deal with relative file paths f02b1ba5ac9b8204d4d96b7067cf0c0ece3a1525 Shim path.isAbsolute for node 0.10 8510d639523675e0e14c51fa7ef09c4910ba166b Test for file existence before directory check 05ff54994f012269945c5712fd98ca1e1f4b1cf1 Use path-is-absolute ponyfill 34e9a1571bbe686cca7d3e924f4d4b94f9ec4b0c Avoid process.chdir in glob-util tests baaa07e Force posix style paths a521d6c Update to node-ignore 3.x and address PR comments
@rawalter21, could you try using master now that we've reworked some of our ignore logic, to see if you're still having problems? I believe we've fixed it, but it would be great if you can confirm. |
@IanVS in my investigation today, it looks like brace expansion has been lost in the switch from |
I don't think brace expansion is legal in a |
Not according to the current eslint documentation |
Ah, good catch. That's a bug in the documentation. I just tested brace expansion in a eslint . --ignore-pattern *.test.js --ignore-pattern *.mock.js If you'd like to submit an issue for the documentation issue, that would be great. |
Ah! Fantastic. This is a good answer. Thank you. Out of curiosity, is there a reason the gitignore doesn't use brace expansion? |
As far as I understand, it isn't a valid glob on all posix operating systems. |
Sure. One more question, the related PR #5461 isn't released yet? |
|
When the working directory is outside of the directory in which the Javascript files are stored the relative paths can cause the "dotfiles" option to ignore files incorrectly. For example, if the relative path starts with a dot like in the following example:
the "dotfiles" option will cause all of these files to be ignored. You are able to get around this by setting dotfiles to false but this will also cause files that begin with a dot to be considered. Also, the dotfiles attribute is not in the documentation so it was not immediately clear what was going on.
This issue was introduced as part of the fix for #3948
The text was updated successfully, but these errors were encountered: