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

create-react-app does NOT need ejecting #42

Closed
kiprasmel opened this issue Feb 3, 2020 · 1 comment
Closed

create-react-app does NOT need ejecting #42

kiprasmel opened this issue Feb 3, 2020 · 1 comment

Comments

@kiprasmel
Copy link

kiprasmel commented Feb 3, 2020

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 Upgrading to eslint v6 requires --ext js,jsx,ts,tsx to lint anything other than js kiprasmel/eslint-config-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

@wesbos
Copy link
Owner

wesbos commented Sep 11, 2020

thanks :) It works! Adding

@wesbos wesbos closed this as completed Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants