@cgzair/eslint-config-cgz 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 cgzjs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # eslint-config-cgz
2
+
3
+ ## 简介
4
+
5
+ 本包提供了《信息技术部前端编码手册》配套的 ESLint 可共享配置,提供了多套配置文件以支持 JavaScript、TypeScript、React、Vue、Node.js 等多种项目类型。
6
+
7
+ ### 使用
8
+
9
+ ```json
10
+ {
11
+ "extends": "@cgzair/eslint-config-cgz"
12
+ }
13
+ ```
package/es5.js ADDED
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ extends: [
3
+ "./rules/base/recommended",
4
+ "./rules/base/possible-errors",
5
+ "./rules/base/style",
6
+ "./rules/base/variables",
7
+ ].map(require.resolve),
8
+ root: true,
9
+ };
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ module.exports = {
2
+ extends: [
3
+ "./rules/base/recommended",
4
+ "./rules/base/possible-errors",
5
+ "./rules/base/style",
6
+ "./rules/base/variables",
7
+ "./rules/base/es6",
8
+ "./rules/base/strict",
9
+ "./rules/imports",
10
+ ].map(require.resolve),
11
+ parser: "@babel/eslint-parser",
12
+ parserOptions: {
13
+ requireConfigFile: false,
14
+ ecmaVersion: 2020,
15
+ sourceType: "module",
16
+ ecmaFeatures: {
17
+ globalReturn: false,
18
+ impliedStrict: true,
19
+ jsx: true,
20
+ },
21
+ },
22
+ root: true,
23
+ };
package/jsx-a11y.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ["./rules/jsx-a11y"].map(require.resolve),
3
+ };
package/node.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ["./index", "./rules/node"].map(require.resolve),
3
+ };
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@cgzair/eslint-config-cgz",
3
+ "version": "1.1.0",
4
+ "description": "ESLint shareable config for cgz frontend Guidelines",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "eslint-config-cgz"
8
+ ],
9
+ "author": "cgz",
10
+ "scripts": {
11
+ "test": "jest",
12
+ "test:coverage": "jest --coverage"
13
+ },
14
+ "files": [
15
+ "rules",
16
+ "typescript",
17
+ "es5.js",
18
+ "index.js",
19
+ "jsx-a11y.js",
20
+ "node.js",
21
+ "package.json",
22
+ "react.js",
23
+ "uni-app.js",
24
+ "vue.js",
25
+ "README.md"
26
+ ],
27
+ "dependencies": {
28
+ "eslint": "^8.7.0"
29
+ },
30
+ "devDependencies": {
31
+ "@babel/core": "^7.16.7",
32
+ "@babel/eslint-parser": "^7.16.5",
33
+ "@babel/preset-react": "^7.16.7",
34
+ "@typescript-eslint/eslint-plugin": "^5.13.0",
35
+ "@typescript-eslint/parser": "^5.13.0",
36
+ "eslint-config-egg": "^11.0.1",
37
+ "eslint-plugin-import": "^2.25.4",
38
+ "eslint-plugin-jsx-a11y": "^6.5.1",
39
+ "eslint-plugin-react": "^7.28.0",
40
+ "eslint-plugin-react-hooks": "^4.3.0",
41
+ "eslint-plugin-vue": "^8.5.0",
42
+ "jest": "^27.3.1",
43
+ "mocha": "^8.2.1",
44
+ "prettier": "^2.5.1",
45
+ "typescript": "^4.1.2",
46
+ "vue-eslint-parser": "^8.3.0"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "engines": {
52
+ "node": ">=12.0.0"
53
+ },
54
+ "license": "MIT",
55
+ "jest": {
56
+ "testMatch": [
57
+ "**/__tests__/**/*.test.js"
58
+ ],
59
+ "coveragePathIgnorePatterns": [
60
+ "node_modules",
61
+ "coverage",
62
+ "__tests__"
63
+ ],
64
+ "collectCoverageFrom": [
65
+ "**/*.{j,t}s?(x)"
66
+ ],
67
+ "resolver": "<rootDir>/../../tests/jest-resolver.js",
68
+ "coverageReporters": [
69
+ "lcov",
70
+ "cobertura"
71
+ ]
72
+ },
73
+ "gitHead": "ac4f859f68745c4250c8aab06047ce03b0de733e"
74
+ }
package/react.js ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ extends: ["./index", "./rules/react"].map(require.resolve),
3
+ parserOptions: {
4
+ babelOptions: {
5
+ presets: ["@babel/preset-react"],
6
+ },
7
+ },
8
+ };
@@ -0,0 +1,76 @@
1
+ module.exports = {
2
+ rules: {
3
+ "arrow-body-style": "off",
4
+ "arrow-parens": ["warn", "always"],
5
+ "arrow-spacing": ["error", { before: true, after: true }],
6
+ "constructor-super": "error",
7
+ "generator-star-spacing": ["error", { before: false, after: true }],
8
+ "no-class-assign": "error",
9
+ "no-confusing-arrow": "error",
10
+ "no-const-assign": "error",
11
+ "no-dupe-class-members": "error",
12
+ "no-duplicate-imports": "off",
13
+ "no-new-symbol": "error",
14
+ "no-restricted-imports": "off",
15
+ "no-this-before-super": "error",
16
+ "no-useless-computed-key": "error",
17
+ "no-useless-constructor": "error",
18
+ "no-useless-rename": [
19
+ "error",
20
+ {
21
+ ignoreDestructuring: false,
22
+ ignoreImport: false,
23
+ ignoreExport: false,
24
+ },
25
+ ],
26
+ "no-var": "error",
27
+ "object-shorthand": [
28
+ "error",
29
+ "always",
30
+ {
31
+ ignoreConstructors: false,
32
+ avoidQuotes: true,
33
+ },
34
+ ],
35
+ "prefer-arrow-callback": [
36
+ "error",
37
+ {
38
+ allowNamedFunctions: false,
39
+ allowUnboundThis: true,
40
+ },
41
+ ],
42
+ "prefer-const": [
43
+ "error",
44
+ {
45
+ destructuring: "any",
46
+ ignoreReadBeforeAssign: true,
47
+ },
48
+ ],
49
+ "prefer-destructuring": [
50
+ "warn",
51
+ {
52
+ VariableDeclarator: {
53
+ array: false,
54
+ object: true,
55
+ },
56
+ AssignmentExpression: {
57
+ array: false,
58
+ object: false,
59
+ },
60
+ },
61
+ {
62
+ enforceForRenamedProperties: false,
63
+ },
64
+ ],
65
+ "prefer-numeric-literals": "off",
66
+ "prefer-rest-params": "warn",
67
+ "prefer-spread": "warn",
68
+ "prefer-template": "warn",
69
+ "require-yield": "error",
70
+ "rest-spread-spacing": ["error", "never"],
71
+ "sort-imports": "off",
72
+ "symbol-description": "warn",
73
+ "template-curly-spacing": "warn",
74
+ "yield-star-spacing": ["error", "after"],
75
+ },
76
+ };
@@ -0,0 +1,41 @@
1
+ module.exports = {
2
+ rules: {
3
+ "for-direction": "error",
4
+ "getter-return": ["error", { allowImplicit: true }],
5
+ "no-async-promise-executor": "error",
6
+ "no-await-in-loop": "warn",
7
+ "no-compare-neg-zero": "error",
8
+ "no-cond-assign": ["error", "always"],
9
+ "no-console": "warn",
10
+ "no-constant-condition": "warn",
11
+ "no-control-regex": "off",
12
+ "no-debugger": "error",
13
+ "no-dupe-args": "error",
14
+ "no-dupe-keys": "error",
15
+ "no-duplicate-case": "error",
16
+ "no-empty": "error",
17
+ "no-empty-character-class": "error",
18
+ "no-ex-assign": "error",
19
+ "no-extra-boolean-cast": "error",
20
+ "no-extra-parens": "off",
21
+ "no-extra-semi": "error",
22
+ "no-func-assign": "error",
23
+ "no-inner-declarations": "error",
24
+ "no-invalid-regexp": "error",
25
+ "no-irregular-whitespace": "error",
26
+ "no-misleading-character-class": "error",
27
+ "no-obj-calls": "error",
28
+ "no-prototype-builtins": "error",
29
+ "no-regex-spaces": "error",
30
+ "no-sparse-arrays": "error",
31
+ "no-template-curly-in-string": "warn",
32
+ "no-unexpected-multiline": "error",
33
+ "no-unreachable": "error",
34
+ "no-unsafe-finally": "error",
35
+ "no-unsafe-negation": "error",
36
+ "require-atomic-updates": "warn",
37
+ "use-isnan": "error",
38
+ "valid-jsdoc": ["warn", { requireReturn: false, requireParamDescription: false, requireReturnDescription: false }],
39
+ "valid-typeof": ["error", { requireStringLiterals: true }],
40
+ },
41
+ };
@@ -0,0 +1,112 @@
1
+ module.exports = {
2
+ rules: {
3
+ "accessor-pairs": "off",
4
+ "array-callback-return": ["error", { allowImplicit: true }],
5
+ "block-scoped-var": "error",
6
+ "class-methods-use-this": "off",
7
+ complexity: "off",
8
+ "consistent-return": "off",
9
+ curly: ["error", "multi-line"],
10
+ "default-case": ["warn", { commentPattern: "^no default$" }],
11
+ "dot-location": ["error", "property"],
12
+ "dot-notation": ["error", { allowKeywords: true }],
13
+ eqeqeq: ["warn", "always", { null: "ignore" }],
14
+ "guard-for-in": "warn",
15
+ "max-classes-per-file": "off",
16
+ "no-alert": "warn",
17
+ "no-caller": "error",
18
+ "no-case-declarations": "error",
19
+ "no-div-regex": "off",
20
+ "no-else-return": "off",
21
+ "no-empty-function": [
22
+ "error",
23
+ {
24
+ allow: ["arrowFunctions", "functions", "methods"],
25
+ },
26
+ ],
27
+ "no-empty-pattern": "error",
28
+ "no-eq-null": "off",
29
+ "no-eval": "error",
30
+ "no-extend-native": "error",
31
+ "no-extra-bind": "error",
32
+ "no-extra-label": "error",
33
+ "no-fallthrough": "error",
34
+ "no-floating-decimal": "error",
35
+ "no-global-assign": ["error", { exceptions: [] }],
36
+ "no-implicit-coercion": "off",
37
+ "no-implicit-globals": "off",
38
+ "no-implied-eval": "error",
39
+ "no-invalid-this": "off",
40
+ "no-iterator": "error",
41
+ "no-labels": ["warn", { allowLoop: false, allowSwitch: false }],
42
+ "no-lone-blocks": "error",
43
+ "no-loop-func": "error",
44
+ "no-magic-numbers": "off",
45
+ "no-multi-spaces": [
46
+ "error",
47
+ {
48
+ ignoreEOLComments: false,
49
+ },
50
+ ],
51
+ "no-multi-str": "error",
52
+ "no-new": "error",
53
+ "no-new-func": "error",
54
+ "no-new-wrappers": "error",
55
+ "no-octal": "error",
56
+ "no-octal-escape": "error",
57
+ "no-param-reassign": [
58
+ "warn",
59
+ {
60
+ props: true,
61
+ ignorePropertyModificationsFor: [
62
+ "acc",
63
+ "e",
64
+ "ctx",
65
+ "draft",
66
+ "req",
67
+ "request",
68
+ "res",
69
+ "response",
70
+ "item",
71
+ "jtem",
72
+ "ktem",
73
+ ],
74
+ },
75
+ ],
76
+ "no-proto": "error",
77
+ "no-redeclare": "error",
78
+ "no-restricted-properties": "off",
79
+ "no-return-assign": ["error", "always"],
80
+ "no-return-await": "off",
81
+ "no-script-url": "error",
82
+ "no-self-assign": "error",
83
+ "no-self-compare": "error",
84
+ "no-sequences": "error",
85
+ "no-throw-literal": "warn",
86
+ "no-unmodified-loop-condition": "off",
87
+ "no-unused-expressions": [
88
+ "error",
89
+ {
90
+ allowShortCircuit: true,
91
+ allowTernary: true,
92
+ allowTaggedTemplates: true,
93
+ },
94
+ ],
95
+ "no-unused-labels": "error",
96
+ "no-useless-call": "off",
97
+ "no-useless-catch": "error",
98
+ "no-useless-concat": "error",
99
+ "no-useless-escape": "error",
100
+ "no-useless-return": "error",
101
+ "no-void": "error",
102
+ "no-warning-comments": "off",
103
+ "no-with": "error",
104
+ "prefer-promise-reject-errors": ["warn", { allowEmptyReject: true }],
105
+ radix: "warn",
106
+ "require-await": "off",
107
+ "require-unicode-regexp": "off",
108
+ "vars-on-top": "off",
109
+ "wrap-iife": ["error", "any", { functionPrototypeMethods: false }],
110
+ yoda: "warn",
111
+ },
112
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ rules: {
3
+ strict: "off",
4
+ },
5
+ };
@@ -0,0 +1,226 @@
1
+ module.exports = {
2
+ rules: {
3
+ "array-bracket-newline": "off",
4
+ "array-bracket-spacing": ["error", "never"],
5
+ "array-element-newline": "off",
6
+ "block-spacing": ["error", "always"],
7
+ "brace-style": ["error", "1tbs", { allowSingleLine: true }],
8
+ camelcase: "off",
9
+ "capitalized-comments": "off",
10
+ "comma-dangle": ["error", "always-multiline"],
11
+ "comma-spacing": ["error", { before: false, after: true }],
12
+ "comma-style": ["error", "last"],
13
+ "computed-property-spacing": ["error", "never"],
14
+ "consistent-this": "off",
15
+ "eol-last": ["warn", "always"],
16
+ "func-call-spacing": ["error", "never"],
17
+ "func-name-matching": "off",
18
+ "func-names": "off",
19
+ "func-style": "off",
20
+ "function-paren-newline": ["error", "consistent"],
21
+ "id-blacklist": "off",
22
+ "id-length": "off",
23
+ "id-match": "off",
24
+ "implicit-arrow-linebreak": "off",
25
+ indent: [
26
+ "error",
27
+ 2,
28
+ {
29
+ SwitchCase: 1,
30
+ VariableDeclarator: 1,
31
+ outerIIFEBody: 1,
32
+ // MemberExpression: null,
33
+ FunctionDeclaration: {
34
+ parameters: 1,
35
+ body: 1,
36
+ },
37
+ FunctionExpression: {
38
+ parameters: 1,
39
+ body: 1,
40
+ },
41
+ CallExpression: {
42
+ arguments: 1,
43
+ },
44
+ ArrayExpression: 1,
45
+ ObjectExpression: 1,
46
+ ImportDeclaration: 1,
47
+ flatTernaryExpressions: false,
48
+ ignoredNodes: [
49
+ "JSXElement",
50
+ "JSXElement > *",
51
+ "JSXAttribute",
52
+ "JSXIdentifier",
53
+ "JSXNamespacedName",
54
+ "JSXMemberExpression",
55
+ "JSXSpreadAttribute",
56
+ "JSXExpressionContainer",
57
+ "JSXOpeningElement",
58
+ "JSXClosingElement",
59
+ "JSXText",
60
+ "JSXEmptyExpression",
61
+ "JSXSpreadChild",
62
+ ],
63
+ ignoreComments: false,
64
+ },
65
+ ],
66
+ "jsx-quotes": ["error", "prefer-double"],
67
+ "key-spacing": ["error", { beforeColon: false, afterColon: true }],
68
+ "keyword-spacing": [
69
+ "error",
70
+ {
71
+ before: true,
72
+ after: true,
73
+ overrides: {
74
+ return: { after: true },
75
+ throw: { after: true },
76
+ case: { after: true },
77
+ },
78
+ },
79
+ ],
80
+ "line-comment-position": "off",
81
+ "linebreak-style": "off",
82
+ "lines-between-class-members": "off",
83
+ "lines-around-comment": "off",
84
+ "max-depth": "off",
85
+ "max-len": [
86
+ "warn",
87
+ 120,
88
+ 2,
89
+ {
90
+ ignoreUrls: true,
91
+ ignoreComments: false,
92
+ ignoreRegExpLiterals: true,
93
+ ignoreStrings: true,
94
+ ignoreTemplateLiterals: true,
95
+ },
96
+ ],
97
+ "max-lines": "off",
98
+ "max-lines-per-function": "off",
99
+ "max-nested-callbacks": "off",
100
+ "max-params": "off",
101
+ "max-statements": "off",
102
+ "max-statements-per-line": "off",
103
+ "multiline-comment-style": "off",
104
+ "multiline-ternary": "off",
105
+ "new-cap": [
106
+ "error",
107
+ {
108
+ newIsCap: true,
109
+ newIsCapExceptions: [],
110
+ capIsNew: false,
111
+ capIsNewExceptions: ["Immutable.Map", "Immutable.Set", "Immutable.List"],
112
+ },
113
+ ],
114
+ "new-parens": "error",
115
+ "newline-per-chained-call": ["warn", { ignoreChainWithDepth: 4 }],
116
+ "no-array-constructor": "error",
117
+ "no-bitwise": "warn",
118
+ "no-continue": "off",
119
+ "no-inline-comments": "off",
120
+ "no-lonely-if": "error",
121
+ "no-mixed-operators": [
122
+ "error",
123
+ {
124
+ groups: [
125
+ ["%", "**"],
126
+ ["%", "+"],
127
+ ["%", "-"],
128
+ ["%", "*"],
129
+ ["%", "/"],
130
+ ["**", "+"],
131
+ ["**", "-"],
132
+ ["**", "*"],
133
+ ["**", "/"],
134
+ ["&", "|", "^", "~", "<<", ">>", ">>>"],
135
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
136
+ ["&&", "||"],
137
+ ["in", "instanceof"],
138
+ ],
139
+ allowSamePrecedence: false,
140
+ },
141
+ ],
142
+ "no-mixed-spaces-and-tabs": "error",
143
+ "no-multi-assign": ["error"],
144
+ "no-multiple-empty-lines": ["error", { max: 2, maxEOF: 1 }],
145
+ "no-negated-condition": "off",
146
+ "no-nested-ternary": "off",
147
+ "no-new-object": "error",
148
+ "no-plusplus": "off",
149
+ "no-restricted-syntax": "off",
150
+ "no-tabs": ["error", { allowIndentationTabs: true }],
151
+ "no-ternary": "off",
152
+ "no-trailing-spaces": [
153
+ "error",
154
+ {
155
+ skipBlankLines: false,
156
+ ignoreComments: false,
157
+ },
158
+ ],
159
+ "no-underscore-dangle": "off",
160
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
161
+ "no-whitespace-before-property": "error",
162
+ "nonblock-statement-body-position": ["error", "beside", { overrides: {} }],
163
+ "object-curly-newline": "off",
164
+ "object-curly-spacing": ["error", "always"],
165
+ "object-property-newline": [
166
+ "error",
167
+ {
168
+ allowAllPropertiesOnSameLine: true,
169
+ },
170
+ ],
171
+ "one-var": ["error", "never"],
172
+ "one-var-declaration-per-line": ["error", "always"],
173
+ "operator-assignment": ["warn", "always"],
174
+ "operator-linebreak": "off",
175
+ "padded-blocks": ["warn", { blocks: "never", classes: "never", switches: "never" }],
176
+ "padding-line-between-statements": "off",
177
+ "prefer-object-spread": "off",
178
+ "quote-props": ["error", "as-needed", { keywords: false, unnecessary: true, numbers: false }],
179
+ quotes: ["error", "double", { avoidEscape: true }],
180
+ "require-jsdoc": "warn",
181
+ semi: ["error", "always"],
182
+ "semi-spacing": ["error", { before: false, after: true }],
183
+ "semi-style": ["error", "last"],
184
+ "sort-keys": "off",
185
+ "sort-vars": "off",
186
+ "space-before-blocks": "error",
187
+ "space-before-function-paren": [
188
+ "error",
189
+ {
190
+ anonymous: "always",
191
+ named: "never",
192
+ asyncArrow: "always",
193
+ },
194
+ ],
195
+ "space-in-parens": ["error", "never"],
196
+ "space-infix-ops": "error",
197
+ "space-unary-ops": [
198
+ "error",
199
+ {
200
+ words: true,
201
+ nonwords: false,
202
+ overrides: {},
203
+ },
204
+ ],
205
+ "spaced-comment": [
206
+ "error",
207
+ "always",
208
+ {
209
+ line: {
210
+ exceptions: ["-", "+"],
211
+ markers: ["=", "!", "/"],
212
+ },
213
+ block: {
214
+ exceptions: ["-", "+"],
215
+ markers: ["=", "!"],
216
+ balanced: true,
217
+ },
218
+ },
219
+ ],
220
+ "switch-colon-spacing": ["error", { after: true, before: false }],
221
+ "template-tag-spacing": ["error", "never"],
222
+ "unicode-bom": "off",
223
+ "wrap-regex": "off",
224
+ "no-loss-of-precision": "error",
225
+ },
226
+ };
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es6: true,
5
+ jasmine: true,
6
+ jest: true,
7
+ jquery: true,
8
+ mocha: true,
9
+ node: true,
10
+ },
11
+ rules: {
12
+ "init-declarations": "off",
13
+ "no-delete-var": "off",
14
+ "no-label-var": "error",
15
+ "no-restricted-globals": "off",
16
+ "no-shadow": "error",
17
+ "no-shadow-restricted-names": "error",
18
+ "no-undef": "error",
19
+ "no-undef-init": "off",
20
+ "no-undefined": "off",
21
+ "no-unused-vars": ["error", { vars: "all", args: "after-used", ignoreRestSiblings: true }],
22
+ "no-use-before-define": ["error", { functions: false, classes: false, variables: false }],
23
+ },
24
+ };