1

我刚刚将 ESLint 安装到 React Native (create-react-native-app)

.eslintrc.json

{
    "env": {
        "browser": true,
        "es6": true,
        "react-native/react-native": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:react/recommended"
    ],
    "parserOptions": {
        "ecmaVersion": 8,
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true,
            "jsx": true
        },
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "react-native"
    ],
    "rules": {
        "no-var": "error",
        "react-native/no-unused-styles": 2,
        "react-native/split-platform-components": 2,
        "react-native/no-inline-styles": 2,
        "react-native/no-color-literals": 2,
        "indent": [
            "error",
            "tab"
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "single"
        ],
        "semi": [
            "error",
            "never"
        ]
    }
}

一切正常,但不是我的组件。所以我的文件夹结构看起来像:

root: src 组件内容...

linter 在编辑器(Sublime)中工作,但不在命令行(iTerm2)中

4

1 回答 1

0

使用 eslint 可以执行 eslint ./src 来验证整个文件夹。

于 2018-06-07T09:39:31.107 回答