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

eslint throws if package.json is in UTF-8 with BOM #6556

Closed
vsemozhetbyt opened this issue Jun 28, 2016 · 4 comments
Closed

eslint throws if package.json is in UTF-8 with BOM #6556

vsemozhetbyt opened this issue Jun 28, 2016 · 4 comments
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 bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@vsemozhetbyt
Copy link
Contributor

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

What did you do?...
I've checked a .js file in the NW.js project directory with package.json in UTF-8 with BOM (there are no eslint settings in this package.json).

What did you expect to happen?
Output from eslint according to .eslintrc.json in some ancestor directory.

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

Cannot read config file: ...\package.json
Error: Cannot read config file: ...\package.json
Error: Unexpected token  in JSON at position 0
SyntaxError: Cannot read config file: ...\package.json
Error: Cannot read config file: ...\package.json
Error: Unexpected token  in JSON at position 0
    at Object.parse (native)
    at loadJSONConfigFile (...\node_modules\eslint\lib\config\config-file.js:121:21)
    at loadPackageJSONConfigFile (...\node_modules\eslint\lib\config\config-file.js:179:16)
    at loadConfigFile (...\node_modules\eslint\lib\config\config-file.js:208:26)
    at Object.load (...\node_modules\eslint\lib\config\config-file.js:499:18)
    at loadConfig (...\node_modules\eslint\lib\config.js:64:33)
    at getLocalConfig (...\node_modules\eslint\lib\config.js:126:23)
    at Config.getConfig (...\node_modules\eslint\lib\config.js:227:22)
    at processText (...\node_modules\eslint\lib\cli-engine.js:223:27)
    at processFile (...\node_modules\eslint\lib\cli-engine.js:298:18)

If I resave the package.json in UTF-8 without BOM, all is OK.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jun 28, 2016
@platinumazure platinumazure 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 Jun 28, 2016
@platinumazure
Copy link
Member

This seems like it shouldn't throw. Unless JSON is very explicitly not allowed to be encoded in UTF8 with BOM, I think we should see if we can work around this.

@gyandeeps
Copy link
Member

gyandeeps commented Jun 28, 2016

@vsemozhetbyt Can you read the file using nodejs readFile function outside of Eslint?
Can you plz try it. Thanks

UPDATE:
I tried it with node 6.0 to read json file wiht utf-8 bom encoding it works but when I tried doing JSON.parse on it it gave me the error. So seems more like a non-eslint issue here.

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Jun 28, 2016

@platinumazure NW.js has no problem with this JSON. I think this is not concerned JSON format by itself, but IO file preprocessing.

@gyandeeps Should not Eslint strip BOM before calling JSON.parse on a string from a Unicode file? Node.js team leaves BOM stripping up to userland.

@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jun 29, 2016
@mysticatea
Copy link
Member

mysticatea commented Jun 29, 2016

Yeah.
We are stripping BOM from source code before linting.
We should strip BOM from config files as same as that.

@mysticatea mysticatea self-assigned this Jul 2, 2016
@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
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 bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

No branches or pull requests

5 participants