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

Make .eslintignore work like .gitignore [$100] #2365

Closed
segrey opened this Issue Apr 23, 2015 · 15 comments

Comments

Projects
None yet
8 participants
@segrey
Copy link

segrey commented Apr 23, 2015

The project tree looks like

/home/user/my-project
├── .eslintignore
└── foo.js

.eslintignore

*/
*.js

File foo.js is expectedly ignored when running eslint foo.js

/home/user/my-project $ eslint foo.js 

foo.js
  0:0  warning  File ignored because of your .eslintignore file. Use --no-ignore to override

✖ 1 problem (0 errors, 1 warning)

However, file foo.js is unexpectedly linted when running with full path specified: eslint /home/user/my-project/foo.js

/home/user/my-project $ eslint /home/user/my-project/foo.js

/home/user/my-project/foo.js
  1:0  error  Infix operators must be spaced                 space-infix-ops
  1:0  error  "a" is not defined                             no-undef
  1:1  error  Newline required at end of file but not found  eol-last
  1:5  error  Missing semicolon                              semi

✖ 4 problems (4 errors, 0 warnings)

Expected behavior: /home/user/my-project/foo.js is also ignored.

Did you help close this issue? Go claim the $100 bounty on Bountysource.

@nzakas nzakas added the triage label Apr 24, 2015

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Apr 24, 2015

Will need to investigate, we are just using minimatch to match the pattern against the filename, so we will need to take a close look.

@nzakas nzakas added bug core accepted and removed triage labels Apr 24, 2015

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented May 9, 2015

This is an expected behavior of minimatch. In order to conditionally match at the front of a pattern, you'd need to do this:

**/foo.js

I'm not sure if there's a change for us to make here.

@segrey

This comment has been minimized.

Copy link
Author

segrey commented May 21, 2015

Probably, eslint could change how it uses minimatch. For instance, eslint could pass paths relative to working directory, like it does for other files.
That would allow to enable the same behavior regardless of how a path to a given file is specified.

/home/user/my-project $ eslint /home/user/my-project/foo.js
/home/user/my-project $ eslint foo.js
/home/user/my-project $ eslint ../my-project/foo.js
@gyandeeps

This comment has been minimized.

Copy link
Member

gyandeeps commented Aug 27, 2015

This has been a long standing issue, either the answer is #2365 (comment) or the solution would be a breaking change (might change if I invest more time)

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Aug 28, 2015

I think long term we need to make .eslintignore act just like .gitignore. That would be a breaking change, so probably hold off until we are ready for 2.0

@gyandeeps

This comment has been minimized.

Copy link
Member

gyandeeps commented Aug 28, 2015

If thats the plan then lets add the milestone 2.0 here. And also add breaking?

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Aug 28, 2015

👍

@nzakas nzakas referenced this issue Aug 28, 2015

Closed

Roadmap: 2.0.0 #3561

11 of 11 tasks complete

@nzakas nzakas modified the milestone: v2.0.0 Aug 28, 2015

@nzakas nzakas added the breaking label Aug 28, 2015

@lo1tuma

This comment has been minimized.

Copy link
Member

lo1tuma commented Aug 29, 2015

FWIW: the ignore module implements the .gitignore spec.

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Aug 31, 2015

Nice!

@JulianLaval

This comment has been minimized.

Copy link

JulianLaval commented Aug 31, 2015

Happy to take the lead on this if no one else is keen :)

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Aug 31, 2015

Absolutely. You'll become the king of breaking changes. :)

@JulianLaval

This comment has been minimized.

Copy link

JulianLaval commented Aug 31, 2015

Hehe >:)

@OliverJAsh

This comment has been minimized.

Copy link
Contributor

OliverJAsh commented Dec 23, 2015

Would this include the ability to have multiple nested .gitignores, i.e. folder specific ignores?

@ilyavolodin

This comment has been minimized.

Copy link
Member

ilyavolodin commented Dec 23, 2015

No, this just changes the way globs are handled.

@nzakas nzakas changed the title Make .eslintignore work like .gitignore [$50] Make .eslintignore work like .gitignore [$100] Dec 27, 2015

gronke added a commit to gronke/eslint that referenced this issue Jan 4, 2016

gronke added a commit to gronke/eslint that referenced this issue Jan 4, 2016

gronke added a commit to gronke/eslint that referenced this issue Jan 4, 2016

gronke added a commit to gronke/eslint that referenced this issue Jan 4, 2016

gronke added a commit to gronke/eslint that referenced this issue Jan 4, 2016

gronke added a commit to gronke/eslint that referenced this issue Jan 4, 2016

gronke added a commit to gronke/eslint that referenced this issue Jan 5, 2016

@nzakas nzakas closed this in #3948 Jan 7, 2016

nzakas added a commit that referenced this issue Jan 7, 2016

Merge pull request #3948 from gronke/issue-2365
Breaking: ignore absolute paths relative to .eslintignore (fixes #2365)

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.