Skip to content

Commit 326ae58

Browse files
committed
eslint增加规则 并修复代码
1 parent ecebfcb commit 326ae58

File tree

143 files changed

+77412
-78019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+77412
-78019
lines changed

.eslintrc.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
//启用 ES6 语法
77
"es6": true
88
},
9+
"plugins": ["import"],
910
"root": true,
1011
"parser": "babel-eslint",
1112
"parserOptions": {
@@ -34,7 +35,7 @@ module.exports = {
3435
//禁止多次声明同一变量
3536
"no-redeclare": "warn",
3637
//允许出现未使用过的变量
37-
"no-unused-vars": "off",
38+
"no-unused-vars": "warn",
3839
//不要求在构造函数中有 super() 的调用
3940
"constructor-super": "off",
4041
//允许在嵌套的块中出现function声明
@@ -50,6 +51,36 @@ module.exports = {
5051
//禁止 case 语句落空
5152
"no-fallthrough": "warn",
5253
//禁止直接调用eval()
53-
"no-eval": ["error", {"allowIndirect": true}]
54+
"no-eval": ["error", {"allowIndirect": true}],
55+
//Ensure imports point to a file/module that can be resolved
56+
"import/no-unresolved": [2, {commonjs: true, amd: true}],
57+
//Ensure named imports correspond to a named export in the remote file
58+
"import/named": 2,
59+
//Ensure a default export is present, given a default import
60+
"import/default": 2,
61+
//Restrict which files can be imported in a given folder
62+
"import/no-restricted-paths": 2,
63+
//Forbid import of modules using absolute paths
64+
"import/no-absolute-path": 2,
65+
//Forbid require() calls with expressions
66+
"import/no-dynamic-require": 2,
67+
//Forbid named default exports
68+
"import/no-named-default": 2,
69+
//Forbid anonymous values as default exports
70+
"import/no-anonymous-default-export": 2,
71+
//Report repeated import of the same module in multiple places
72+
"import/no-duplicates": 1,
73+
//Ensure consistent use of file extension within the import path
74+
"import/extensions": 1,
75+
//Ensure all imports appear before other statements
76+
"import/first": 1,
77+
//Enforce a newline after import statements
78+
"import/newline-after-import": 1,
79+
//Prevent importing the submodules of other modules
80+
"import/no-internal-modules": 0,
81+
//Forbid unassigned imports
82+
"import/no-unassigned-import": 0
83+
84+
5485
},
5586
};

0 commit comments

Comments
 (0)