@dvukovic/style-guide 0.13.0 → 0.14.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/dist/src/eslint/plugins/validate-rules.d.ts +1 -0
- package/dist/src/eslint/plugins/validate-rules.test.d.ts +1 -0
- package/package.json +2 -1
- package/src/eslint/plugins/playwright.js +1 -1
- package/src/eslint/plugins/validate-rules.js +33 -0
- package/src/eslint/plugins/validate-rules.test.js +68 -0
- package/src/eslint/plugins/vitest.js +1 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function validatePluginRules(pluginConfig: any): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvukovic/style-guide",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "My own style guide",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
"prettier": "3.8.1",
|
|
110
110
|
"release-it": "19.2.4",
|
|
111
111
|
"semver": "7.7.3",
|
|
112
|
+
"storybook": "10.2.3",
|
|
112
113
|
"stylelint": "16.26.1",
|
|
113
114
|
"typescript": "5.9.3",
|
|
114
115
|
"vitest": "4.0.18"
|
|
@@ -6,7 +6,7 @@ export const playwright = {
|
|
|
6
6
|
playwright: plugin,
|
|
7
7
|
},
|
|
8
8
|
rules: {
|
|
9
|
-
"playwright/
|
|
9
|
+
"playwright/consistent-spacing-between-blocks": "error",
|
|
10
10
|
"playwright/expect-expect": "error",
|
|
11
11
|
"playwright/max-expects": ["error", { max: 15 }],
|
|
12
12
|
"playwright/max-nested-describe": ["error", { max: 4 }],
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function validatePluginRules(pluginConfig) {
|
|
2
|
+
const { plugins, rules } = pluginConfig
|
|
3
|
+
|
|
4
|
+
if (!plugins || !rules) {
|
|
5
|
+
return
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
for (const ruleKey of Object.keys(rules)) {
|
|
9
|
+
const separatorIndex = ruleKey.startsWith("@")
|
|
10
|
+
? ruleKey.indexOf("/", ruleKey.indexOf("/") + 1)
|
|
11
|
+
: ruleKey.indexOf("/")
|
|
12
|
+
|
|
13
|
+
if (separatorIndex === -1) {
|
|
14
|
+
continue
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const pluginPrefix = ruleKey.slice(0, separatorIndex)
|
|
18
|
+
const ruleName = ruleKey.slice(separatorIndex + 1)
|
|
19
|
+
const plugin = plugins[pluginPrefix]
|
|
20
|
+
|
|
21
|
+
if (!plugin) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Rule "${ruleKey}" references plugin "${pluginPrefix}" which is not in plugins`,
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const pluginRules = plugin.rules ?? plugin.module?.rules
|
|
28
|
+
|
|
29
|
+
if (!pluginRules?.[ruleName]) {
|
|
30
|
+
throw new Error(`Rule "${ruleName}" does not exist in plugin "${pluginPrefix}"`)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { baseline } from "./baseline.js"
|
|
2
|
+
import { dvukovic } from "./dvukovic.js"
|
|
3
|
+
import { eslint } from "./eslint.js"
|
|
4
|
+
import { eslintComments } from "./eslint-comments.js"
|
|
5
|
+
import { importX } from "./import-x.js"
|
|
6
|
+
import { jest } from "./jest.js"
|
|
7
|
+
import { mobx } from "./mobx.js"
|
|
8
|
+
import { nodeN } from "./n.js"
|
|
9
|
+
import { next } from "./next.js"
|
|
10
|
+
import { packageJson } from "./package-json.js"
|
|
11
|
+
import { playwright } from "./playwright.js"
|
|
12
|
+
import { promise } from "./promise.js"
|
|
13
|
+
import { react } from "./react.js"
|
|
14
|
+
import { reactHooks } from "./react-hooks.js"
|
|
15
|
+
import { rimac } from "./rimac.js"
|
|
16
|
+
import { securityNode } from "./security-node.js"
|
|
17
|
+
import { simpleImportSort } from "./simple-import-sort.js"
|
|
18
|
+
import { sonarjs } from "./sonarjs.js"
|
|
19
|
+
import { sonarjsAws } from "./sonarjs-aws.js"
|
|
20
|
+
import { sortDestructureKeys } from "./sort-destructure-keys.js"
|
|
21
|
+
import { sortKeysFix } from "./sort-keys-fix.js"
|
|
22
|
+
import { storybook } from "./storybook.js"
|
|
23
|
+
import { stylistic } from "./stylistic.js"
|
|
24
|
+
import { typescriptEslint } from "./typescript-eslint.js"
|
|
25
|
+
import { typescriptSortKeys } from "./typescript-sort-keys.js"
|
|
26
|
+
import { unicorn } from "./unicorn.js"
|
|
27
|
+
import { unusedImports } from "./unused-imports.js"
|
|
28
|
+
import { validatePluginRules } from "./validate-rules.js"
|
|
29
|
+
import { vitest } from "./vitest.js"
|
|
30
|
+
|
|
31
|
+
const allPlugins = {
|
|
32
|
+
baseline,
|
|
33
|
+
dvukovic,
|
|
34
|
+
eslint,
|
|
35
|
+
eslintComments,
|
|
36
|
+
importX,
|
|
37
|
+
jest,
|
|
38
|
+
mobx,
|
|
39
|
+
next,
|
|
40
|
+
nodeN,
|
|
41
|
+
packageJson,
|
|
42
|
+
playwright,
|
|
43
|
+
promise,
|
|
44
|
+
react,
|
|
45
|
+
reactHooks,
|
|
46
|
+
rimac,
|
|
47
|
+
securityNode,
|
|
48
|
+
simpleImportSort,
|
|
49
|
+
sonarjs,
|
|
50
|
+
sonarjsAws,
|
|
51
|
+
sortDestructureKeys,
|
|
52
|
+
sortKeysFix,
|
|
53
|
+
storybook,
|
|
54
|
+
stylistic,
|
|
55
|
+
typescriptEslint,
|
|
56
|
+
typescriptSortKeys,
|
|
57
|
+
unicorn,
|
|
58
|
+
unusedImports,
|
|
59
|
+
vitest,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe("plugin rules", () => {
|
|
63
|
+
for (const [name, config] of Object.entries(allPlugins)) {
|
|
64
|
+
test(`${name} has no invalid rules`, () => {
|
|
65
|
+
validatePluginRules(config)
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
})
|
|
@@ -65,6 +65,7 @@ export const vitest = {
|
|
|
65
65
|
"@vitest/prefer-hooks-on-top": "error",
|
|
66
66
|
"@vitest/prefer-lowercase-title": "error",
|
|
67
67
|
"@vitest/prefer-mock-promise-shorthand": "error",
|
|
68
|
+
"@vitest/prefer-mock-return-shorthand": "error",
|
|
68
69
|
"@vitest/prefer-spy-on": "error",
|
|
69
70
|
"@vitest/prefer-strict-boolean-matchers": "error",
|
|
70
71
|
"@vitest/prefer-strict-equal": "error",
|
|
@@ -75,7 +76,6 @@ export const vitest = {
|
|
|
75
76
|
"@vitest/prefer-todo": "error",
|
|
76
77
|
"@vitest/prefer-vi-mocked": "error",
|
|
77
78
|
"@vitest/require-awaited-expect-poll": "error",
|
|
78
|
-
"@vitest/require-import-vi-mock": "error",
|
|
79
79
|
"@vitest/require-mock-type-parameters": [
|
|
80
80
|
"error",
|
|
81
81
|
{
|
|
@@ -93,7 +93,6 @@ export const vitest = {
|
|
|
93
93
|
"@vitest/valid-expect": "error",
|
|
94
94
|
"@vitest/valid-expect-in-promise": "error",
|
|
95
95
|
"@vitest/valid-title": "error",
|
|
96
|
-
"@vitest/vitest/prefer-mock-return-shorthand": "error",
|
|
97
96
|
"@vitest/warn-todo": "warn",
|
|
98
97
|
},
|
|
99
98
|
}
|