Overview
Use Create-react-app Scaffolding feel its eslint configuration a bit good, so consider not create-react-app scaffolding how to use these configurations.
I then eject the Create-react-app scaffold, view its detailed configuration and official documents, summarize the method of using its Eslint configuration, recorded as follows, for future development of reference, I believe for others also useful.
Configuration
(1) Install dependencies First:
npm install eslint --save-devnpm install babel-eslint --save-devnpm install eslint-plugin-flowtype --save-devnpm install eslint-plugin-jsx-a11y --save-dev
(2) then configure the package.json
file. ( you do not need to configure the. eslintrc.js file , see eslint Configuring documentation)
"eslintConfig": { "parser": "babel-eslint", "extends": [ "plugin:flowtype/recommended", "plugin:jsx-a11y/recommended" ], "plugins": [ "flowtype", "jsx-a11y" ]}
(3) Enter Eslint + file name below the main directory. For example eslint test.js
.
Whether the test takes effect
The test content is as follows, if there are 5 errors, then the proof is effective.
type X = bool// Message: Use "boolean", not "bool"// Options: ["boolean"]type X = bool// Message: Use "boolean", not "bool"// Options: ["bool"]type X = boolean// Message: Use "bool", not "boolean"
Feelings
Before using the eslint feeling every time to configure the .eslintrc.js
file Super trouble, now found can be directly in the package.json
configuration, really very convenient.
Create-react-app using its eslint configuration outside of the project