Skip to content
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

Clarification on behavior of dot directories #12348

Closed
brandonchinn178 opened this issue Oct 1, 2019 · 9 comments · Fixed by #12600
Closed

Clarification on behavior of dot directories #12348

brandonchinn178 opened this issue Oct 1, 2019 · 9 comments · Fixed by #12600
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation help wanted The team would welcome a contribution from the community for this issue

Comments

@brandonchinn178
Copy link

Tell us about your environment

  • ESLint Version: v6.3.0
  • Node Version: v12.8.1
  • yarn Version: 1.17.3

What parser (default, Babel-ESLint, etc.) are you using?

@typescript-eslint/parser

Please show your full configuration:

Configuration
{
  "env": {
    "browser": true,
    "es6": true,
    "node": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:prettier/recommended",
    "plugin:react/recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint", "simple-import-sort", "prettier"],
  "parserOptions": {
    "sourceType": "module"
  },
  "rules": {
    "indent": ["error", 2],
    "react/display-name": "off",
    "react/prop-types": "off",
    "react/react-in-jsx-scope": "off",
    "simple-import-sort/sort": "error",
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/member-delimiter-style": "off",
    "@typescript-eslint/no-unused-vars": ["error", {
      "argsIgnorePattern": "^_$"
    }]
  },
  "globals": {
    "React": "writable"
  },
  "settings": {
    "react": {
        "version": "detect"
    }
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

What actually happened? Please include the actual, raw output from ESLint.

$ yarn eslint client/.storybook/config.js 

.../client/.storybook/config.js
  0:0  warning  File ignored because of a matching ignore pattern. Use "--no-ignore" to override

✖ 1 problem (0 errors, 1 warning)

What did you expect to happen?

client/.storybook/config.js should be linted

Are you willing to submit a pull request to fix this bug?

Sure?

More details

I see this comment: #4828 (comment)

Thanks. So this looks like a bug, we should be linting anything passed on the command line. We should fix that.

But it seems like that's not the case, from this test suite:

it("should not check .hidden files if they are passed explicitly without --no-ignore flag", function() {
engine = new CLIEngine({
cwd: path.join(fixtureDir, "..")
});
var report = engine.executeOnFiles(["fixtures/files/.bar.js"]);
assert.equal(report.results.length, 0);
});
it("should check .hidden files if they are passed explicitly with --no-ignore flag", function() {
engine = new CLIEngine({
ignore: false,
cwd: path.join(fixtureDir, "..")
});
var report = engine.executeOnFiles(["fixtures/files/.bar.js"]);
assert.equal(report.results.length, 1);
assert.equal(report.results[0].messages.length, 0);
});

The documentation doesn't seem very helpful. Searching for "dot files" doesn't help me, and the section on .eslintignore only mentions:

Lines preceded by ! are negated patterns that re-include a pattern that was ignored by an earlier pattern.

Even though I'm not ignoring anything. It's also weird that the message says File ignored because of a matching ignore pattern because I don't have a .eslintignore file in my project.

The weird part is that yarn eslint client/.storybook/ works. Can we get some clarification on this issue (and the expected behavior) in the docs and/or in the CLI?

Issues that I've already looked at:

@brandonchinn178 brandonchinn178 added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Oct 1, 2019
@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion documentation Relates to ESLint's documentation and removed triage An ESLint team member will look at this issue soon labels Oct 1, 2019
@mysticatea
Copy link
Member

mysticatea commented Oct 1, 2019

Thank you for your report.

Indeed, documentation is not enough.

The logic to ignore files has quirks for historical reason. I don't know the reason, but I found some quirks while I implemented #11546 and #12274. The following list is it.

  • ESLint ignores /node_modules/*, /bower_components/*, and dotfiles by default.
  • If a path is a glob pattern or a directory path rather than a file path, and the path starts with . or contains /., then ESLint doesn't ignore dotfiles.
  • If --no-ignore is present, ESLint ignores --ignore-path, --ignore-pattern, and .eslintignore. This means ESLint ignores the files which match the default ignore patterns.
  • But if --no-ignore is present, and a path is a file path rather than a glob pattern nor a directory path, then ESLint doesn't ignore the file even if the path matches the default ignore patterns.

Anyway, I'd like to recommend to configure to unignore dotfiles you want because ignoring dotfiles is essential behavior.

# .eslintignore
!.storybook

@mysticatea mysticatea removed the bug ESLint is working incorrectly label Oct 1, 2019
@kaicataldo kaicataldo added Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ help wanted The team would welcome a contribution from the community for this issue labels Oct 1, 2019
@brandonchinn178
Copy link
Author

Yes, I can unignore manually, but I would like to echo what this person said: #10341 (comment)

It's weird that you use an ignore list to un-ignore things.

I would personally request the following changes:

  1. Change the error message to mention whether the ignored file is due to a default, implicit ignore pattern
  2. Update docs to include the minutiae you listed out
  3. (optional) It would be amazing to add a dotpaths key to eslintrc that specifies dot files/directories that shouldn't be "auto-ignored".

Thanks!

@mysticatea
Copy link
Member

I have the same comment. However, ignoring dotfiles is a common behavior.

About 1 and 2, PR is welcome.

About 3, you can do it once #12274 merged.

@snhardin
Copy link
Contributor

snhardin commented Oct 2, 2019

Hello! I'd like to take a stab at this. I use ESLint a lot for work and would enjoy the opportunity to give back. Any pointers on where to focus my attention are appreciated.

@brandonchinn178
Copy link
Author

brandonchinn178 commented Oct 2, 2019

@snhardin For 2, I would recommend editing this section with more details on the implicit ignore patterns eslint automatically applies (see @mysticatea's first comment). Also, the documentation says

File ignored because of your .eslintignore file. Use --no-ignore to override.

But the message shown is different

File ignored because of a matching ignore pattern. Use "--no-ignore" to override

See https://github.com/eslint/eslint/blob/master/lib/cli-engine/cli-engine.js#L293

For 1, it seems like the code tries to handle this, but the regex isn't good enough: it only matches /^\./, when the problem happens when a dot file/directory (e.g. client/.storybook/foo.js) occurs later on in the path. So it would probably mean fixing the regex

I can help with 3 after that PR gets closed, but if you get to it before me, go for it

@snhardin
Copy link
Contributor

Hello everyone. Will be submitting a PR for this soon. Thank you for your patience. 🙂

@kaicataldo kaicataldo removed the Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ label Nov 19, 2019
snhardin added a commit to snhardin/eslint that referenced this issue Nov 25, 2019
@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Dec 31, 2019
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that accepted issues failing to be implemented after 90 days tend to
never be implemented, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@kaicataldo kaicataldo reopened this Jan 2, 2020
@kaicataldo
Copy link
Member

Reopening this because we have an open PR for it.

@kaicataldo kaicataldo removed the auto closed The bot closed this issue label Jan 2, 2020
@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Feb 2, 2020
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that accepted issues failing to be implemented after 90 days tend to
never be implemented, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@kaicataldo kaicataldo self-assigned this Feb 3, 2020
@kaicataldo kaicataldo removed the auto closed The bot closed this issue label Feb 3, 2020
@kaicataldo kaicataldo reopened this Feb 3, 2020
@mdjermanovic mdjermanovic linked a pull request Feb 9, 2020 that will close this issue
ankon added a commit to Collaborne/material-kanban that referenced this issue Oct 2, 2020
Explicitly listing the .storybook/stories path in the package.json's `test:lint` invocation
works for ensuring that things get linted as part of the CI process, but VSCode (or any other
editor, for that matter) isn't aware of that and won't flag issues in these files. This leads
to multiple "fix warnings" commits and releases that are not working.

Instead this commit changes the .eslintignore file to explicitly un-ignore the .storybook directory
as advised by eslint/eslint#12348 (comment).

Note that this commit also fixes a bunch of now-reported warnings in other files that previously
got excluded.
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Dec 31, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation help wanted The team would welcome a contribution from the community for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants