question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When running eslint from another directory and using --ignore-path, paths are not relative to .eslintignore location

See original GitHub issue

What version of ESLint are you using? 3.1.1

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

Please show your full configuration: Project structure:

.eslintignore
.eslintrc
bar.js
src/foo.js

.eslintrc

{
    "root": true,
    "extends": "eslint:recommended"
}

.eslintignore

src/foo.js

What did you do? Please include the actual source code causing the issue.

$ eslint foo.js --ignore-path ../.eslintignore

C:\dev\eslint-bug\src\foo.js
  1:1  error  'test' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)

What did you expect to happen? Expected C:\dev\eslint-bug\src\foo.js to be ignored

What actually happened? Please include the actual, raw output from ESLint. Errors were reported for C:\dev\eslint-bug\src\foo.js:

C:\dev\eslint-bug\src\foo.js
  1:1  error  'test' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)

In Configuring ESLint it says “Paths are relative to .eslintignore location or the current working directory”. As a user, I would assume that if I passed in --ignore-path that it would ignore files as if I had called ESLint from that directory.

I see that there have been a lot of issues opened regarding ESLint ignore and parent directories, but after eslint/eslint#5694, ignoring files in SublimeText with SublimeLinter-eslint has been broken. There is an open PR to fix an existing issue with loading .eslintignore in SublimeLinter-eslint (roadhump/SublimeLinter-eslint#145), but it doesn’t work after ESLint 2.5.0.

There is an option in the CLIEngine to specify a cwd. If my above process is “working as intended” (or perhaps I have misinterpreted the documentation), then it would be great to be able to pass in a --cwdoption for the command line so that the relative paths can be loaded correctly.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:30 (27 by maintainers)

github_iconTop GitHub Comments

10reactions
IanVScommented, Jul 28, 2016

It seems reasonable to me to use a provided --ignore-path directory as the base dir when we convert the filename to a relative path. I’ve tried a possible implementation of this and it seems to work and not break any of our existing tests, would be happy to submit a PR if this is accepted by the TSC.

4reactions
IanVScommented, Jul 28, 2016

Or would it be a bugfix? I can’t think of a single reason why someone would want the behavior of the .eslintignore file to depend on cwd when linting is performed. I doubt that was intended, but maybe I’m wrong. That’s something for the TSC to decide anyway. I’m tossing it on the agenda.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignoring Code - ESLint - Pluggable JavaScript Linter
You can tell ESLint to ignore specific files and directories using ignorePatterns ... --ignore-path means that the existing .eslintignore file is not used....
Read more >
Disable eslint rules for folder - Stack Overflow
To ignore some folder from eslint rules we could create the file .eslintignore in root directory and add there the path to the...
Read more >
ESLint | IntelliJ IDEA Documentation - JetBrains
Paths relative to content roots can be used if some linted files are not under the project base directory in the folder hierarchy....
Read more >
Configuring ESLint - ESLint中文文档
Configuration Files - use a JavaScript, JSON or YAML file to specify configuration information for an entire directory and all of its subdirectories....
Read more >
gulp-eslint-new - npm
ignorePath. Type: string. The path to a file ESLint uses instead of .eslintignore in the current working directory.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found