wesbos / eslint-config-wesbos

No-Sweat™ Eslint and Prettier Setup - with or without VS Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Run npx install-peerdeps eslint-config-sarpik --dev --yarn
  2. Crack open your package.json and
    1. replace "extends": "react-app" with "extends": "sarpik"
    2. replace "eslint": "5.x" with "eslint": "6.x" like so: yarn add eslint@6.x, or replace yourself & run yarn install
      1. verify that eslint's version is 6.x.y: run node node_modules/.bin/eslint --version
    3. append --ext js,jsx,ts,tsx to eslint every time you call it (required for eslint 6.x, see kiprasmel#4)

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 🚀

Outcome: https://github.com/sarpik/cra-eslint-ts

thanks :) It works! Adding