Create-react-app using its eslint configuration outside of the project

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.