@deot/dev-eslint 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +5 -0
  2. package/index.js +233 -0
  3. package/package.json +23 -0
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @deot/dev-eslint
2
+
3
+ ESLint 配置项
4
+
5
+ - 使用`dependencies`,非`peerDependencies`。主要考虑仅安装`@deot/dev-eslint`即可
package/index.js ADDED
@@ -0,0 +1,233 @@
1
+ module.exports = {
2
+ "root": true,
3
+ "parser": "@typescript-eslint/parser",
4
+ "parserOptions": {
5
+ "requireConfigFile": false,
6
+ "ecmaVersion": 2020,
7
+ "sourceType": "module",
8
+ "ecmaFeatures": {
9
+ "jsx": true,
10
+ "tsx": true
11
+ }
12
+ },
13
+ "env":
14
+ {
15
+ "browser": true,
16
+ "node": true,
17
+ "es6": true,
18
+ "mocha": true
19
+ },
20
+ // 四个级别: base/essential/strongly-recommended/recommended, 使用最高约束
21
+ "extends": [
22
+ "eslint:recommended",
23
+ "plugin:@typescript-eslint/recommended",
24
+ "plugin:jsdoc/recommended",
25
+ "plugin:markdown/recommended",
26
+ "airbnb-base"
27
+ ],
28
+ "plugins": [
29
+ "@babel",
30
+ "@typescript-eslint",
31
+ "markdown",
32
+ "jsdoc"
33
+ ],
34
+ "settings": {
35
+ "import/resolver": {
36
+ "node": {
37
+ "extensions": [
38
+ ".js"
39
+ ]
40
+ }
41
+ }
42
+ },
43
+ "globals": {
44
+ "_global": "readonly"
45
+ },
46
+
47
+ // 避免全局类型出错
48
+ "overrides": [
49
+ {
50
+ // .md有效
51
+ "files": ["**/*.md"],
52
+ "processor": "markdown/markdown"
53
+ },
54
+ {
55
+ // 在md文件中标识:```js
56
+ "files": ["**/*.md/*.js"],
57
+ "rules": {
58
+ "no-console": 0,
59
+ "import/no-unresolved": 0,
60
+ "no-undef": 0
61
+ }
62
+ },
63
+
64
+ {
65
+ "files": ["*.ts"],
66
+ "rules": {
67
+ "no-undef": 0
68
+ }
69
+ }
70
+ ],
71
+
72
+ "rules":
73
+ {
74
+ "import/no-import-module-exports": 0,
75
+
76
+ // ts
77
+ "@typescript-eslint/ban-ts-ignore": 0,
78
+ "@typescript-eslint/explicit-function-return-type": 0,
79
+ "@typescript-eslint/no-explicit-any": 0,
80
+ "@typescript-eslint/no-var-requires": 0,
81
+ "@typescript-eslint/no-empty-function": 0,
82
+ "@typescript-eslint/no-use-before-define": 0,
83
+ "@typescript-eslint/ban-ts-comment": 0,
84
+ "@typescript-eslint/ban-types": 0,
85
+ "@typescript-eslint/no-non-null-assertion": 0,
86
+ "@typescript-eslint/explicit-module-boundary-types": 0,
87
+ "@typescript-eslint/no-unused-vars": 1,
88
+ "@typescript-eslint/no-inferrable-types": 0,
89
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2483
90
+ "@typescript-eslint/no-shadow": "error",
91
+ "@typescript-eslint/member-delimiter-style": 'warn',
92
+ "no-shadow": "off",
93
+
94
+ // "@typescript-eslint/no-unused-vars": [
95
+ // "warn",
96
+ // {
97
+ // argsIgnorePattern: "^_",
98
+ // varsIgnorePattern: "^_",
99
+ // }
100
+ // ],
101
+
102
+ // airbnb
103
+ "comma-dangle": ["warn", {
104
+ "arrays": "never",
105
+ "objects": "ignore",
106
+ "imports": "never",
107
+ "exports": "never",
108
+ "functions": "ignore"
109
+ }],
110
+ "camelcase": 0,
111
+ "dot-notation": 0,
112
+ "new-parens": ["warn"],
113
+ "no-mixed-spaces-and-tabs": ["warn", "smart-tabs"],
114
+ "object-curly-newline": 0, // { a, b, c } 允许不换行
115
+ "arrow-body-style": 0, // a => 1
116
+ "arrow-parens": 0, // a => 1
117
+ "quote-props": 0, // "a-1": 2
118
+ "guard-for-in": 0, // xx.hasOwnProperty(key)
119
+ "no-restricted-syntax": 0,
120
+ "global-require": 0,
121
+ "eqeqeq": 0,
122
+ "no-plusplus": 0,
123
+ "no-unused-expressions": 0,
124
+ "no-undef": ["warn"],
125
+ "no-unused-vars": 0,
126
+ "import/no-extraneous-dependencies": 0,
127
+ "import/prefer-default-export": 0,
128
+ "import/newline-after-import": ["warn"],
129
+ "import/first": 0,
130
+ "import/no-unresolved": 0,
131
+ "import/extensions": 0,
132
+ "no-multiple-empty-lines": 0,
133
+ "no-restricted-globals": 0,
134
+ "no-param-reassign": 0,
135
+ "no-use-before-define": 0,
136
+ "consistent-return": 0,
137
+ "no-useless-return": 0,
138
+ "prefer-const": 0,
139
+ "no-else-return": 0,
140
+ "no-useless-escape": 0,
141
+ "func-names": 0,
142
+ "prefer-arrow-callback": 0,
143
+ "no-bitwise": 0,
144
+ "padded-blocks": 0, // {} 允许空行
145
+ "no-return-assign": 0,
146
+ "max-len": ["warn", { "code": 150, "ignoreComments": true }],
147
+ "prefer-destructuring": 0,
148
+ "prefer-template": 0,
149
+ "no-nested-ternary": 0,
150
+ "prefer-rest-params": 0,
151
+ "class-methods-use-this": 0,
152
+ // tab缩进
153
+ "indent": ["warn", "tab", { "SwitchCase": 1 }],
154
+ "no-tabs": 0,
155
+ "quotes": 0,
156
+ "no-console": 0,
157
+ "no-debugger": 1,
158
+ "no-var": 1,
159
+ "import/named": 0,
160
+ "semi": [
161
+ 1,
162
+ "always"
163
+ ],
164
+ "no-trailing-spaces": 0,
165
+ "eol-last": 0,
166
+ "no-underscore-dangle": 0,
167
+ "no-alert": 0,
168
+ "no-lone-blocks": 0,
169
+ // 关键字周围强制使用空格
170
+ "keyword-spacing": [
171
+ "error",
172
+ {
173
+ "before": true,
174
+ "after": true
175
+ }
176
+ ],
177
+ // 大括号中强制使用空格
178
+ "object-curly-spacing": [
179
+ "warn",
180
+ "always"
181
+ ],
182
+ // 单行代码块前后要加空格
183
+ "block-spacing": [
184
+ "warn",
185
+ "always"
186
+ ],
187
+ // 逗号后面加空格
188
+ "comma-spacing": [
189
+ "warn",
190
+ {
191
+ "before": false,
192
+ "after": true
193
+ }
194
+ ],
195
+ // 分号后面加空格
196
+ "semi-spacing": [
197
+ "warn",
198
+ {
199
+ "before": false,
200
+ "after": true
201
+ }
202
+ ],
203
+ // 在注释前有空白
204
+ "spaced-comment": [
205
+ "warn",
206
+ "always"
207
+ ],
208
+ // 箭头函数前后要有空格
209
+ "arrow-spacing": [
210
+ "warn",
211
+ {
212
+ "before": true,
213
+ "after": true
214
+ }
215
+ ],
216
+ // 对象字面量的属性中键和值之间使用一致的间距
217
+ "key-spacing": [
218
+ "warn",
219
+ {
220
+ "beforeColon": false,
221
+ "afterColon": true
222
+ }
223
+ ],
224
+ // 要求操作符周围有空格
225
+ "space-infix-ops": [
226
+ "warn",
227
+ {
228
+ "int32Hint": false
229
+ }
230
+ ],
231
+ "jsx-quotes": 1,
232
+ }
233
+ };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@deot/dev-eslint",
3
+ "version": "1.1.0",
4
+ "main": "index.js",
5
+ "files": [
6
+ "index.js"
7
+ ],
8
+ "license": "MIT",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "dependencies": {
13
+ "@babel/eslint-plugin": "^7.19.1",
14
+ "@typescript-eslint/eslint-plugin": "^5.44.0",
15
+ "@typescript-eslint/parser": "^5.44.0",
16
+ "eslint": "^8.38.0",
17
+ "eslint-config-airbnb-base": "^15.0.0",
18
+ "eslint-plugin-import": "^2.27.5",
19
+ "eslint-plugin-jsdoc": "^43.0.0",
20
+ "eslint-plugin-markdown": "^3.0.0",
21
+ "eslint-watch": "^8.0.0"
22
+ }
23
+ }