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

visual studio code eslint support #1955

Closed
tzapu opened this issue Apr 9, 2017 · 15 comments · Fixed by #2054
Closed

visual studio code eslint support #1955

tzapu opened this issue Apr 9, 2017 · 15 comments · Fixed by #2054

Comments

@tzapu
Copy link

tzapu commented Apr 9, 2017

Description

The docs here https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md mention that vs code should support the eslint config without doing anything extra

VS Code ESLint plugin automatically detects Create React App's configuration file. So you do not need to create eslintrc.json at the root directory, except when you want to add your own rules. In that case, you should include CRA's config by adding this line:

in practice, with latest versions of everything, i still had to add .eslintrc containing { "extends": "react-app" } in order for the editor to load a config

Expected behavior

VS Code ESLint plugin automatically detects Create React App's configuration file

Actual behavior

VS Code ESLint plugin needs and .eslintrc file to detect any config

Environment

Run these commands in the project folder and fill in their results:

npm ls react-scripts
└── react-scripts@0.9.5
node -v
v7.8.0
npm -v
4.2.0

  1. Operating system:
    macOS

I am not sure if this is a bug or a lack in documentation or I m just doing something wrong.
If it's the docs i can make a pull request I guess
Cheers

@Timer
Copy link
Contributor

Timer commented Apr 15, 2017

Can we trace this down to any specific VSCode version when this stopped working (I haven't tested this myself)? It may be a regression on their end.

Otherwise, we may need to update the documentation to reflect this change.

@anilreddykatta
Copy link
Contributor

@tzapu vscode doesn't seem to detect eslint configuration for apps created using create-react-app.

I have observed similar behavior in vscode-1.11.2

@tzapu
Copy link
Author

tzapu commented Apr 20, 2017

@Timer @anilreddykatta i noticed this on Version 1.11.1 (1.11.1)

so so far, 1.11.1 & 1.11.2 seem not to be working

cheers

@Angarsk8
Copy link

Not working here neither, I'm on version 1.11.2.

@dbaeumer
Copy link

Hi, I maintain the ESLint extension for VS Code and got here due to microsoft/vscode-eslint#230.

I created a react app using create-react-app my-app and the generated package.json file doesn't contain an eslintConfig property. After adding

  "eslintConfig": {
    "extends": "react-app"
  }

things started to work for me. Is there something I am missing ?

@tzapu
Copy link
Author

tzapu commented Apr 27, 2017

i think the confusing bit is that the docs are saying that it just works, you don't need to add anything, as the eslint extension in vscode auto detects create react app's eslint rules

hope this helps
cheers

@dbaeumer
Copy link

To make setup for users easier could the create-react-app generate a corresponding .eslintrc. From all feedback I got it is easier for users to deal with an .eslintrc file than a property in the package.json file.

@gaearon
Copy link
Contributor

gaearon commented May 1, 2017

I don’t think we’ll be creating .eslintrc in the project folder, no. A property in package.json is a supported way to configure ESLint, so we would like to keep using that.

@luftywiranda13
Copy link
Contributor

@gaearon
just for a clear clarification
eslintConfig in package.json is just a way to customize eslint in code editor but has nothing to do with eslint warning/error in browser/cli, right?

@gaearon
Copy link
Contributor

gaearon commented May 1, 2017

Yes. In the browser/cli, we hardcode ESLint to use the react-app configuration. However IDEs can’t know about this.

I think it’s fine if we encourage people to create .eslintrc in their project folder if that solves the problem for VSCode. I’m just saying we won’t be generating it by default.

@gaearon
Copy link
Contributor

gaearon commented May 1, 2017

Does this solve the issue?
Can somebody review this PR please?

#2054

@tzapu
Copy link
Author

tzapu commented May 1, 2017

this seems like satisfactory solution, it's clear enough, it works, all is good in the world again.

thank you very much

@gaearon
Copy link
Contributor

gaearon commented May 1, 2017

Sounds great. Sorry for the trouble. 😛

@vladbilyk
Copy link

vladbilyk commented Jul 18, 2017

I've tried both things (.eslintrc in the root and eslintConfig in packages.config) but with the same result: "Cannot find module 'eslint-config-react-app' Referenced from:". New react app, VSC 1.14.1...

@allstone
Copy link

adding eslintConfig to package.json works for me

samlandfried added a commit to samlandfried/cheat-sheet that referenced this issue Aug 19, 2018
samlandfried added a commit to samlandfried/cheat-sheet that referenced this issue Aug 20, 2018
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants