[React]Linting React JSX with ESLint(in ES 6)

2643 ワード

ESLint is a JavaScript linter(static anlysis tool)that offrs full support for ES 6,JSX,and other moden tools via plugins.We walk through setting up ESLint in a project,using the  eslint --init CLI tool with the JSX and ES 6 options,writing a React component in JSX,and adding some extra react linting rules with a plugn.ESLint is built to be“pluggable”with simple,extensdable,modular ruting ings.Ent.ingling.ingn.ingn.ings.あなたのcan exted the core「recommanded」rules which will catch common JavaScript errors、and you can also turn on stylic rules for code consistency.You can also plugline which we do the this less wisson  eslint-plugin-react package.
 
{
    "rules": {
        "indent": [
            2,
            "tab"
        ],
        "quotes": [
            2,
            "single"
        ],
        "linebreak-style": [
            2,
            "unix"
        ],
        "semi": [
            2,
            "always"
        ],
        "react/prop-types": 1
    },
    "env": {
        "es6": true,
        "browser": true
    },
    "extends": "eslint:recommended",
    "ecmaFeatures": {
        "modules": true,  //es6
        "jsx": true,
        "experimentalObjectRestSpread": true
    },
    "plugins": [
        "react"
    ]
}
 
転載先:https://www.cnblogs.com/Answer1215/p/4773114.html