@dvukovic/style-guide 0.3.96 → 0.3.98
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/README.md +93 -159
- package/package.json +16 -16
- package/src/cspell/base.txt +12 -0
- package/src/eslint/configs/core.js +42 -30
- package/src/eslint/configs/core.test.js +4 -4
- package/src/eslint/configs/jest.js +26 -3
- package/src/eslint/configs/jest.test.js +3 -3
- package/src/eslint/configs/mobx.js +15 -3
- package/src/eslint/configs/mobx.test.js +3 -3
- package/src/eslint/configs/next.js +15 -3
- package/src/eslint/configs/next.test.js +3 -3
- package/src/eslint/configs/node.js +16 -4
- package/src/eslint/configs/node.test.js +3 -3
- package/src/eslint/configs/playwright.js +26 -3
- package/src/eslint/configs/playwright.test.js +3 -3
- package/src/eslint/configs/react.js +16 -4
- package/src/eslint/configs/react.test.js +3 -3
- package/src/eslint/configs/storybook.js +15 -3
- package/src/eslint/configs/storybook.test.js +3 -3
- package/src/eslint/configs/typescript-strict.js +14 -2
- package/src/eslint/configs/typescript-strict.test.js +6 -4
- package/src/eslint/configs/typescript.js +37 -4
- package/src/eslint/configs/typescript.test.js +6 -4
- package/src/eslint/configs/vitest.js +26 -3
- package/src/eslint/configs/vitest.test.js +3 -3
- package/src/eslint/index.js +25 -0
- package/src/eslint/plugins/dvukovic.js +15 -0
- package/src/eslint/plugins/es-x.js +7 -6
- package/src/eslint/plugins/eslint-comments.js +4 -6
- package/src/eslint/plugins/eslint.js +9 -3
- package/src/eslint/plugins/eslint.test.js +42 -0
- package/src/eslint/plugins/import-x.js +10 -6
- package/src/eslint/plugins/jest.js +4 -5
- package/src/eslint/plugins/mobx.js +4 -5
- package/src/eslint/plugins/n.js +4 -6
- package/src/eslint/plugins/next.js +4 -5
- package/src/eslint/plugins/playwright.js +4 -5
- package/src/eslint/plugins/promise.js +4 -5
- package/src/eslint/plugins/react-hooks.js +4 -5
- package/src/eslint/plugins/react.js +4 -5
- package/src/eslint/plugins/rimac.js +4 -5
- package/src/eslint/plugins/security-node.js +4 -5
- package/src/eslint/plugins/simple-import-sort.js +4 -5
- package/src/eslint/plugins/sonarjs.js +261 -37
- package/src/eslint/plugins/sort-destructure-keys.js +4 -5
- package/src/eslint/plugins/sort-keys-fix.js +4 -5
- package/src/eslint/plugins/storybook.js +4 -5
- package/src/eslint/plugins/stylistic.js +4 -5
- package/src/eslint/plugins/typescript-eslint.js +4 -5
- package/src/eslint/plugins/typescript-sort-keys.js +4 -5
- package/src/eslint/plugins/unicorn.js +4 -5
- package/src/eslint/plugins/unused-imports.js +4 -5
- package/src/eslint/plugins/vitest.js +4 -5
- package/src/eslint/rules/no-commented-out-code/no-commented-out-code.js +80 -0
- package/src/eslint/rules/no-commented-out-code/no-commented-out-code.test.js +89 -0
- package/src/eslint/rules/no-commented-out-code/no-commented-out-code.utils.js +119 -0
- package/src/eslint/types.js +19 -0
- package/src/eslint/plugins/etc.js +0 -3
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import playwrightPlugin from "../plugins/playwright.js"
|
|
1
|
+
import { playwright as playwrightPlugin } from "../plugins/playwright.js"
|
|
2
2
|
|
|
3
|
-
const playwrightConfig = [playwrightPlugin]
|
|
3
|
+
export const playwrightConfig = [playwrightPlugin]
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Playwright testing configuration
|
|
7
|
+
*
|
|
8
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
9
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
10
|
+
*/
|
|
11
|
+
export function playwright(config) {
|
|
12
|
+
return {
|
|
13
|
+
extends: [...playwrightConfig, ...(config?.extends ?? [])],
|
|
14
|
+
files: [
|
|
15
|
+
"**/*.test.js",
|
|
16
|
+
"**/*.test.ts",
|
|
17
|
+
"**/*.spec.js",
|
|
18
|
+
"**/*.spec.ts",
|
|
19
|
+
"**/*.unit.test.js",
|
|
20
|
+
"**/*.unit.test.ts",
|
|
21
|
+
"**/*.int.test.js",
|
|
22
|
+
"**/*.int.test.ts",
|
|
23
|
+
"**/*.integration.test.js",
|
|
24
|
+
"**/*.integration.test.ts",
|
|
25
|
+
],
|
|
26
|
+
...config,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { playwrightConfig } from "./playwright.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: playwrightConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ describe("playwright", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.spec.ts" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
})
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import reactPlugin from "../plugins/react.js"
|
|
2
|
-
import reactHooksPlugin from "../plugins/react-hooks.js"
|
|
1
|
+
import { react as reactPlugin } from "../plugins/react.js"
|
|
2
|
+
import { reactHooks as reactHooksPlugin } from "../plugins/react-hooks.js"
|
|
3
3
|
|
|
4
|
-
const reactConfig = [reactPlugin, reactHooksPlugin]
|
|
4
|
+
export const reactConfig = [reactPlugin, reactHooksPlugin]
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* React framework configuration
|
|
8
|
+
*
|
|
9
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
10
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
11
|
+
*/
|
|
12
|
+
export function react(config) {
|
|
13
|
+
return {
|
|
14
|
+
extends: [...reactConfig, ...(config?.extends ?? [])],
|
|
15
|
+
files: ["**/*.jsx", "**/*.tsx"],
|
|
16
|
+
...config,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { reactConfig } from "./react.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: reactConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ describe("react", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.tsx" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import storybookPlugin from "../plugins/storybook.js"
|
|
1
|
+
import { storybook as storybookPlugin } from "../plugins/storybook.js"
|
|
2
2
|
|
|
3
|
-
const storybookConfig = [
|
|
3
|
+
export const storybookConfig = [
|
|
4
4
|
storybookPlugin,
|
|
5
5
|
{
|
|
6
6
|
rules: {
|
|
@@ -13,4 +13,16 @@ const storybookConfig = [
|
|
|
13
13
|
},
|
|
14
14
|
]
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Storybook ESLint configuration with relaxed rules for story files
|
|
18
|
+
*
|
|
19
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
20
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
21
|
+
*/
|
|
22
|
+
export function storybook(config) {
|
|
23
|
+
return {
|
|
24
|
+
extends: [...storybookConfig, ...(config?.extends ?? [])],
|
|
25
|
+
files: ["**/*.stories.js", "**/*.stories.ts", "**/*.stories.jsx", "**/*.stories.tsx"],
|
|
26
|
+
...config,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { storybookConfig } from "./storybook.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: storybookConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ describe("storybook", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.stories.tsx" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import typescriptEslint from "typescript-eslint"
|
|
2
2
|
|
|
3
|
-
const typescriptStrictConfig = [
|
|
3
|
+
export const typescriptStrictConfig = [
|
|
4
4
|
{
|
|
5
5
|
plugins: {
|
|
6
6
|
"@typescript-eslint": typescriptEslint.plugin,
|
|
@@ -29,4 +29,16 @@ const typescriptStrictConfig = [
|
|
|
29
29
|
},
|
|
30
30
|
]
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Strict TypeScript ESLint configuration with additional safety rules
|
|
34
|
+
*
|
|
35
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
36
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
37
|
+
*/
|
|
38
|
+
export function typescriptStrict(config) {
|
|
39
|
+
return {
|
|
40
|
+
extends: [...typescriptStrictConfig, ...(config?.extends ?? [])],
|
|
41
|
+
files: ["**/*.ts", "**/*.tsx", "**/*.cts", "**/*.mts"],
|
|
42
|
+
...config,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { typescriptStrictConfig } from "./typescript-strict.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: typescriptStrictConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
describe("typescript-strict", () => {
|
|
11
11
|
test("loads without errors", async () => {
|
|
12
|
-
const results = await eslint.lintText("const x: number = 1\n", {
|
|
12
|
+
const results = await eslint.lintText("const x: number = 1\n", {
|
|
13
|
+
filePath: "src/eslint/configs/typescript-strict.test.ts",
|
|
14
|
+
})
|
|
13
15
|
|
|
14
16
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
17
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
18
|
})
|
|
17
19
|
})
|
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import typescriptSortKeysPlugin from "../plugins/typescript-sort-keys.js"
|
|
1
|
+
import tseslint from "typescript-eslint"
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import { typescriptEslint } from "../plugins/typescript-eslint.js"
|
|
4
|
+
import { typescriptSortKeys } from "../plugins/typescript-sort-keys.js"
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export const typescriptConfig = [
|
|
7
|
+
{
|
|
8
|
+
files: ["**/*.js", "**/*.ts", "**/*.tsx", "**/*.cjs"],
|
|
9
|
+
languageOptions: {
|
|
10
|
+
parser: tseslint.parser,
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 2024,
|
|
13
|
+
project: "./tsconfig.json",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
19
|
+
...typescriptEslint,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
23
|
+
...typescriptSortKeys,
|
|
24
|
+
},
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* TypeScript ESLint configuration with parser setup and rules
|
|
29
|
+
*
|
|
30
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
31
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
32
|
+
*/
|
|
33
|
+
export function typescript(config) {
|
|
34
|
+
return {
|
|
35
|
+
extends: [...typescriptConfig, ...(config?.extends ?? [])],
|
|
36
|
+
files: ["**/*.js", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.cts", "**/*.mts"],
|
|
37
|
+
...config,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { typescriptConfig } from "./typescript.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: typescriptConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
describe("typescript", () => {
|
|
11
11
|
test("loads without errors", async () => {
|
|
12
|
-
const results = await eslint.lintText("const x
|
|
12
|
+
const results = await eslint.lintText("const x = 1\n", {
|
|
13
|
+
filePath: "src/eslint/configs/typescript.test.js",
|
|
14
|
+
})
|
|
13
15
|
|
|
14
16
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
17
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
18
|
})
|
|
17
19
|
})
|
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import vitestPlugin from "../plugins/vitest.js"
|
|
1
|
+
import { vitest as vitestPlugin } from "../plugins/vitest.js"
|
|
2
2
|
|
|
3
|
-
const vitestConfig = [vitestPlugin]
|
|
3
|
+
export const vitestConfig = [vitestPlugin]
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Vitest testing framework configuration
|
|
7
|
+
*
|
|
8
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
9
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
10
|
+
*/
|
|
11
|
+
export function vitest(config) {
|
|
12
|
+
return {
|
|
13
|
+
extends: [...vitestConfig, ...(config?.extends ?? [])],
|
|
14
|
+
files: [
|
|
15
|
+
"**/*.test.js",
|
|
16
|
+
"**/*.test.ts",
|
|
17
|
+
"**/*.spec.js",
|
|
18
|
+
"**/*.spec.ts",
|
|
19
|
+
"**/*.unit.test.js",
|
|
20
|
+
"**/*.unit.test.ts",
|
|
21
|
+
"**/*.int.test.js",
|
|
22
|
+
"**/*.int.test.ts",
|
|
23
|
+
"**/*.integration.test.js",
|
|
24
|
+
"**/*.integration.test.ts",
|
|
25
|
+
],
|
|
26
|
+
...config,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { vitestConfig } from "./vitest.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: vitestConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ describe("vitest", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.test.ts" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { defineConfig, globalIgnores } from "eslint/config"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Custom wrapper for ESLint defineConfig with simplified API
|
|
6
|
+
*
|
|
7
|
+
* @param {string[]} ignores - Paths to ignore
|
|
8
|
+
* @param {Array} configs - Array of ESLint config objects
|
|
9
|
+
* @returns {Array} ESLint configuration
|
|
10
|
+
*/
|
|
11
|
+
export function customDefineConfig(ignores, configs = []) {
|
|
12
|
+
return defineConfig(globalIgnores(["node_modules", ...ignores]), ...configs)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export * from "./configs/core.js"
|
|
16
|
+
export * from "./configs/jest.js"
|
|
17
|
+
export * from "./configs/mobx.js"
|
|
18
|
+
export * from "./configs/next.js"
|
|
19
|
+
export * from "./configs/node.js"
|
|
20
|
+
export * from "./configs/playwright.js"
|
|
21
|
+
export * from "./configs/react.js"
|
|
22
|
+
export * from "./configs/storybook.js"
|
|
23
|
+
export * from "./configs/typescript.js"
|
|
24
|
+
export * from "./configs/typescript-strict.js"
|
|
25
|
+
export * from "./configs/vitest.js"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { noCommentedOutCode } from "../rules/no-commented-out-code/no-commented-out-code.js"
|
|
2
|
+
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const dvukovic = {
|
|
5
|
+
plugins: {
|
|
6
|
+
dvukovic: {
|
|
7
|
+
rules: {
|
|
8
|
+
"no-commented-out-code": noCommentedOutCode,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
"dvukovic/no-commented-out-code": "error",
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "eslint-plugin-es-x"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const esX = {
|
|
4
5
|
plugins: {
|
|
5
|
-
"es-x":
|
|
6
|
+
"es-x": plugin,
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
...plugin.configs["flat/restrict-to-es2022"].rules,
|
|
6
10
|
},
|
|
7
|
-
rules: {},
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
export default plugin
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "@eslint-community/eslint-plugin-eslint-comments"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const eslintComments = {
|
|
4
5
|
plugins: {
|
|
5
|
-
"@eslint-community/eslint-comments":
|
|
6
|
+
"@eslint-community/eslint-comments": plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
|
-
"@eslint-community/eslint-comments/disable-enable-pair": "error",
|
|
9
9
|
"@eslint-community/eslint-comments/no-aggregating-enable": "error",
|
|
10
10
|
"@eslint-community/eslint-comments/no-duplicate-disable": "error",
|
|
11
11
|
"@eslint-community/eslint-comments/no-unlimited-disable": "error",
|
|
@@ -14,5 +14,3 @@ const plugin = {
|
|
|
14
14
|
"@eslint-community/eslint-comments/require-description": "error",
|
|
15
15
|
},
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
export default plugin
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import globals from "globals"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const eslint = {
|
|
4
5
|
languageOptions: {
|
|
5
6
|
ecmaVersion: 2024,
|
|
6
7
|
globals: {
|
|
@@ -101,6 +102,13 @@ const plugin = {
|
|
|
101
102
|
"no-proto": "error",
|
|
102
103
|
"no-prototype-builtins": "error",
|
|
103
104
|
"no-regex-spaces": "error",
|
|
105
|
+
"no-restricted-syntax": [
|
|
106
|
+
"error",
|
|
107
|
+
{
|
|
108
|
+
message: "Use union types or const objects instead of enums.",
|
|
109
|
+
selector: "TSEnumDeclaration",
|
|
110
|
+
},
|
|
111
|
+
],
|
|
104
112
|
"no-return-assign": "error",
|
|
105
113
|
"no-script-url": "error",
|
|
106
114
|
"no-self-assign": "error",
|
|
@@ -166,5 +174,3 @@ const plugin = {
|
|
|
166
174
|
yoda: "error",
|
|
167
175
|
},
|
|
168
176
|
}
|
|
169
|
-
|
|
170
|
-
export default plugin
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ESLint } from "eslint"
|
|
2
|
+
import tseslint from "typescript-eslint"
|
|
3
|
+
|
|
4
|
+
import { eslint as base } from "./eslint.js"
|
|
5
|
+
|
|
6
|
+
const eslint = new ESLint({
|
|
7
|
+
overrideConfig: [
|
|
8
|
+
{
|
|
9
|
+
files: ["**/*.ts"],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parser: tseslint.parser,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
base,
|
|
15
|
+
],
|
|
16
|
+
overrideConfigFile: true,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe("eslint no-enum", () => {
|
|
20
|
+
test("detects enum declarations", async () => {
|
|
21
|
+
const code = `enum Status { Active, Inactive }\n`
|
|
22
|
+
const results = await eslint.lintText(code, { filePath: "test.ts" })
|
|
23
|
+
|
|
24
|
+
const enumErrors = results[0]?.messages.filter((message) => {
|
|
25
|
+
return message.ruleId === "no-restricted-syntax"
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
expect(enumErrors?.length).toBe(1)
|
|
29
|
+
expect(enumErrors?.[0]?.message).toContain("enum")
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test("allows union types", async () => {
|
|
33
|
+
const code = `type Status = "active" | "inactive"\n`
|
|
34
|
+
const results = await eslint.lintText(code, { filePath: "test.ts" })
|
|
35
|
+
|
|
36
|
+
const restrictedSyntaxErrors = results?.[0]?.messages.filter((message) => {
|
|
37
|
+
return message.ruleId === "no-restricted-syntax"
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
expect(restrictedSyntaxErrors?.length).toBe(0)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "eslint-plugin-import-x"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const importX = {
|
|
4
5
|
plugins: {
|
|
5
|
-
"import-x":
|
|
6
|
+
"import-x": plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
9
|
"import-x/default": "error",
|
|
@@ -18,7 +19,12 @@ const plugin = {
|
|
|
18
19
|
"import-x/no-duplicates": "error",
|
|
19
20
|
"import-x/no-dynamic-require": "error",
|
|
20
21
|
"import-x/no-empty-named-blocks": "error",
|
|
21
|
-
"import-x/no-extraneous-dependencies":
|
|
22
|
+
"import-x/no-extraneous-dependencies": [
|
|
23
|
+
"error",
|
|
24
|
+
{
|
|
25
|
+
whitelist: ["typescript-eslint"],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
22
28
|
"import-x/no-mutable-exports": "error",
|
|
23
29
|
"import-x/no-named-as-default": "error",
|
|
24
30
|
"import-x/no-named-as-default-member": "error",
|
|
@@ -28,5 +34,3 @@ const plugin = {
|
|
|
28
34
|
"import-x/no-useless-path-segments": "error",
|
|
29
35
|
},
|
|
30
36
|
}
|
|
31
|
-
|
|
32
|
-
export default plugin
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "eslint-plugin-jest"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const jest = {
|
|
4
5
|
plugins: {
|
|
5
|
-
jest,
|
|
6
|
+
jest: plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
9
|
"jest/consistent-test-it": ["error", { fn: "test", withinDescribe: "test" }],
|
|
@@ -60,5 +61,3 @@ const plugin = {
|
|
|
60
61
|
"jest/valid-title": "error",
|
|
61
62
|
},
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
export default plugin
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "eslint-plugin-mobx"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const mobx = {
|
|
4
5
|
plugins: {
|
|
5
|
-
mobx,
|
|
6
|
+
mobx: plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
9
|
"mobx/exhaustive-make-observable": "error",
|
|
@@ -10,5 +11,3 @@ const plugin = {
|
|
|
10
11
|
"mobx/unconditional-make-observable": "error",
|
|
11
12
|
},
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
export default plugin
|
package/src/eslint/plugins/n.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "eslint-plugin-n"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const nodeN = {
|
|
4
5
|
plugins: {
|
|
5
|
-
n:
|
|
6
|
+
n: plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
9
|
"n/callback-return": "error",
|
|
@@ -12,7 +13,6 @@ const plugin = {
|
|
|
12
13
|
"n/hashbang": "error",
|
|
13
14
|
"n/no-deprecated-api": "error",
|
|
14
15
|
"n/no-exports-assign": "error",
|
|
15
|
-
"n/no-extraneous-import": "error",
|
|
16
16
|
"n/no-extraneous-require": "error",
|
|
17
17
|
"n/no-missing-require": "error",
|
|
18
18
|
"n/no-new-require": "error",
|
|
@@ -38,5 +38,3 @@ const plugin = {
|
|
|
38
38
|
"n/prefer-promises/fs": "error",
|
|
39
39
|
},
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
export default plugin
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "@next/eslint-plugin-next"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const next = {
|
|
4
5
|
plugins: {
|
|
5
|
-
"@next/next":
|
|
6
|
+
"@next/next": plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
9
|
"@next/next/google-font-display": "error",
|
|
@@ -28,5 +29,3 @@ const plugin = {
|
|
|
28
29
|
"@next/next/no-unwanted-polyfillio": "error",
|
|
29
30
|
},
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
export default plugin
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "eslint-plugin-playwright"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const playwright = {
|
|
4
5
|
plugins: {
|
|
5
|
-
playwright,
|
|
6
|
+
playwright: plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
9
|
"playwright/expect-expect": "error",
|
|
@@ -56,5 +57,3 @@ const plugin = {
|
|
|
56
57
|
"playwright/valid-title": "error",
|
|
57
58
|
},
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
export default plugin
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "eslint-plugin-promise"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const promise = {
|
|
4
5
|
plugins: {
|
|
5
|
-
promise,
|
|
6
|
+
promise: plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
9
|
"promise/always-return": "error",
|
|
@@ -18,5 +19,3 @@ const plugin = {
|
|
|
18
19
|
"promise/valid-params": "error",
|
|
19
20
|
},
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
export default plugin
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import plugin from "eslint-plugin-react-hooks"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import("@eslint/config-helpers").Config} */
|
|
4
|
+
export const reactHooks = {
|
|
4
5
|
plugins: {
|
|
5
|
-
"react-hooks":
|
|
6
|
+
"react-hooks": plugin,
|
|
6
7
|
},
|
|
7
8
|
rules: {
|
|
8
9
|
"react-hooks/rules-of-hooks": "error",
|
|
9
10
|
},
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
export default plugin
|