{ "env": { "browser": true, "node": true, "es6": true, "jquery": true, "commonjs": true, "phantomjs": true, "mocha": true }, "parser": "babel-eslint", "parserOptions": { "ecmaFeatures": { "jsx": true } }, "rules": { // 不可省略分号 "semi": [2, "always"], // 控制逗号在行尾出现还是在行首出现 (逗号放在行尾) "comma-style": [1, "last"], // 单引号 '优于双引号" "quotes": [2, "single"], // 对象属性声明的冒号:后,加空格 "key-spacing": [2], // 控制逗号前后的空格 "comma-spacing": [2, { "before": false, "after": true }], // 条件语句if、else、switch...后,加空格 "keyword-spacing": [2, { "before": true, "after": true }], // 开始大括号前,加空格 "space-before-blocks": [2, "always"], // 文件末尾强制换行; 为了兼容解析js文件的地方 "eol-last": 2, // 规则配置 "no-extra-semi": 1, "no-constant-condition": 2, "no-extra-boolean-cast": 2, "use-isnan": 2, "no-undef-init": 2, "camelcase": 2, "no-mixed-spaces-and-tabs": 2, "no-const-assign": 2, "no-func-assign": 2, "no-else-return": 1, "no-obj-calls": 2, "valid-typeof": 2, "no-unused-vars": 1, "object-curly-spacing": 1, "block-spacing": 1, "comma-dangle": 0, "array-bracket-spacing": 1, "space-before-function-paren": ["error", { "named": "never", "asyncArrow": "always", "anonymous": "always" }], "no-extra-bind": 1, "no-var": "error", "arrow-spacing": ["error", { "before": true, "after": true }], "arrow-body-style": ["error", "as-needed"], "no-empty-function": ["error", { "allow": ["arrowFunctions", "constructors"] }] }, "settings": { // 如果通过webpack配置忽略了js文件后缀,在正常情况下eslint会因为找不到文件而报错。因此需要在settings里配置可省略的后缀名 "import/resolver": { "node": { "extensions": [".coffee", ".js", ".jsx"] } }, // 哪些import是不去检查的 // node_modules为默认值 // 还可以配置带有指定文件后缀不检查,如\.coffee$ "import/ignore": ["node_modules"] } }