@prowise/eslint-config-linting-rules 1.1.2 → 1.2.1
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/backend.js +8 -3
- package/frontend.js +9 -3
- package/index.js +5 -12
- package/package.json +1 -1
- package/rules/plugin-solid-rules.js +130 -0
- package/rules/test-rules.js +439 -0
- package/solid.js +35 -0
- package/typescript.js +1 -1
- package/.editorconfig +0 -15
- package/.eslintrc.js +0 -7
- package/.nvmrc +0 -1
- /package/{src/rules → rules}/base-rules.js +0 -0
- /package/{src/rules → rules}/plugin-import-rules.js +0 -0
- /package/{src/rules → rules}/plugin-jsdoc-rules.js +0 -0
- /package/{src/rules → rules}/plugin-jsx-a11y-rules.js +0 -0
- /package/{src/rules → rules}/plugin-node-rules.js +0 -0
- /package/{src/rules → rules}/plugin-react-hooks-rules.js +0 -0
- /package/{src/rules → rules}/plugin-react-rules.js +0 -0
- /package/{src/rules → rules}/plugin-typescript-rules.js +0 -0
package/backend.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const { rules: nodeRules } = require("./
|
|
1
|
+
const { rules: nodeRules } = require("./rules/plugin-node-rules");
|
|
2
|
+
const { vitestRules } = require("./rules/test-rules");
|
|
2
3
|
|
|
3
4
|
module.exports = {
|
|
4
5
|
extends: ["./typescript.js"].map(require.resolve),
|
|
@@ -6,7 +7,11 @@ module.exports = {
|
|
|
6
7
|
env: { node: true },
|
|
7
8
|
|
|
8
9
|
// For Node, we require that you add extensions (.js) to every Javascript/Typescript file.
|
|
9
|
-
plugins: [
|
|
10
|
+
plugins: [
|
|
11
|
+
"eslint-plugin-node",
|
|
12
|
+
"require-extensions",
|
|
13
|
+
"vitest",
|
|
14
|
+
],
|
|
10
15
|
|
|
11
|
-
rules: { ...nodeRules },
|
|
16
|
+
rules: { ...nodeRules, ...vitestRules },
|
|
12
17
|
};
|
package/frontend.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const { rules: reactHooksRules } = require("./
|
|
2
|
-
const { rules: reactRules } = require("./
|
|
1
|
+
const { rules: reactHooksRules } = require("./rules/plugin-react-hooks-rules");
|
|
2
|
+
const { rules: reactRules } = require("./rules/plugin-react-rules");
|
|
3
|
+
const { jestRules } = require("./rules/test-rules");
|
|
3
4
|
|
|
4
5
|
module.exports = {
|
|
5
6
|
extends: ["./typescript.js"].map(require.resolve),
|
|
@@ -21,10 +22,15 @@ module.exports = {
|
|
|
21
22
|
ecmaFeatures: { jsx: true },
|
|
22
23
|
},
|
|
23
24
|
|
|
24
|
-
plugins: [
|
|
25
|
+
plugins: [
|
|
26
|
+
"eslint-plugin-react",
|
|
27
|
+
"eslint-plugin-react-hooks",
|
|
28
|
+
"eslint-plugin-jest",
|
|
29
|
+
],
|
|
25
30
|
|
|
26
31
|
rules: {
|
|
27
32
|
...reactRules,
|
|
28
33
|
...reactHooksRules,
|
|
34
|
+
...jestRules,
|
|
29
35
|
},
|
|
30
36
|
};
|
package/index.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
const { rules: baseRules } = require("./
|
|
2
|
-
const { rules: importsRules } = require("./
|
|
3
|
-
const { rules: jsDocRules } = require("./
|
|
1
|
+
const { rules: baseRules } = require("./rules/base-rules");
|
|
2
|
+
const { rules: importsRules } = require("./rules/plugin-import-rules");
|
|
3
|
+
const { rules: jsDocRules } = require("./rules/plugin-jsdoc-rules");
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
env: {
|
|
7
|
-
|
|
8
|
-
es2021: true,
|
|
7
|
+
es2024: true,
|
|
9
8
|
},
|
|
10
9
|
|
|
11
10
|
plugins: [
|
|
12
11
|
"eslint-plugin-import",
|
|
13
12
|
"eslint-plugin-prefer-arrow",
|
|
14
|
-
"eslint-plugin-jest",
|
|
15
13
|
"eslint-plugin-jsdoc",
|
|
16
14
|
],
|
|
17
15
|
|
|
18
16
|
parserOptions: {
|
|
19
|
-
ecmaVersion:
|
|
17
|
+
ecmaVersion: "latest",
|
|
20
18
|
sourceType: "module",
|
|
21
19
|
},
|
|
22
20
|
|
|
@@ -33,10 +31,5 @@ module.exports = {
|
|
|
33
31
|
allowStandaloneDeclarations: true,
|
|
34
32
|
},
|
|
35
33
|
],
|
|
36
|
-
"jest/no-disabled-tests": "warn",
|
|
37
|
-
"jest/no-focused-tests": "error",
|
|
38
|
-
"jest/no-identical-title": "error",
|
|
39
|
-
"jest/prefer-to-have-length": "warn",
|
|
40
|
-
"jest/valid-expect": "error",
|
|
41
34
|
},
|
|
42
35
|
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@prowise/eslint-config-linting-rules","version":"1.1
|
|
1
|
+
{"name":"@prowise/eslint-config-linting-rules","version":"1.2.1","description":"Default Prowise linting rules for npm packages.","main":"index.js","exports":{"./default":"./index.js","./typescript":"./typescript.js","./backend":"./backend.js","./frontend":"./frontend.js","./solid":"./solid.js"},"scripts":{"lint":"eslint **/*.js"},"repository":{"type":"git","url":"git+ssh://git@bitbucket.org/prowise/npm-linting-rules.git"},"author":"Prowise B.V.","license":"UNLICENSED","homepage":"https://bitbucket.org/prowise/npm-linting-rules#readme","dependencies":{"@typescript-eslint/eslint-plugin":"^6.19.0","@typescript-eslint/parser":"^6.19.0","confusing-browser-globals":"^1.0.11","eslint":"^8.56.0","eslint-import-resolver-typescript":"^3.6.1","eslint-plugin-import":"^2.29.1","eslint-plugin-jest":"^27.6.3","eslint-plugin-jsdoc":"^48.0.2","eslint-plugin-node":"^11.1.0","eslint-plugin-prefer-arrow":"^1.2.3","eslint-plugin-react":"^7.33.2","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-require-extensions":"^0.1.3","eslint-plugin-solid":"^0.13.1","eslint-plugin-vitest":"^0.3.20","object.assign":"^4.1.5"},"overrides":{"semver":"^7.5.3"}}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/*
|
|
3
|
+
* ✅ recommended
|
|
4
|
+
* 🔧 fixable
|
|
5
|
+
* 💡 has suggestion
|
|
6
|
+
*/
|
|
7
|
+
parser: { ecmaFeatures: { jsx: true } },
|
|
8
|
+
rules: {
|
|
9
|
+
/**
|
|
10
|
+
* Disallow early returns in components. ✅ 🔧
|
|
11
|
+
* Solid components only run once, and so conditionals should be inside JSX.
|
|
12
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/components-return-once.md
|
|
13
|
+
*/
|
|
14
|
+
"solid/components-return-once": "warn",
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Enforce naming DOM element event handlers consistently and prevent ✅ 🔧
|
|
18
|
+
* Solid's analysis from misunderstanding whether a prop should be an event handler.
|
|
19
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/event-handlers.md
|
|
20
|
+
*/
|
|
21
|
+
"solid/event-handlers": "warn",
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Enforce consistent imports from "solid-js", "solid-js/web", and "solid-js/store". ✅ 🔧
|
|
25
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/imports.md
|
|
26
|
+
*/
|
|
27
|
+
"solid/imports": "warn",
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Disallow passing the same prop twice in JSX. ✅
|
|
31
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/jsx-no-duplicate-props.md
|
|
32
|
+
*/
|
|
33
|
+
"solid/jsx-no-duplicate-props": "error",
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Disallow javascript: URLs. ✅
|
|
37
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/jsx-no-script-url.md
|
|
38
|
+
*/
|
|
39
|
+
"solid/jsx-no-script-url": "error",
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Disallow references to undefined variables in JSX. Handles custom directives. ✅ 🔧
|
|
43
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/jsx-no-undef.md
|
|
44
|
+
*/
|
|
45
|
+
"solid/jsx-no-undef": "error",
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Prevent variables used in JSX from being marked as unused. ✅
|
|
49
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/jsx-uses-vars.md
|
|
50
|
+
*/
|
|
51
|
+
"solid/jsx-uses-vars": "error",
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Disallow usage of type-unsafe event handlers.
|
|
55
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/no-array-handlers.md
|
|
56
|
+
*/
|
|
57
|
+
"solid/no-array-handlers": "off",
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Disallow destructuring props. ✅ 🔧
|
|
61
|
+
* In Solid, props must be used with property accesses (props.foo) to preserve reactivity.
|
|
62
|
+
* This rule only tracks destructuring in the parameter list.
|
|
63
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/no-destructure.md
|
|
64
|
+
*/
|
|
65
|
+
"solid/no-destructure": "error",
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Disallow usage of the innerHTML attribute, which can often lead to security vulnerabilities. ✅ 🔧
|
|
69
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/no-innerhtml.md
|
|
70
|
+
*/
|
|
71
|
+
"solid/no-innerhtml": "error",
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Disallow usage of APIs that use ES6 Proxies, only to target environments that don't support them.
|
|
75
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/no-proxy-apis.md
|
|
76
|
+
*/
|
|
77
|
+
"solid/no-proxy-apis": "off",
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Disallow usage of dependency arrays in createEffect and createMemo. ✅ 🔧
|
|
81
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/no-react-deps.md
|
|
82
|
+
*/
|
|
83
|
+
"solid/no-react-deps": "warn",
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Disallow usage of React-specific className/htmlFor props, which were deprecated in v1.4.0. ✅ 🔧
|
|
87
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/no-react-specific-props.md
|
|
88
|
+
*/
|
|
89
|
+
"solid/no-react-specific-props": "warn",
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Enforce using only Solid-specific namespaced attribute names (i.e. 'on:' in <div on:click={...} />). ✅
|
|
93
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/no-unknown-namespaces.md
|
|
94
|
+
*/
|
|
95
|
+
"solid/no-unknown-namespaces": "error",
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Enforce using Solid's <For /> component for mapping an array to JSX elements. ✅ 🔧
|
|
99
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/prefer-for.md
|
|
100
|
+
*/
|
|
101
|
+
"solid/prefer-for": "error",
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Enforce using Solid's <Show /> component for conditionally showing content. 🔧
|
|
105
|
+
* Solid's compiler covers this case, so it's a stylistic rule only.
|
|
106
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/prefer-show.md
|
|
107
|
+
*/
|
|
108
|
+
"solid/prefer-show": "off",
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Enforce that reactivity (props, signals, memos, etc.) is properly used, ✅
|
|
112
|
+
* so changes in those values will be tracked and update the view as expected.
|
|
113
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/reactivity.md
|
|
114
|
+
*/
|
|
115
|
+
"solid/reactivity": "warn",
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Disallow extra closing tags for components without children. ✅ 🔧
|
|
119
|
+
* https://github.com/solidjs-community/eslint-plugin-solid/blob/main/docs/self-closing-comp.md
|
|
120
|
+
*/
|
|
121
|
+
"solid/self-closing-comp": "warn",
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Require CSS properties in the style prop to be valid and kebab-cased (ex. 'font-size'), ✅ 🔧
|
|
125
|
+
* not camel-cased (ex. 'fontSize') like in React, and that property values with dimensions
|
|
126
|
+
* are strings, not numbers with implicit 'px' units.
|
|
127
|
+
*/
|
|
128
|
+
"solid/style-prop": "warn",
|
|
129
|
+
},
|
|
130
|
+
};
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ✅ recommended
|
|
3
|
+
* 🔧 fixable
|
|
4
|
+
* 💡 has suggestion
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Rules for both test frameworks
|
|
9
|
+
*/
|
|
10
|
+
const rules = {
|
|
11
|
+
/**
|
|
12
|
+
* Enforce the usage of "it" and "test" 🔧
|
|
13
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/HEAD/docs/rules/consistent-test-it.md
|
|
14
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
|
|
15
|
+
*/
|
|
16
|
+
"consistent-test-it": ["warn", { fn: "test", withinDescribe: "it" }],
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Enforce to use an expectation in the test body. ✅
|
|
20
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/expect-expect.md
|
|
21
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
|
|
22
|
+
*/
|
|
23
|
+
"expect-expect": "error",
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Enforces a maximum number assertion calls in a test body
|
|
27
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/max-expects.md
|
|
28
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
|
|
29
|
+
* Rule turned off: gives too many false positives
|
|
30
|
+
*/
|
|
31
|
+
"max-expects": ["off", { max: 10 }],
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Enforces a maximum depth to nested describe calls
|
|
35
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/max-nested-describe.md
|
|
36
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
|
|
37
|
+
*/
|
|
38
|
+
"max-nested-describe": ["warn", { max: 5 }],
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Disallow alias methods ✅ 🔧
|
|
42
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-alias-methods.md
|
|
43
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md
|
|
44
|
+
*/
|
|
45
|
+
"no-alias-methods": "warn",
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Disallow commented out tests ✅
|
|
49
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-commented-out-tests.md
|
|
50
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md
|
|
51
|
+
*/
|
|
52
|
+
"no-commented-out-tests": "error",
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Disallow expects in a conditional block ✅
|
|
56
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-conditional-expect.md
|
|
57
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
|
|
58
|
+
*/
|
|
59
|
+
"no-conditional-expect": "error",
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Disallow conditionals in a test block
|
|
63
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-conditional-in-test.md
|
|
64
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
|
|
65
|
+
*/
|
|
66
|
+
"no-conditional-in-test": "off",
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Disallow disabled tests ✅
|
|
70
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-disabled-tests.md
|
|
71
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
|
|
72
|
+
*/
|
|
73
|
+
"no-disabled-tests": "warn",
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Disallow using a callback in asynchronous tests and hooks ✅
|
|
77
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-done-callback.md
|
|
78
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md
|
|
79
|
+
*/
|
|
80
|
+
"no-done-callback": "warn",
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Disallow duplicate setup and teardown hooks
|
|
84
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-duplicate-hooks.md
|
|
85
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md
|
|
86
|
+
*/
|
|
87
|
+
"no-duplicate-hooks": "error",
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Disallow focused tests
|
|
91
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-focused-tests.md
|
|
92
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
|
|
93
|
+
*/
|
|
94
|
+
"no-focused-tests": "error",
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Disallow setup and teardown hooks
|
|
98
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-hooks.md
|
|
99
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
|
|
100
|
+
*/
|
|
101
|
+
"no-hooks": "off",
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Disallow identical titles ✅
|
|
105
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-identical-title.md
|
|
106
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
|
|
107
|
+
*/
|
|
108
|
+
"no-identical-title": "error",
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Disallow string interpolation inside snapshots ✅
|
|
112
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-interpolation-in-snapshots.md
|
|
113
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
|
|
114
|
+
*/
|
|
115
|
+
"no-interpolation-in-snapshots": "warn",
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Disallow large snapshots
|
|
119
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-large-snapshots.md
|
|
120
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md
|
|
121
|
+
*/
|
|
122
|
+
"no-large-snapshots": ["error", { maxSize: 30, inlineMaxSize: 10 }],
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Disallow manually importing from __mocks__ ✅
|
|
126
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-mocks-import.md
|
|
127
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
|
|
128
|
+
*/
|
|
129
|
+
"no-mocks-import": "error",
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Disallow specific matchers & modifiers
|
|
133
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-restricted-matchers.md
|
|
134
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
|
|
135
|
+
*/
|
|
136
|
+
"no-restricted-matchers": "off",
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Disallow using expect outside of it or test blocks ✅
|
|
140
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-standalone-expect.md
|
|
141
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
|
|
142
|
+
*/
|
|
143
|
+
"no-standalone-expect": "error",
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Disallow using any prefixed to skip tests ✅ 🔧
|
|
147
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-test-prefixes.md
|
|
148
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
|
|
149
|
+
*/
|
|
150
|
+
"no-test-prefixes": "error",
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Disallow explicitly returning from tests
|
|
154
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-test-return-statement.md
|
|
155
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
|
|
156
|
+
*/
|
|
157
|
+
"no-test-return-statement": "error",
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Suggest using toBeCalledWith() or toHaveBeenCalledWith()
|
|
161
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-called-with.md
|
|
162
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
|
|
163
|
+
*/
|
|
164
|
+
"prefer-called-with": "warn",
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Suggest using the built-in comparison matchers
|
|
168
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-comparison-matcher.md
|
|
169
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
|
|
170
|
+
*/
|
|
171
|
+
"prefer-comparison-matcher": "warn",
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Prefer using .each rather than manual loops
|
|
175
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-each.md
|
|
176
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
|
|
177
|
+
*/
|
|
178
|
+
"prefer-each": "off",
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Suggest using the built-in equality matchers
|
|
182
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-equality-matcher.md
|
|
183
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
|
|
184
|
+
*/
|
|
185
|
+
"prefer-equality-matcher": "warn",
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Suggest using expect assertions instead of callbacks
|
|
189
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-expect-assertions.md
|
|
190
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-assertions.md
|
|
191
|
+
*/
|
|
192
|
+
"prefer-expect-assertions": "off",
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Suggest using expect().resolves over expect(await ...) syntax 🔧
|
|
196
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-expect-resolves.md
|
|
197
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
|
|
198
|
+
*/
|
|
199
|
+
"prefer-expect-resolves": "warn",
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Prefer having hooks in consistent order
|
|
203
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-hooks-in-order.md
|
|
204
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
|
|
205
|
+
*/
|
|
206
|
+
"prefer-hooks-in-order": "warn",
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Suggest having hooks before any test cases
|
|
210
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-hooks-on-top.md
|
|
211
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
|
|
212
|
+
*/
|
|
213
|
+
"prefer-hooks-on-top": "warn",
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Enforce lowercase test names
|
|
217
|
+
*/
|
|
218
|
+
"prefer-lowercase-title": ["warn", { ignore: ["describe", "test"] }],
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Prefer mock resolved/rejected shorthands for promises 🔧
|
|
222
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
|
|
223
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
|
|
224
|
+
*/
|
|
225
|
+
"prefer-mock-promise-shorthand": "warn",
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Prefer including a hint with external snapshots
|
|
229
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-snapshot-hint.md
|
|
230
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md
|
|
231
|
+
*/
|
|
232
|
+
"prefer-snapshot-hint": "off",
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Suggest using .spyOn()
|
|
236
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-spy-on.md
|
|
237
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
|
|
238
|
+
*/
|
|
239
|
+
"prefer-spy-on": "warn",
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Prefer strict equal over equal
|
|
243
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-strict-equal.md
|
|
244
|
+
* Vitest https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
|
|
245
|
+
*/
|
|
246
|
+
"prefer-strict-equal": "off",
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Suggest using toBe() for primitive literals 🔧
|
|
250
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-to-be.md
|
|
251
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md
|
|
252
|
+
*/
|
|
253
|
+
"prefer-to-be": "warn",
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Suggest using toContain() 🔧
|
|
257
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-to-contain.md
|
|
258
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
|
|
259
|
+
*/
|
|
260
|
+
"prefer-to-contain": "warn",
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Suggest using toHaveLength() 🔧
|
|
264
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-to-have-length.md
|
|
265
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
|
|
266
|
+
*/
|
|
267
|
+
"prefer-to-have-length": "warn",
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Suggest using test.todo 🔧
|
|
271
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-todo.md
|
|
272
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md
|
|
273
|
+
*/
|
|
274
|
+
"prefer-todo": "warn",
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Require setup and teardown code to be within a hook
|
|
278
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/require-hook.md
|
|
279
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
|
|
280
|
+
*/
|
|
281
|
+
"require-hook": "off",
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Require a message for toThrow()
|
|
285
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/require-to-throw-message.md
|
|
286
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
|
|
287
|
+
*/
|
|
288
|
+
"require-to-throw-message": "warn",
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Require test cases and hooks to be inside a describe block
|
|
292
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/require-top-level-describe.md
|
|
293
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
|
|
294
|
+
*/
|
|
295
|
+
"require-top-level-describe": "off",
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Enforce unbound methods are called with their expected scope
|
|
299
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md
|
|
300
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/unbound-method.md
|
|
301
|
+
*/
|
|
302
|
+
"unbound-method": "off",
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Enforce valid describe() ✅
|
|
306
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/valid-describe-callback.md
|
|
307
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md
|
|
308
|
+
*/
|
|
309
|
+
"valid-describe-callback": "error",
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Enforce valid expect() usage ✅
|
|
313
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/valid-expect.md
|
|
314
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
|
|
315
|
+
*/
|
|
316
|
+
"valid-expect": ["error", { alwaysAwait: true, asyncMatchers: ["toBeResolved", "toBeRejected"] }],
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Enforce valid titles ✅ 🔧
|
|
320
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/valid-title.md
|
|
321
|
+
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
|
|
322
|
+
*/
|
|
323
|
+
"valid-title": "error",
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Make the global test rules readable for the jest/vitest plugin.
|
|
328
|
+
*
|
|
329
|
+
* @param framework Used test framework
|
|
330
|
+
* @returns Testing rules.
|
|
331
|
+
*/
|
|
332
|
+
function commonRules(framework) {
|
|
333
|
+
const updated = {};
|
|
334
|
+
for (const key in rules) {
|
|
335
|
+
updated[`${framework}/${key}`] = rules[key];
|
|
336
|
+
}
|
|
337
|
+
return updated;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
module.exports = {
|
|
341
|
+
jestRules: {
|
|
342
|
+
...commonRules("jest"),
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Disallow confusing usages of jest.setTimeout
|
|
346
|
+
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-confusing-set-timeout.md
|
|
347
|
+
*/
|
|
348
|
+
"jest/no-confusing-set-timeout": "off",
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Disallow use of deprecated functions ✅ 🔧
|
|
352
|
+
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-deprecated-functions.md
|
|
353
|
+
*/
|
|
354
|
+
"jest/no-deprecated-functions": "error",
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Disallow using exports in files containing tests ✅
|
|
358
|
+
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-export.md
|
|
359
|
+
*/
|
|
360
|
+
"no-export": "error",
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Disallow Jasmine globals ✅ 🔧
|
|
364
|
+
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-jasmine-globals.md
|
|
365
|
+
*/
|
|
366
|
+
"jest/no-jasmine-globals": "error",
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Disallow specific jest. methods
|
|
370
|
+
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-restricted-jest-methods.md
|
|
371
|
+
*/
|
|
372
|
+
"jest/no-restricted-jest-methods": "off",
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Disallow using jest.mock() factories without an explicit type parameter
|
|
376
|
+
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-untyped-mock-factory.md
|
|
377
|
+
*/
|
|
378
|
+
"jest/no-untyped-mock-factory": "off",
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Require promises that have expectations in their chain to be valid ✅
|
|
382
|
+
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/valid-expect-in-promise.md
|
|
383
|
+
*/
|
|
384
|
+
"valid-expect-in-promise": "error",
|
|
385
|
+
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
vitestRules: {
|
|
389
|
+
...commonRules("vitest"),
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Forbidden test file pattern: default only "test" accepted
|
|
393
|
+
* https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
|
|
394
|
+
*/
|
|
395
|
+
"vitest/consistent-test-filename": ["off", { pattern: ".*\\.test\\.[tj]sx?$" }],
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Do not use conditionals to run tests
|
|
399
|
+
* https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md
|
|
400
|
+
*/
|
|
401
|
+
"vitest/no-conditional-tests": "off",
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Disallow importing node:test ✅ 🔧
|
|
405
|
+
* https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
|
|
406
|
+
*/
|
|
407
|
+
"vitest/no-import-node-test": "error",
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Disallow specific vi. methods
|
|
411
|
+
* https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md
|
|
412
|
+
*/
|
|
413
|
+
"vitest/no-restricted-vi-methods": "off",
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Suggest using toBeFalsy() 🔧
|
|
417
|
+
* https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md
|
|
418
|
+
*/
|
|
419
|
+
"vitest/prefer-to-be-falsy)": "off",
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Prefer toBeObject() 🔧
|
|
423
|
+
* https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md
|
|
424
|
+
*/
|
|
425
|
+
"vitest/prefer-to-be-object": "off",
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Suggest using toBeTruthy 🔧
|
|
429
|
+
* https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md
|
|
430
|
+
*/
|
|
431
|
+
"vitest/prefer-to-be-truthy": "off",
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Require local Test Context for concurrent snapshot tests ✅
|
|
435
|
+
* https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-local-test-context-for-concurrent-snapshots.md
|
|
436
|
+
*/
|
|
437
|
+
"vitest/require-local-test-context-for-concurrent-snapshots": "error",
|
|
438
|
+
},
|
|
439
|
+
};
|
package/solid.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const { rules: solidRules } = require("./rules/plugin-solid-rules");
|
|
2
|
+
const { vitestRules } = require("./rules/test-rules");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
extends: ["./typescript.js"].map(require.resolve),
|
|
6
|
+
|
|
7
|
+
env: { browser: true },
|
|
8
|
+
globals: {
|
|
9
|
+
suite: true,
|
|
10
|
+
test: true,
|
|
11
|
+
describe: true,
|
|
12
|
+
it: true,
|
|
13
|
+
expectTypeOf: true,
|
|
14
|
+
assertType: true,
|
|
15
|
+
expect: true,
|
|
16
|
+
assert: true,
|
|
17
|
+
vitest: true,
|
|
18
|
+
vi: true,
|
|
19
|
+
beforeAll: true,
|
|
20
|
+
afterAll: true,
|
|
21
|
+
beforeEach: true,
|
|
22
|
+
afterEach: true,
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
plugins: [
|
|
26
|
+
"eslint-plugin-solid",
|
|
27
|
+
"vitest",
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
parserOptions: {
|
|
31
|
+
ecmaFeatures: { jsx: true },
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
rules: { ...solidRules, ...vitestRules },
|
|
35
|
+
};
|
package/typescript.js
CHANGED
package/.editorconfig
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
; This file is for unifying the coding style for different editors and IDEs.
|
|
2
|
-
; More information at http://editorconfig.org
|
|
3
|
-
|
|
4
|
-
root = true
|
|
5
|
-
|
|
6
|
-
[*]
|
|
7
|
-
charset = utf-8
|
|
8
|
-
indent_style = space
|
|
9
|
-
indent_size = 4
|
|
10
|
-
end_of_line = lf
|
|
11
|
-
insert_final_newline = true
|
|
12
|
-
trim_trailing_whitespace = true
|
|
13
|
-
|
|
14
|
-
[*.md]
|
|
15
|
-
trim_trailing_whitespace = false
|
package/.eslintrc.js
DELETED
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
18
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|