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

First line of .eslintignore doesn't seem to get read #8044

Closed
sgjoy1 opened this issue Feb 8, 2017 · 14 comments
Closed

First line of .eslintignore doesn't seem to get read #8044

sgjoy1 opened this issue Feb 8, 2017 · 14 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint

Comments

@sgjoy1
Copy link

sgjoy1 commented Feb 8, 2017

I'm using node.exe to run eslint.js on the command line. I'm feeding in my own .eslintrc file and all of the rules are being respected; however, my .eslintignore file didn't seem to be working. I believe I'm using the default parser.

My command looks a little like:

..somePath../node.exe ..pathToNPMEsLintPackage../eslint.js -c ..workingDirectory../.eslintrc ..workingDirectory../**/*.js

My .eslintignore is in the same working directory as the process, but it only had one line in it. Running the command produced the same result as if I hadn't ignored the file. If I add another line to my .eslintignore file, my result is the same, except anything that produced an error for the second ignore rule is now gone. I've added a comment on the first line and both rules are respected. It looks like something isn't fully reading the .eslintignore file, but it's not a huge issue now that I know what's happening.

EsLint Version: 3.14.1
Node Version: 7.4.0
npm Version: 4.0.5

.eslintrc file:

{
	"env": {
		"browser": true,
		"es6": true
	},
	"extends": "eslint:recommended",
	"parserOptions": {
		"ecmaFeatures": {
			"experimentalObjectRestSpread": true
		},
		"sourceType": "module"
	},
	"rules": {
		"no-console": 2
	}
}



@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Feb 8, 2017
@platinumazure
Copy link
Member

We have an open issue #6759 which talks about .eslintignore patterns being resolved from the current working directory instead of from the location of the .eslintignore. This will be fixed by #7678, but we can't merge that in until we're ready to release 4.0.0 because it's a breaking change.

In the meantime, your best bet is to either run ESLint from the directory where .eslintignore is located, or modify the ignore patterns in .eslintignore to work when they are resolved from the CWD of the ESLint process.

@platinumazure
Copy link
Member

Also: Could you please include the contents of your .eslintignore (from before you made the first line a comment)? Thanks!

@sgjoy1
Copy link
Author

sgjoy1 commented Feb 8, 2017

The issue isn't that .eslintignore isn't working, it's that the first line isn't read. For instance, I have the following structure

Scripts
|_Test.js
|_thing
  |_Test2.js

Using this .eslintignore file:

/Scripts/Test.js
/Scripts/thing/Test2.js

only the files in the thing folder (Test2.js) are ignored.

Using this .eslintignore file:

#skip
/Scripts/Test.js
/Scripts/thing/Test2.js

all files (Test.js and Test2.js) get ignored. It looks like the first line simply isn't read.

@platinumazure
Copy link
Member

platinumazure commented Feb 8, 2017 via email

@sgjoy1
Copy link
Author

sgjoy1 commented Feb 8, 2017

Sorry, that was a typo. they are lowercase.

@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Feb 9, 2017
@alberto
Copy link
Member

alberto commented Feb 18, 2017

@sgjoy1 can you create a repo with a simplified reproducible example?

@sgjoy1
Copy link
Author

sgjoy1 commented Feb 21, 2017

I've added a repo here (https://github.com/sgjoy1/eslintignoreLineReadIssue). You'll need to fill in some of the blanks on the command to run, but you'll eventually see 2 errors. If you open the .eslintignore file and add a comment for the first line, you'll get 1 error.

@alberto
Copy link
Member

alberto commented Feb 21, 2017

There is a weird character in your .eslintignore file which is causing the first line not to match.

$ git diff .eslintignore
diff --git a/.eslintignore b/.eslintignore
index 094fbe9..dbc882c 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1 +1 @@
-<U+FEFF>Scripts/Test.js
\ No newline at end of file
+Scripts/Test.js

Also, you shouldn't use comments in json files, they are not valid. You should use .yml or .js if you want to use comments.

@alberto alberto added question This issue asks a question about ESLint and removed bug ESLint is working incorrectly core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Feb 21, 2017
@sgjoy1
Copy link
Author

sgjoy1 commented Feb 21, 2017

I'm guessing it's a BOM. I'll try to remove it and see if that solves the issue. Thanks for your help!

As for the comment, the documentation says JSON and YAML support comments (http://eslint.org/docs/2.0.0/user-guide/configuring#comments-in-configuration-files). Perhaps that's incorrect?

@sgjoy1
Copy link
Author

sgjoy1 commented Feb 21, 2017

It looks like the BOM was the problem. Thanks for your help.

@alberto
Copy link
Member

alberto commented Feb 21, 2017

Closing this issue as it looks like the question has been answered. Please feel free to visit us in the ESLint Gitter if you have any other issues!

@alberto alberto closed this as completed Feb 21, 2017
@platinumazure
Copy link
Member

Hi @sgjoy1, we use a particular library for reading ESLint configuration files which goes beyond the JSON standard and allows comments, but this only applies to ESLint configuration files. In general, comments are invalid in standard JSON.

@sgjoy1
Copy link
Author

sgjoy1 commented Feb 21, 2017

Hi @platinumazure, I agree with not adding comments to JSON files, but figured @alberto was referencing my .eslintrc.json file since the .eslintignore file is plain text. I see now that he didn't specify which JSON file had comments, so it's possible I have an odd setup somewhere, or it's just confusion between expected behavior and the special library that EsLint is using for .eslintrc.json files.

@alberto
Copy link
Member

alberto commented Feb 21, 2017

Sorry about the confusion. You can use comments in .eslintrc.json files and eslint will deal with them without problems, but I would personally avoid it since other programs (e.g. editors, json validators) won't necessarily work with them.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@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 Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

5 participants