Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using create-react-app and Sublimelinter ESlint together

I use facebook's create-react-app, which intentionally hide all the configuration setup, and leave us with a lovely simple file structure

a lovely file structure

That's great! but there's one really annoying thing that come up:

SublimeLinter is no longer works because the .eslintrc configuration file is not longer at the root of the project.

Key points

  • I know I can put another .eslintrc file at the root, but I would like to be able to set my rules in one place

  • I know it is possible to npm eject to get the entire project structure out in front, but I would like to keep things simple. otherwise it becomes just another boilerplate

  • I noticed that in the package.json a clue inside the package.json

What I already tried?

a direction I thought about is to change:

"eslintConfig": {
   "extends": "./node_modules/react-scripts/config/eslint.js"
}

to:

"eslintConfig": {
   "extends": "./.eslintrc.js"
}

but it seems to require all the eslint-plugins (which are magically hidden from node_modules) so I'm not sure it's the right way.

Any insights?

like image 201
Asaf Katz Avatar asked Aug 03 '16 17:08

Asaf Katz


People also ask

Do I need to install ESLint With create React app?

Install the ESLint packages for TypeScript and Jest support. Note, ESLint is installed with create-react-app, so you don't need to explicitly install it.


1 Answers

SublimeLinter is no longer works because the .eslintrc configuration file is not longer at the root of the project.

This is not correct.

SublimeLinter will work just fine but you currently have to install a few things globally. The generated project’s README includes the instructions to get linter IDE integration working:

Finally, you will need to install some packages globally:

npm install -g eslint babel-eslint eslint-plugin-react eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-flowtype

We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. The ESLint team is already working on a solution to this so this may become unnecessary in a couple of months.

This is, of course, assuming that you’re fine with the ESLint configuration we picked for you.

like image 175
Dan Abramov Avatar answered Oct 19 '22 02:10

Dan Abramov