@umijs/lint 4.2.6-alpha.6 → 4.2.6-alpha.9

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.
@@ -0,0 +1 @@
1
+ import './setup';
@@ -0,0 +1,83 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+
24
+ // src/config/eslint/index.ts
25
+ var import_recommended = __toESM(require("./rules/recommended"));
26
+ var import_setup = require("./setup");
27
+ module.exports = {
28
+ parser: require.resolve("@babel/eslint-parser"),
29
+ plugins: ["react", "react-hooks"],
30
+ settings: {
31
+ react: {
32
+ version: "detect"
33
+ }
34
+ },
35
+ env: {
36
+ browser: true,
37
+ node: true,
38
+ es2022: true,
39
+ jest: true
40
+ },
41
+ rules: import_recommended.default,
42
+ overrides: [
43
+ {
44
+ parser: require.resolve("@typescript-eslint/parser"),
45
+ plugins: ["@typescript-eslint/eslint-plugin"],
46
+ files: ["**/*.{ts,tsx}"],
47
+ rules: import_recommended.typescript
48
+ },
49
+ {
50
+ settings: {
51
+ jest: {
52
+ version: detectJestVersion()
53
+ }
54
+ },
55
+ files: ["**/*.{test,spec,unit,e2e}.{ts,tsx,js,jsx}"],
56
+ plugins: ["jest"],
57
+ rules: import_recommended.jest
58
+ }
59
+ ],
60
+ parserOptions: {
61
+ ecmaFeatures: {
62
+ jsx: true
63
+ },
64
+ babelOptions: {
65
+ babelrc: false,
66
+ configFile: false,
67
+ browserslistConfigFile: false,
68
+ presets: [require.resolve("@umijs/babel-preset-umi")]
69
+ },
70
+ requireConfigFile: false,
71
+ warnOnUnsupportedTypeScriptVersion: false
72
+ }
73
+ };
74
+ function detectJestVersion() {
75
+ try {
76
+ const pkg = require.resolve("jest/package.json", {
77
+ paths: [process.cwd()]
78
+ });
79
+ return require(pkg).version;
80
+ } catch {
81
+ return 29;
82
+ }
83
+ }
@@ -0,0 +1 @@
1
+ import './setup';
@@ -0,0 +1,61 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+
24
+ // src/config/eslint/legacy.ts
25
+ var import_fabric = __toESM(require("./rules/fabric"));
26
+ var import_setup = require("./setup");
27
+ module.exports = {
28
+ extends: ["prettier", "plugin:react/recommended"],
29
+ parser: require.resolve("@babel/eslint-parser"),
30
+ plugins: ["react", "react-hooks"],
31
+ env: {
32
+ browser: true,
33
+ node: true,
34
+ es6: true,
35
+ mocha: true,
36
+ jest: true,
37
+ jasmine: true
38
+ },
39
+ rules: import_fabric.default,
40
+ overrides: [
41
+ {
42
+ files: ["**/*.{ts,tsx}"],
43
+ parser: require.resolve("@typescript-eslint/parser"),
44
+ rules: import_fabric.typescript,
45
+ extends: ["prettier", "plugin:@typescript-eslint/recommended"]
46
+ }
47
+ ],
48
+ parserOptions: {
49
+ ecmaFeatures: {
50
+ jsx: true
51
+ },
52
+ babelOptions: {
53
+ babelrc: false,
54
+ configFile: false,
55
+ browserslistConfigFile: false,
56
+ presets: [require.resolve("@umijs/babel-preset-umi")]
57
+ },
58
+ requireConfigFile: false,
59
+ warnOnUnsupportedTypeScriptVersion: false
60
+ }
61
+ };
@@ -0,0 +1,86 @@
1
+ /**
2
+ * legay enabled/disabled rules from @umijs/fabric tsEslintConfig
3
+ * @see https://github.com/umijs/fabric/blob/master/src/tsEslintConfig.ts
4
+ */
5
+ export declare const typescript: {
6
+ 'no-dupe-class-members': number;
7
+ 'no-redeclare': number;
8
+ 'no-undef': number;
9
+ 'no-unused-vars': number;
10
+ '@typescript-eslint/adjacent-overload-signatures': number;
11
+ '@typescript-eslint/array-type': number;
12
+ '@typescript-eslint/await-thenable': number;
13
+ '@typescript-eslint/ban-ts-comment': number;
14
+ '@typescript-eslint/ban-types': number;
15
+ '@typescript-eslint/consistent-indexed-object-style': number;
16
+ '@typescript-eslint/consistent-type-imports': number;
17
+ '@typescript-eslint/dot-notation': number;
18
+ '@typescript-eslint/method-signature-style': number;
19
+ '@typescript-eslint/no-array-constructor': number;
20
+ '@typescript-eslint/no-confusing-non-null-assertion': number;
21
+ '@typescript-eslint/no-dupe-class-members': number;
22
+ '@typescript-eslint/no-empty-function': number;
23
+ '@typescript-eslint/no-empty-interface': number;
24
+ '@typescript-eslint/no-explicit-any': number;
25
+ '@typescript-eslint/no-extra-non-null-assertion': number;
26
+ '@typescript-eslint/no-floating-promises': number;
27
+ '@typescript-eslint/no-implied-eval': number;
28
+ '@typescript-eslint/no-inferrable-types': number;
29
+ '@typescript-eslint/no-invalid-this': number;
30
+ '@typescript-eslint/no-loop-func': number;
31
+ '@typescript-eslint/no-loss-of-precision': number;
32
+ '@typescript-eslint/no-misused-promises': number;
33
+ '@typescript-eslint/no-namespace': number;
34
+ '@typescript-eslint/no-non-null-assertion': number;
35
+ '@typescript-eslint/no-parameter-properties': number;
36
+ '@typescript-eslint/no-redeclare': number;
37
+ '@typescript-eslint/no-shadow': number;
38
+ '@typescript-eslint/no-throw-literal': number;
39
+ '@typescript-eslint/no-unnecessary-type-assertion': number;
40
+ '@typescript-eslint/no-unnecessary-type-constraint': number;
41
+ '@typescript-eslint/no-unsafe-assignment': number;
42
+ '@typescript-eslint/no-unsafe-call': number;
43
+ '@typescript-eslint/no-unsafe-member-access': number;
44
+ '@typescript-eslint/no-unsafe-return': number;
45
+ '@typescript-eslint/no-unused-expressions': number;
46
+ '@typescript-eslint/no-unused-vars': (string | {
47
+ vars: string;
48
+ args: string;
49
+ ignoreRestSiblings: boolean;
50
+ })[];
51
+ '@typescript-eslint/no-use-before-define': (string | {
52
+ functions: boolean;
53
+ classes: boolean;
54
+ variables: boolean;
55
+ typedefs: boolean;
56
+ })[];
57
+ '@typescript-eslint/no-useless-constructor': number;
58
+ '@typescript-eslint/no-var-requires': number;
59
+ '@typescript-eslint/prefer-as-const': number;
60
+ '@typescript-eslint/prefer-namespace-keyword': number;
61
+ '@typescript-eslint/require-await': number;
62
+ '@typescript-eslint/restrict-plus-operands': number;
63
+ '@typescript-eslint/restrict-template-expressions': number;
64
+ '@typescript-eslint/switch-exhaustiveness-check': number;
65
+ '@typescript-eslint/type-annotation-spacing': number;
66
+ '@typescript-eslint/typedef': number;
67
+ '@typescript-eslint/unbound-method': number;
68
+ '@typescript-eslint/unified-signatures': number;
69
+ };
70
+ /**
71
+ * legay enabled/disabled rules from @umijs/fabric
72
+ * @see https://github.com/umijs/fabric/blob/master/src/eslint.ts#L54
73
+ */
74
+ declare const _default: {
75
+ 'no-param-reassign': number;
76
+ 'no-prototype-builtins': number;
77
+ 'react/display-name': number;
78
+ 'react/jsx-key': number;
79
+ 'react/no-array-index-key': number;
80
+ 'react/prop-types': number;
81
+ 'react/react-in-jsx-scope': number;
82
+ 'react/self-closing-comp': number;
83
+ 'react-hooks/exhaustive-deps': number;
84
+ 'react-hooks/rules-of-hooks': number;
85
+ };
86
+ export default _default;
@@ -0,0 +1,108 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/eslint/rules/fabric.ts
20
+ var fabric_exports = {};
21
+ __export(fabric_exports, {
22
+ default: () => fabric_default,
23
+ typescript: () => typescript
24
+ });
25
+ module.exports = __toCommonJS(fabric_exports);
26
+ var typescript = {
27
+ // eslint built-in rules
28
+ "no-dupe-class-members": 0,
29
+ "no-redeclare": 0,
30
+ "no-undef": 0,
31
+ "no-unused-vars": 0,
32
+ // @typescript-eslint rules
33
+ "@typescript-eslint/adjacent-overload-signatures": 0,
34
+ "@typescript-eslint/array-type": 2,
35
+ "@typescript-eslint/await-thenable": 0,
36
+ "@typescript-eslint/ban-ts-comment": 0,
37
+ "@typescript-eslint/ban-types": 1,
38
+ "@typescript-eslint/consistent-indexed-object-style": 1,
39
+ "@typescript-eslint/consistent-type-imports": 1,
40
+ "@typescript-eslint/dot-notation": 1,
41
+ "@typescript-eslint/method-signature-style": 2,
42
+ "@typescript-eslint/no-array-constructor": 0,
43
+ "@typescript-eslint/no-confusing-non-null-assertion": 2,
44
+ "@typescript-eslint/no-dupe-class-members": 2,
45
+ "@typescript-eslint/no-empty-function": 0,
46
+ "@typescript-eslint/no-empty-interface": 1,
47
+ "@typescript-eslint/no-explicit-any": 0,
48
+ "@typescript-eslint/no-extra-non-null-assertion": 0,
49
+ "@typescript-eslint/no-floating-promises": 0,
50
+ "@typescript-eslint/no-implied-eval": 0,
51
+ "@typescript-eslint/no-inferrable-types": 0,
52
+ "@typescript-eslint/no-invalid-this": 1,
53
+ "@typescript-eslint/no-loop-func": 2,
54
+ "@typescript-eslint/no-loss-of-precision": 0,
55
+ "@typescript-eslint/no-misused-promises": 0,
56
+ "@typescript-eslint/no-namespace": 1,
57
+ "@typescript-eslint/no-non-null-assertion": 0,
58
+ "@typescript-eslint/no-parameter-properties": 2,
59
+ "@typescript-eslint/no-redeclare": 2,
60
+ "@typescript-eslint/no-shadow": 2,
61
+ "@typescript-eslint/no-throw-literal": 2,
62
+ "@typescript-eslint/no-unnecessary-type-assertion": 0,
63
+ "@typescript-eslint/no-unnecessary-type-constraint": 0,
64
+ "@typescript-eslint/no-unsafe-assignment": 0,
65
+ "@typescript-eslint/no-unsafe-call": 0,
66
+ "@typescript-eslint/no-unsafe-member-access": 0,
67
+ "@typescript-eslint/no-unsafe-return": 0,
68
+ "@typescript-eslint/no-unused-expressions": 2,
69
+ "@typescript-eslint/no-unused-vars": [
70
+ "error",
71
+ { vars: "all", args: "after-used", ignoreRestSiblings: true }
72
+ ],
73
+ "@typescript-eslint/no-use-before-define": [
74
+ "error",
75
+ { functions: false, classes: true, variables: true, typedefs: true }
76
+ ],
77
+ "@typescript-eslint/no-useless-constructor": 2,
78
+ "@typescript-eslint/no-var-requires": 0,
79
+ "@typescript-eslint/prefer-as-const": 0,
80
+ "@typescript-eslint/prefer-namespace-keyword": 0,
81
+ "@typescript-eslint/require-await": 0,
82
+ "@typescript-eslint/restrict-plus-operands": 0,
83
+ "@typescript-eslint/restrict-template-expressions": 0,
84
+ "@typescript-eslint/switch-exhaustiveness-check": 2,
85
+ "@typescript-eslint/type-annotation-spacing": 2,
86
+ "@typescript-eslint/typedef": 2,
87
+ "@typescript-eslint/unbound-method": 0,
88
+ "@typescript-eslint/unified-signatures": 2
89
+ };
90
+ var fabric_default = {
91
+ // eslint built-in rules
92
+ "no-param-reassign": 2,
93
+ "no-prototype-builtins": 0,
94
+ // eslint-plugin-react rules
95
+ "react/display-name": 0,
96
+ "react/jsx-key": 1,
97
+ "react/no-array-index-key": 1,
98
+ "react/prop-types": 0,
99
+ "react/react-in-jsx-scope": 0,
100
+ "react/self-closing-comp": 1,
101
+ // eslint-pluginr-react-hooks rules
102
+ "react-hooks/exhaustive-deps": 1,
103
+ "react-hooks/rules-of-hooks": 2
104
+ };
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ typescript
108
+ });
@@ -0,0 +1,96 @@
1
+ /**
2
+ * recommended enabled/disabled rules for umi project
3
+ * @note base on recommended rule set from loaded eslint plugins
4
+ */
5
+ declare const _default: {
6
+ 'array-callback-return': number;
7
+ eqeqeq: number;
8
+ 'for-direction': number;
9
+ 'guard-for-in': number;
10
+ 'no-async-promise-executor': number;
11
+ 'no-case-declarations': number;
12
+ 'no-debugger': number;
13
+ 'no-delete-var': number;
14
+ 'no-dupe-else-if': number;
15
+ 'no-duplicate-case': number;
16
+ 'no-eval': number;
17
+ 'no-ex-assign': number;
18
+ 'no-global-assign': number;
19
+ 'no-invalid-regexp': number;
20
+ 'no-native-reassign': number;
21
+ 'no-param-reassign': number;
22
+ 'no-promise-executor-return': number;
23
+ 'no-self-assign': number;
24
+ 'no-self-compare': number;
25
+ 'no-shadow-restricted-names': number;
26
+ 'no-sparse-arrays': number;
27
+ 'no-unsafe-finally': number;
28
+ 'no-unused-labels': number;
29
+ 'no-useless-catch': number;
30
+ 'no-useless-escape': number;
31
+ 'no-var': number;
32
+ 'no-with': number;
33
+ 'require-yield': number;
34
+ 'use-isnan': number;
35
+ 'react/button-has-type': number;
36
+ 'react/jsx-key': number;
37
+ 'react/jsx-no-comment-textnodes': number;
38
+ 'react/jsx-no-duplicate-props': number;
39
+ 'react/jsx-no-target-blank': number;
40
+ 'react/jsx-no-undef': number;
41
+ 'react/jsx-uses-react': number;
42
+ 'react/jsx-uses-vars': number;
43
+ 'react/no-children-prop': number;
44
+ 'react/no-danger-with-children': number;
45
+ 'react/no-deprecated': number;
46
+ 'react/no-direct-mutation-state': number;
47
+ 'react/no-find-dom-node': number;
48
+ 'react/no-is-mounted': number;
49
+ 'react/no-string-refs': number;
50
+ 'react/no-render-return-value': number;
51
+ 'react/no-unescaped-entities': number;
52
+ 'react/no-unknown-property': number;
53
+ 'react/require-render-return': number;
54
+ 'react-hooks/rules-of-hooks': number;
55
+ };
56
+ export default _default;
57
+ /**
58
+ * config-plugin-jest rules
59
+ */
60
+ export declare const jest: {
61
+ 'jest/no-conditional-expect': number;
62
+ 'jest/no-deprecated-functions': number;
63
+ 'jest/no-export': number;
64
+ 'jest/no-focused-tests': number;
65
+ 'jest/no-identical-title': number;
66
+ 'jest/no-interpolation-in-snapshots': number;
67
+ 'jest/no-jasmine-globals': number;
68
+ 'jest/no-mocks-import': number;
69
+ 'jest/no-standalone-expect': number;
70
+ 'jest/valid-describe-callback': number;
71
+ 'jest/valid-expect-in-promise': number;
72
+ 'jest/valid-expect': number;
73
+ 'jest/valid-title': number;
74
+ };
75
+ /**
76
+ * recommended enabled/disabled rules for typescript umi project
77
+ * @note base on recommended rule set from loaded eslint plugins
78
+ */
79
+ export declare const typescript: {
80
+ '@typescript-eslint/ban-types': number;
81
+ '@typescript-eslint/no-confusing-non-null-assertion': number;
82
+ '@typescript-eslint/no-dupe-class-members': number;
83
+ '@typescript-eslint/no-empty-interface': number;
84
+ '@typescript-eslint/no-invalid-this': number;
85
+ '@typescript-eslint/no-loop-func': number;
86
+ '@typescript-eslint/no-misused-new': number;
87
+ '@typescript-eslint/no-namespace': number;
88
+ '@typescript-eslint/no-non-null-asserted-optional-chain': number;
89
+ '@typescript-eslint/no-redeclare': number;
90
+ '@typescript-eslint/no-this-alias': number;
91
+ '@typescript-eslint/no-unused-expressions': number;
92
+ '@typescript-eslint/no-unused-vars': number;
93
+ '@typescript-eslint/no-use-before-define': number;
94
+ '@typescript-eslint/no-useless-constructor': number;
95
+ '@typescript-eslint/triple-slash-reference': number;
96
+ };
@@ -0,0 +1,127 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/eslint/rules/recommended.ts
20
+ var recommended_exports = {};
21
+ __export(recommended_exports, {
22
+ default: () => recommended_default,
23
+ jest: () => jest,
24
+ typescript: () => typescript
25
+ });
26
+ module.exports = __toCommonJS(recommended_exports);
27
+ var recommended_default = {
28
+ // eslint built-in rules
29
+ // 不需要返回就用 forEach
30
+ "array-callback-return": 2,
31
+ // eqeq 可能导致潜在的类型转换问题
32
+ eqeqeq: 2,
33
+ "for-direction": 2,
34
+ // 不加 hasOwnProperty 判断会多出原型链的内容
35
+ "guard-for-in": 2,
36
+ "no-async-promise-executor": 2,
37
+ "no-case-declarations": 2,
38
+ "no-debugger": 2,
39
+ "no-delete-var": 2,
40
+ "no-dupe-else-if": 2,
41
+ "no-duplicate-case": 2,
42
+ // eval()可能导致潜在的安全问题
43
+ "no-eval": 2,
44
+ "no-ex-assign": 2,
45
+ "no-global-assign": 2,
46
+ "no-invalid-regexp": 2,
47
+ // 没必要改 native 变量
48
+ "no-native-reassign": 2,
49
+ // 修改对象时,会影响原对象;但是有些场景就是有目的
50
+ "no-param-reassign": 2,
51
+ // return 值无意义,可能会理解为 resolve
52
+ "no-promise-executor-return": 2,
53
+ "no-self-assign": 2,
54
+ "no-self-compare": 2,
55
+ "no-shadow-restricted-names": 2,
56
+ "no-sparse-arrays": 2,
57
+ "no-unsafe-finally": 2,
58
+ "no-unused-labels": 2,
59
+ "no-useless-catch": 2,
60
+ "no-useless-escape": 2,
61
+ "no-var": 2,
62
+ "no-with": 2,
63
+ "require-yield": 2,
64
+ "use-isnan": 2,
65
+ // config-plugin-react rules
66
+ // button 自带 submit 属性
67
+ "react/button-has-type": 2,
68
+ "react/jsx-key": 2,
69
+ "react/jsx-no-comment-textnodes": 2,
70
+ "react/jsx-no-duplicate-props": 2,
71
+ "react/jsx-no-target-blank": 2,
72
+ "react/jsx-no-undef": 2,
73
+ "react/jsx-uses-react": 2,
74
+ "react/jsx-uses-vars": 2,
75
+ "react/no-children-prop": 2,
76
+ "react/no-danger-with-children": 2,
77
+ "react/no-deprecated": 2,
78
+ "react/no-direct-mutation-state": 2,
79
+ "react/no-find-dom-node": 2,
80
+ "react/no-is-mounted": 2,
81
+ "react/no-string-refs": 2,
82
+ "react/no-render-return-value": 2,
83
+ "react/no-unescaped-entities": 2,
84
+ "react/no-unknown-property": 2,
85
+ "react/require-render-return": 2,
86
+ // config-plugin-react-hooks rules
87
+ "react-hooks/rules-of-hooks": 2
88
+ };
89
+ var jest = {
90
+ "jest/no-conditional-expect": 2,
91
+ "jest/no-deprecated-functions": 2,
92
+ "jest/no-export": 2,
93
+ "jest/no-focused-tests": 2,
94
+ "jest/no-identical-title": 2,
95
+ "jest/no-interpolation-in-snapshots": 2,
96
+ "jest/no-jasmine-globals": 2,
97
+ "jest/no-mocks-import": 2,
98
+ "jest/no-standalone-expect": 2,
99
+ "jest/valid-describe-callback": 2,
100
+ "jest/valid-expect-in-promise": 2,
101
+ "jest/valid-expect": 2,
102
+ "jest/valid-title": 2
103
+ };
104
+ var typescript = {
105
+ // config-plugin-typescript rules
106
+ "@typescript-eslint/ban-types": 2,
107
+ "@typescript-eslint/no-confusing-non-null-assertion": 2,
108
+ "@typescript-eslint/no-dupe-class-members": 2,
109
+ "@typescript-eslint/no-empty-interface": 2,
110
+ "@typescript-eslint/no-invalid-this": 2,
111
+ "@typescript-eslint/no-loop-func": 2,
112
+ "@typescript-eslint/no-misused-new": 2,
113
+ "@typescript-eslint/no-namespace": 2,
114
+ "@typescript-eslint/no-non-null-asserted-optional-chain": 2,
115
+ "@typescript-eslint/no-redeclare": 2,
116
+ "@typescript-eslint/no-this-alias": 2,
117
+ "@typescript-eslint/no-unused-expressions": 2,
118
+ "@typescript-eslint/no-unused-vars": 2,
119
+ "@typescript-eslint/no-use-before-define": 2,
120
+ "@typescript-eslint/no-useless-constructor": 2,
121
+ "@typescript-eslint/triple-slash-reference": 2
122
+ };
123
+ // Annotate the CommonJS export names for ESM import in node:
124
+ 0 && (module.exports = {
125
+ jest,
126
+ typescript
127
+ });
File without changes
@@ -0,0 +1,2 @@
1
+ // src/config/eslint/setup.ts
2
+ require("../../../compiled/@rushstack/eslint-patch/lib/modern-module-resolution.js");
File without changes
@@ -0,0 +1,74 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+
24
+ // src/config/stylelint/index.ts
25
+ module.exports = {
26
+ extends: [
27
+ require.resolve("stylelint-config-standard"),
28
+ require.resolve("../../../compiled/stylelint-config-prettier"),
29
+ require.resolve("../../../compiled/stylelint-config-css-modules")
30
+ ],
31
+ plugins: [
32
+ require.resolve("../../../compiled/stylelint-declaration-block-no-ignored-properties")
33
+ ],
34
+ rules: {
35
+ "no-descending-specificity": null,
36
+ "function-url-quotes": "always",
37
+ "selector-attribute-quotes": "always",
38
+ "font-family-no-missing-generic-family-keyword": null,
39
+ // iconfont
40
+ "plugin/declaration-block-no-ignored-properties": true,
41
+ "unit-no-unknown": [true, { ignoreUnits: ["rpx"] }],
42
+ // webcomponent
43
+ "selector-type-no-unknown": null,
44
+ "value-keyword-case": ["lower", { ignoreProperties: ["composes"] }],
45
+ "selector-class-pattern": [
46
+ "^([a-z][a-z0-9]*(-[a-z0-9]+)*|[a-z][a-zA-Z0-9]+)$",
47
+ {
48
+ message: "Expected class selector to be kebab-case or lowerCamelCase"
49
+ }
50
+ ],
51
+ // to avoid conflicts with less option { math: always }
52
+ // ref: https://github.com/less/less-docs/blob/c8b9d33b0b4ec5fe59a4bbda11db202545741228/content/usage/less-options.md#math
53
+ "color-function-notation": null,
54
+ // disallowed set single font-family as PingFangSC
55
+ // in most cases, this font-family rule is copied unconsciously from Sketch
56
+ // and it will cause an unexpected font rendering on the devices that have no PingFangSC font
57
+ "declaration-property-value-disallowed-list": [
58
+ {
59
+ "font-family": `/^('|")?PingFangSC(-(Regular|Medium|Semibold|Bold))?\\1$/`
60
+ },
61
+ {
62
+ message: 'Unexpected value for property "font-family", which will cause some devices to render the wrong font, please delete this "font-family" css rule, see also: https://github.com/umijs/umi/pull/11001'
63
+ }
64
+ ]
65
+ },
66
+ customSyntax: require.resolve("../../../compiled/postcss-less"),
67
+ ignoreFiles: ["node_modules"],
68
+ overrides: [
69
+ {
70
+ files: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
71
+ customSyntax: require.resolve("@stylelint/postcss-css-in-js")
72
+ }
73
+ ]
74
+ };
@@ -0,0 +1,4 @@
1
+ import type { ILintArgs, ILinterOpts } from './types';
2
+ export type { ILintArgs, ILinterOpts };
3
+ declare const _default: (opts: ILinterOpts, args: ILintArgs) => void;
4
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ default: () => src_default
23
+ });
24
+ module.exports = __toCommonJS(src_exports);
25
+ var import_linter = require("./linter");
26
+ var ES_EXTS = ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"];
27
+ var STYLE_EXTS = [
28
+ "**/*.less",
29
+ "**/*.css",
30
+ "**/*.sass",
31
+ "**/*.scss",
32
+ "**/*.styl"
33
+ ];
34
+ var src_default = (opts, args) => {
35
+ if (!args.eslintOnly) {
36
+ const stylelint = new import_linter.StyleLinter(opts);
37
+ const styleArgs = { ...args, _: [...args._] };
38
+ if (!styleArgs.cssinjs) {
39
+ for (const suffix of ES_EXTS) {
40
+ styleArgs._.unshift("--ignore-pattern", suffix);
41
+ }
42
+ }
43
+ stylelint.run(styleArgs);
44
+ }
45
+ if (!args.stylelintOnly) {
46
+ const eslint = new import_linter.EsLinter(opts);
47
+ const esArgs = { ...args, _: [...args._] };
48
+ for (const suffix of STYLE_EXTS) {
49
+ esArgs._.unshift("--ignore-pattern", suffix);
50
+ }
51
+ eslint.run(esArgs);
52
+ }
53
+ };
@@ -0,0 +1,27 @@
1
+ import type { ILintArgs, ILinterOpts } from '../types';
2
+ /**
3
+ * base linter
4
+ */
5
+ export default class BaseLinter {
6
+ /**
7
+ * linter package name
8
+ */
9
+ linter: string;
10
+ /**
11
+ * paths for linter
12
+ */
13
+ paths: Partial<ILinterOpts>;
14
+ constructor({ cwd }: ILinterOpts);
15
+ /**
16
+ * get bin file path for current linter
17
+ */
18
+ getBinPath(): string;
19
+ /**
20
+ * get linter fork args
21
+ */
22
+ getRunArgs(args: ILintArgs): string[];
23
+ /**
24
+ * execute linter
25
+ */
26
+ run(args: ILintArgs): void;
27
+ }
@@ -0,0 +1,80 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/linter/base.ts
30
+ var base_exports = {};
31
+ __export(base_exports, {
32
+ default: () => BaseLinter
33
+ });
34
+ module.exports = __toCommonJS(base_exports);
35
+ var import_child_process = require("child_process");
36
+ var import_path = __toESM(require("path"));
37
+ var BaseLinter = class {
38
+ constructor({ cwd }) {
39
+ /**
40
+ * linter package name
41
+ */
42
+ this.linter = "";
43
+ /**
44
+ * paths for linter
45
+ */
46
+ this.paths = {};
47
+ this.paths.cwd = cwd;
48
+ }
49
+ /**
50
+ * get bin file path for current linter
51
+ */
52
+ getBinPath() {
53
+ try {
54
+ const pkgPath = require.resolve(`${this.linter}/package.json`);
55
+ const pkgContent = require(pkgPath);
56
+ return import_path.default.resolve(import_path.default.dirname(pkgPath), pkgContent.bin[this.linter]);
57
+ } catch (e) {
58
+ throw new Error(`${this.linter} not found, please install it first.`, {
59
+ cause: e
60
+ });
61
+ }
62
+ }
63
+ /**
64
+ * get linter fork args
65
+ */
66
+ getRunArgs(args) {
67
+ args;
68
+ return [];
69
+ }
70
+ /**
71
+ * execute linter
72
+ */
73
+ run(args) {
74
+ (0, import_child_process.fork)(this.getBinPath(), this.getRunArgs(args)).on("exit", (code) => {
75
+ if (!!code) {
76
+ process.exitCode = code;
77
+ }
78
+ });
79
+ }
80
+ };
@@ -0,0 +1,9 @@
1
+ import type { ILintArgs } from '../types';
2
+ import BaseLinter from './base';
3
+ /**
4
+ * linter for drive eslint
5
+ */
6
+ export default class Eslinter extends BaseLinter {
7
+ linter: string;
8
+ getRunArgs(args: ILintArgs): string[];
9
+ }
@@ -0,0 +1,48 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/linter/eslint.ts
30
+ var eslint_exports = {};
31
+ __export(eslint_exports, {
32
+ default: () => Eslinter
33
+ });
34
+ module.exports = __toCommonJS(eslint_exports);
35
+ var import_base = __toESM(require("./base"));
36
+ var Eslinter = class extends import_base.default {
37
+ constructor() {
38
+ super(...arguments);
39
+ this.linter = "eslint";
40
+ }
41
+ getRunArgs(args) {
42
+ return [
43
+ ...args.quiet ? ["--quiet"] : [],
44
+ ...args.fix ? ["--fix"] : [],
45
+ ...args._
46
+ ];
47
+ }
48
+ };
@@ -0,0 +1,2 @@
1
+ export { default as EsLinter } from './eslint';
2
+ export { default as StyleLinter } from './stylelint';
@@ -0,0 +1,42 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/linter/index.ts
30
+ var linter_exports = {};
31
+ __export(linter_exports, {
32
+ EsLinter: () => import_eslint.default,
33
+ StyleLinter: () => import_stylelint.default
34
+ });
35
+ module.exports = __toCommonJS(linter_exports);
36
+ var import_eslint = __toESM(require("./eslint"));
37
+ var import_stylelint = __toESM(require("./stylelint"));
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ EsLinter,
41
+ StyleLinter
42
+ });
@@ -0,0 +1,9 @@
1
+ import type { ILintArgs } from '../types';
2
+ import BaseLinter from './base';
3
+ /**
4
+ * linter for drive stylelint
5
+ */
6
+ export default class StyleLinter extends BaseLinter {
7
+ linter: string;
8
+ getRunArgs(args: ILintArgs): string[];
9
+ }
@@ -0,0 +1,51 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/linter/stylelint.ts
30
+ var stylelint_exports = {};
31
+ __export(stylelint_exports, {
32
+ default: () => StyleLinter
33
+ });
34
+ module.exports = __toCommonJS(stylelint_exports);
35
+ var import_base = __toESM(require("./base"));
36
+ var StyleLinter = class extends import_base.default {
37
+ constructor() {
38
+ super(...arguments);
39
+ this.linter = "stylelint";
40
+ }
41
+ getRunArgs(args) {
42
+ return [
43
+ "--config-basedir",
44
+ this.paths.cwd,
45
+ ...args.quiet ? ["--quiet"] : [],
46
+ "--allow-empty-input",
47
+ ...args.fix ? ["--fix"] : [],
48
+ ...args._
49
+ ];
50
+ }
51
+ };
@@ -0,0 +1,11 @@
1
+ export interface ILinterOpts {
2
+ cwd: string;
3
+ }
4
+ export interface ILintArgs {
5
+ _: string[];
6
+ quiet?: boolean;
7
+ fix?: boolean;
8
+ eslintOnly?: boolean;
9
+ stylelintOnly?: boolean;
10
+ cssinjs?: boolean;
11
+ }
package/dist/types.js ADDED
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/types.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/lint",
3
- "version": "4.2.6-alpha.6",
3
+ "version": "4.2.6-alpha.9",
4
4
  "description": "@umijs/lint",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/lint#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -27,7 +27,7 @@
27
27
  "postcss": "^8.4.21",
28
28
  "postcss-syntax": "0.36.2",
29
29
  "stylelint-config-standard": "25.0.0",
30
- "@umijs/babel-preset-umi": "4.2.6-alpha.6"
30
+ "@umijs/babel-preset-umi": "4.2.6-alpha.9"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@rushstack/eslint-patch": "1.1.2",