create-react-app does NOT need ejecting
kiprasmel opened this issue · comments
You can use eslint with CRA without ejecting!
I've updated my fork's installation steps for CRA - you can take them & update yours too.
TL;DR:
- Run
npx install-peerdeps eslint-config-sarpik --dev --yarn
- Crack open your
package.json
and- replace
"extends": "react-app"
with"extends": "sarpik"
- replace
"eslint": "5.x"
with"eslint": "6.x"
like so:yarn add eslint@6.x
, or replace yourself & runyarn install
- verify that eslint's version is
6.x.y
: runnode node_modules/.bin/eslint --version
- verify that eslint's version is
- append
--ext js,jsx,ts,tsx
toeslint
every time you call it (required for eslint6.x
, see kiprasmel#4)
- replace
Your package.json
should have this:
{
"scripts": {
"lint": " eslint . --ext js,jsx,ts,tsx",
"lint:fix": "eslint . --ext js,jsx,ts,tsx --fix"
},
"eslintConfig": {
"extends": "sarpik"
},
"devDependencies": {
"<other-dev-dependency>": "<version>",
"eslint": "6.x"
}
}
Try it out:
npx create-react-app cra-eslint-ts --template typescript # typescript is optional
cd cra-eslint-ts
and then follow the steps above.
Finally, run yarn lint
and yarn lint:fix
& verify that yarn start
still works 🚀
thanks :) It works! Adding