@ts-items/oxlint-config 0.0.1 → 0.2.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.
Files changed (30) hide show
  1. package/README.md +43 -0
  2. package/dist/configurations/baseConfig/baseConfig.d.ts +80 -23
  3. package/dist/configurations/baseConfig/baseConfig.js +14 -22
  4. package/dist/configurations/baseConfig/rules/eslintRules/eslintRules.d.ts +52 -16
  5. package/dist/configurations/baseConfig/rules/eslintRules/eslintRules.js +24 -1
  6. package/dist/configurations/baseConfig/rules/importRules/importRules.d.ts +9 -0
  7. package/dist/configurations/baseConfig/rules/importRules/importRules.js +10 -0
  8. package/dist/configurations/baseConfig/rules/oxcRules/oxcRules.d.ts +5 -0
  9. package/dist/configurations/baseConfig/rules/oxcRules/oxcRules.js +6 -0
  10. package/dist/configurations/baseConfig/rules/typescriptRules/typescriptRules.d.ts +12 -1
  11. package/dist/configurations/baseConfig/rules/typescriptRules/typescriptRules.js +4 -0
  12. package/dist/configurations/baseConfig/rules/unicornRules/unicornRules.d.ts +7 -1
  13. package/dist/configurations/baseConfig/rules/unicornRules/unicornRules.js +2 -0
  14. package/dist/configurations/index.d.ts +3 -0
  15. package/dist/configurations/index.js +3 -0
  16. package/dist/configurations/nextConfig/nextConfig.d.ts +153 -0
  17. package/dist/configurations/nextConfig/nextConfig.js +63 -0
  18. package/dist/configurations/reactConfig/reactConfig.d.ts +90 -28
  19. package/dist/configurations/reactConfig/reactConfig.js +4 -17
  20. package/dist/configurations/reactConfig/rules/reactPerformanceRules/reactPerformanceRules.d.ts +6 -0
  21. package/dist/configurations/reactConfig/rules/reactPerformanceRules/reactPerformanceRules.js +8 -0
  22. package/dist/configurations/reactConfig/rules/reactRules/reactRules.d.ts +18 -0
  23. package/dist/configurations/reactConfig/rules/reactRules/reactRules.js +21 -0
  24. package/dist/configurations/storybookConfig/storybookConfig.d.ts +22 -0
  25. package/dist/configurations/storybookConfig/storybookConfig.js +38 -0
  26. package/dist/configurations/vitestConfig/vitestConfig.d.ts +24 -0
  27. package/dist/configurations/vitestConfig/vitestConfig.js +35 -0
  28. package/dist/utilities/withRulePrefix/withRulePrefix.d.ts +6 -1
  29. package/dist/utilities/withRulePrefix/withRulePrefix.js +1 -0
  30. package/package.json +1 -1
package/README.md CHANGED
@@ -43,3 +43,46 @@ export default defineConfig({
43
43
  },
44
44
  })
45
45
  ```
46
+
47
+ ### For Next.js + TypeScript projects
48
+
49
+ ```ts
50
+ import { nextConfig } from "@ts-items/oxlint-config"
51
+ import { defineConfig } from "oxlint"
52
+
53
+ export default defineConfig({
54
+ extends: [nextConfig],
55
+ options: {
56
+ typeAware: true, // Optional but recommended. Requires `oxlint-tsgolint`
57
+ },
58
+ })
59
+ ```
60
+
61
+ ### For Storybook with some React Project
62
+
63
+ Turn off some rules that are not suitable with Storybook
64
+
65
+ ```ts
66
+ import { storybookConfig } from "@ts-items/oxlint-config"
67
+ import { defineConfig } from "oxlint"
68
+
69
+ export default defineConfig({
70
+ extends: [storybookConfig],
71
+ // some config for react
72
+ })
73
+ ```
74
+
75
+ ### For Vitest with some TypeScript Project
76
+
77
+ Enable the vitest plugin and adjust some of its rules for Vitest.
78
+ `vitest/prefer-importing-vitest-globals` is enabled only for test files (`*.spec.*`, `*.test.*`, `spec/**`), so `expect` imported from `storybook/test` in stories is not reported.
79
+
80
+ ```ts
81
+ import { vitestConfig } from "@ts-items/oxlint-config"
82
+ import { defineConfig } from "oxlint"
83
+
84
+ export default defineConfig({
85
+ extends: [vitestConfig],
86
+ // some config for typescript
87
+ })
88
+ ```
@@ -8,31 +8,88 @@ export declare const baseConfig: {
8
8
  style: "error";
9
9
  suspicious: "error";
10
10
  };
11
- plugins: ("eslint" | "unicorn" | "oxc" | "import")[];
11
+ overrides: {
12
+ files: string[];
13
+ rules: {
14
+ "typescript/consistent-type-definitions": "off";
15
+ };
16
+ }[];
17
+ plugins: ("eslint" | "import" | "oxc" | "unicorn")[];
12
18
  rules: {
13
- "explicit-function-return-type": "off";
14
- "explicit-module-boundary-types": "off";
15
- "exports-last": "off";
16
- "filename-case": "off";
17
- "group-exports": "off";
18
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"];
19
- "import/no-relative-parent-imports": "off";
20
- "no-duplicate-imports": ["error", {
21
- allowSeparateTypeImports: true;
22
- }];
23
- "no-inline-comments": "off";
24
- "no-named-export": "off";
25
- "no-nested-ternary": "error";
26
- "no-null": "off";
27
- "no-rest-spread-properties": "off";
28
- "no-ternary": "off";
29
- "no-undefined": "off";
30
- "no-unneeded-ternary": "error";
31
- "no-warning-comments": "off";
32
- "one-var": "off";
19
+ "unicorn/filename-case": "off";
20
+ "unicorn/no-array-callback-reference": "off";
21
+ "unicorn/no-array-reduce": "off";
22
+ "unicorn/no-immediate-mutation": "off";
23
+ "unicorn/no-null": "off";
24
+ "typescript/require-await": "error";
25
+ "typescript/consistent-type-definitions": ["error", "type"];
26
+ "typescript/explicit-function-return-type": "off";
27
+ "typescript/explicit-module-boundary-types": "off";
28
+ "typescript/prefer-readonly-parameter-types": "off";
29
+ "typescript/promise-function-async": "error";
30
+ "typescript/restrict-template-expressions": ["error", {
31
+ readonly allowBoolean: true;
32
+ readonly allowNumber: true;
33
+ }];
33
34
  "oxc/no-async-await": "off";
34
35
  "oxc/no-optional-chaining": "off";
35
- "prefer-default-export": "off";
36
- "sort-imports": "off";
36
+ "oxc/no-rest-spread-properties": "off";
37
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"];
38
+ "import/exports-last": "off";
39
+ "import/group-exports": "off";
40
+ "import/max-dependencies": "off";
41
+ "import/no-named-export": "off";
42
+ "import/no-relative-parent-imports": "off";
43
+ "import/prefer-default-export": "off";
44
+ "eslint/arrow-body-style": ["error", "as-needed"];
45
+ "eslint/complexity": ["error", 5];
46
+ "eslint/curly": ["warn", "all"];
47
+ "eslint/id-length": ["error", {
48
+ readonly exceptions: ["_"];
49
+ readonly min: 2;
50
+ }];
51
+ "eslint/max-depth": ["error", 3];
52
+ "eslint/max-lines": ["error", {
53
+ readonly max: 100;
54
+ }];
55
+ "eslint/max-lines-per-function": ["error", {
56
+ readonly IIFEs: true;
57
+ readonly max: 50;
58
+ readonly skipBlankLines: true;
59
+ readonly skipComments: true;
60
+ }];
61
+ "eslint/max-nested-callbacks": ["error", 3];
62
+ "eslint/max-params": ["warn", 3];
63
+ "eslint/max-statements": ["error", 10];
64
+ "eslint/no-duplicate-imports": ["error", {
65
+ readonly allowSeparateTypeImports: true;
66
+ }];
67
+ "eslint/no-implicit-coercion": ["warn", {
68
+ readonly boolean: true;
69
+ readonly number: true;
70
+ readonly string: true;
71
+ }];
72
+ "eslint/no-inline-comments": "off";
73
+ "eslint/no-magic-numbers": ["warn", {
74
+ readonly ignoreNumericLiteralTypes: true;
75
+ readonly ignoreReadonlyClassProperties: true;
76
+ readonly ignoreTypeIndexes: true;
77
+ }];
78
+ "eslint/no-nested-ternary": "error";
79
+ "eslint/no-param-reassign": ["error", {
80
+ readonly props: true;
81
+ }];
82
+ "eslint/no-ternary": "off";
83
+ "eslint/no-undefined": "off";
84
+ "eslint/no-unneeded-ternary": "error";
85
+ "eslint/no-use-before-define": "error";
86
+ "eslint/no-warning-comments": "off";
87
+ "eslint/one-var": "off";
88
+ "eslint/prefer-named-capture-group": "warn";
89
+ "eslint/require-await": "off";
90
+ "eslint/sort-imports": "off";
91
+ "eslint/sort-keys": ["warn", "asc", {
92
+ readonly allowLineSeparatedGroups: true;
93
+ }];
37
94
  };
38
95
  };
@@ -1,5 +1,8 @@
1
1
  import { defineConfig } from "oxlint";
2
+ import { withRulePrefix } from "../../utilities/withRulePrefix/withRulePrefix.js";
2
3
  import { eslintRules } from "./rules/eslintRules/eslintRules.js";
4
+ import { importRules } from "./rules/importRules/importRules.js";
5
+ import { oxcRules } from "./rules/oxcRules/oxcRules.js";
3
6
  import { typescriptRules } from "./rules/typescriptRules/typescriptRules.js";
4
7
  import { unicornRules } from "./rules/unicornRules/unicornRules.js";
5
8
  export const baseConfig = defineConfig({
@@ -12,32 +15,21 @@ export const baseConfig = defineConfig({
12
15
  style: "error",
13
16
  suspicious: "error",
14
17
  },
18
+ overrides: [
19
+ {
20
+ // Declaration merging(module augmentation 等)は interface でしか書けず、type への自動修正で拡張が無効になるため
21
+ files: ["**/*.d.{ts,mts,cts}"],
22
+ rules: withRulePrefix("typescript", {
23
+ "consistent-type-definitions": "off",
24
+ }),
25
+ },
26
+ ],
15
27
  plugins: ["eslint", "import", "oxc", "unicorn"],
16
28
  rules: {
17
29
  ...eslintRules,
30
+ ...importRules,
31
+ ...oxcRules,
18
32
  ...typescriptRules,
19
33
  ...unicornRules,
20
- "explicit-function-return-type": "off",
21
- "explicit-module-boundary-types": "off",
22
- "exports-last": "off",
23
- "filename-case": "off",
24
- "group-exports": "off",
25
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
26
- "import/no-relative-parent-imports": "off",
27
- "no-duplicate-imports": ["error", { allowSeparateTypeImports: true }],
28
- "no-inline-comments": "off",
29
- "no-named-export": "off",
30
- "no-nested-ternary": "error",
31
- "no-null": "off",
32
- "no-rest-spread-properties": "off",
33
- "no-ternary": "off",
34
- "no-undefined": "off",
35
- "no-unneeded-ternary": "error",
36
- "no-warning-comments": "off",
37
- "one-var": "off",
38
- "oxc/no-async-await": "off",
39
- "oxc/no-optional-chaining": "off",
40
- "prefer-default-export": "off",
41
- "sort-imports": "off",
42
34
  },
43
35
  });
@@ -1,16 +1,52 @@
1
- export declare const eslintRules: Record<`eslint/${string}`, "off" | "warn" | "error" | ["error", "as-needed"] | ["error", 5] | ["warn", "all"] | ["error", 3] | ["warn", 3] | ["error", 10] | ["error", {
2
- readonly max: 100;
3
- }] | ["error", {
4
- readonly IIFEs: true;
5
- readonly max: 50;
6
- readonly skipBlankLines: true;
7
- readonly skipComments: true;
8
- }] | ["warn", {
9
- readonly boolean: true;
10
- readonly number: true;
11
- readonly string: true;
12
- }] | ["error", {
13
- readonly props: true;
14
- }] | ["warn", "asc", {
15
- readonly allowLineSeparatedGroups: true;
16
- }]>;
1
+ export declare const eslintRules: {
2
+ "eslint/arrow-body-style": ["error", "as-needed"];
3
+ "eslint/complexity": ["error", 5];
4
+ "eslint/curly": ["warn", "all"];
5
+ "eslint/id-length": ["error", {
6
+ readonly exceptions: ["_"];
7
+ readonly min: 2;
8
+ }];
9
+ "eslint/max-depth": ["error", 3];
10
+ "eslint/max-lines": ["error", {
11
+ readonly max: 100;
12
+ }];
13
+ "eslint/max-lines-per-function": ["error", {
14
+ readonly IIFEs: true;
15
+ readonly max: 50;
16
+ readonly skipBlankLines: true;
17
+ readonly skipComments: true;
18
+ }];
19
+ "eslint/max-nested-callbacks": ["error", 3];
20
+ "eslint/max-params": ["warn", 3];
21
+ "eslint/max-statements": ["error", 10];
22
+ "eslint/no-duplicate-imports": ["error", {
23
+ readonly allowSeparateTypeImports: true;
24
+ }];
25
+ "eslint/no-implicit-coercion": ["warn", {
26
+ readonly boolean: true;
27
+ readonly number: true;
28
+ readonly string: true;
29
+ }];
30
+ "eslint/no-inline-comments": "off";
31
+ "eslint/no-magic-numbers": ["warn", {
32
+ readonly ignoreNumericLiteralTypes: true;
33
+ readonly ignoreReadonlyClassProperties: true;
34
+ readonly ignoreTypeIndexes: true;
35
+ }];
36
+ "eslint/no-nested-ternary": "error";
37
+ "eslint/no-param-reassign": ["error", {
38
+ readonly props: true;
39
+ }];
40
+ "eslint/no-ternary": "off";
41
+ "eslint/no-undefined": "off";
42
+ "eslint/no-unneeded-ternary": "error";
43
+ "eslint/no-use-before-define": "error";
44
+ "eslint/no-warning-comments": "off";
45
+ "eslint/one-var": "off";
46
+ "eslint/prefer-named-capture-group": "warn";
47
+ "eslint/require-await": "off";
48
+ "eslint/sort-imports": "off";
49
+ "eslint/sort-keys": ["warn", "asc", {
50
+ readonly allowLineSeparatedGroups: true;
51
+ }];
52
+ };
@@ -4,6 +4,13 @@ export const eslintRules = withRulePrefix("eslint", {
4
4
  "arrow-body-style": ["error", "as-needed"],
5
5
  "complexity": ["error", 5],
6
6
  "curly": ["warn", "all"],
7
+ "id-length": [
8
+ "error",
9
+ {
10
+ exceptions: ["_"],
11
+ min: 2,
12
+ },
13
+ ],
7
14
  "max-depth": ["error", 3],
8
15
  "max-lines": ["error", { max: 100 }],
9
16
  "max-lines-per-function": [
@@ -18,6 +25,7 @@ export const eslintRules = withRulePrefix("eslint", {
18
25
  "max-nested-callbacks": ["error", 3],
19
26
  "max-params": ["warn", 3],
20
27
  "max-statements": ["error", 10],
28
+ "no-duplicate-imports": ["error", { allowSeparateTypeImports: true }],
21
29
  "no-implicit-coercion": [
22
30
  "warn",
23
31
  {
@@ -26,15 +34,30 @@ export const eslintRules = withRulePrefix("eslint", {
26
34
  string: true,
27
35
  },
28
36
  ],
29
- "no-magic-numbers": "warn",
37
+ "no-inline-comments": "off",
38
+ "no-magic-numbers": [
39
+ "warn",
40
+ {
41
+ ignoreNumericLiteralTypes: true,
42
+ ignoreReadonlyClassProperties: true,
43
+ ignoreTypeIndexes: true,
44
+ },
45
+ ],
46
+ "no-nested-ternary": "error",
30
47
  "no-param-reassign": [
31
48
  "error",
32
49
  {
33
50
  props: true,
34
51
  },
35
52
  ],
53
+ "no-ternary": "off",
54
+ "no-undefined": "off",
55
+ "no-unneeded-ternary": "error",
36
56
  "no-use-before-define": "error",
57
+ "no-warning-comments": "off",
58
+ "one-var": "off",
37
59
  "prefer-named-capture-group": "warn",
38
60
  "require-await": "off",
61
+ "sort-imports": "off",
39
62
  "sort-keys": ["warn", "asc", { allowLineSeparatedGroups: true }],
40
63
  });
@@ -0,0 +1,9 @@
1
+ export declare const importRules: {
2
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"];
3
+ "import/exports-last": "off";
4
+ "import/group-exports": "off";
5
+ "import/max-dependencies": "off";
6
+ "import/no-named-export": "off";
7
+ "import/no-relative-parent-imports": "off";
8
+ "import/prefer-default-export": "off";
9
+ };
@@ -0,0 +1,10 @@
1
+ import { withRulePrefix } from "../../../../utilities/withRulePrefix/withRulePrefix.js";
2
+ export const importRules = withRulePrefix("import", {
3
+ "consistent-type-specifier-style": ["error", "prefer-top-level"],
4
+ "exports-last": "off",
5
+ "group-exports": "off",
6
+ "max-dependencies": "off",
7
+ "no-named-export": "off",
8
+ "no-relative-parent-imports": "off",
9
+ "prefer-default-export": "off",
10
+ });
@@ -0,0 +1,5 @@
1
+ export declare const oxcRules: {
2
+ "oxc/no-async-await": "off";
3
+ "oxc/no-optional-chaining": "off";
4
+ "oxc/no-rest-spread-properties": "off";
5
+ };
@@ -0,0 +1,6 @@
1
+ import { withRulePrefix } from "../../../../utilities/withRulePrefix/withRulePrefix.js";
2
+ export const oxcRules = withRulePrefix("oxc", {
3
+ "no-async-await": "off",
4
+ "no-optional-chaining": "off",
5
+ "no-rest-spread-properties": "off",
6
+ });
@@ -1 +1,12 @@
1
- export declare const typescriptRules: Record<`typescript/${string}`, "off" | "error">;
1
+ export declare const typescriptRules: {
2
+ "typescript/require-await": "error";
3
+ "typescript/consistent-type-definitions": ["error", "type"];
4
+ "typescript/explicit-function-return-type": "off";
5
+ "typescript/explicit-module-boundary-types": "off";
6
+ "typescript/prefer-readonly-parameter-types": "off";
7
+ "typescript/promise-function-async": "error";
8
+ "typescript/restrict-template-expressions": ["error", {
9
+ readonly allowBoolean: true;
10
+ readonly allowNumber: true;
11
+ }];
12
+ };
@@ -1,6 +1,10 @@
1
1
  import { withRulePrefix } from "../../../../utilities/withRulePrefix/withRulePrefix.js";
2
2
  export const typescriptRules = withRulePrefix("typescript", {
3
+ "consistent-type-definitions": ["error", "type"],
4
+ "explicit-function-return-type": "off",
5
+ "explicit-module-boundary-types": "off",
3
6
  "prefer-readonly-parameter-types": "off",
4
7
  "promise-function-async": "error",
5
8
  "require-await": "error",
9
+ "restrict-template-expressions": ["error", { allowBoolean: true, allowNumber: true }],
6
10
  });
@@ -1 +1,7 @@
1
- export declare const unicornRules: Record<`unicorn/${string}`, "off">;
1
+ export declare const unicornRules: {
2
+ "unicorn/filename-case": "off";
3
+ "unicorn/no-array-callback-reference": "off";
4
+ "unicorn/no-array-reduce": "off";
5
+ "unicorn/no-immediate-mutation": "off";
6
+ "unicorn/no-null": "off";
7
+ };
@@ -1,6 +1,8 @@
1
1
  import { withRulePrefix } from "../../../../utilities/withRulePrefix/withRulePrefix.js";
2
2
  export const unicornRules = withRulePrefix("unicorn", {
3
+ "filename-case": "off",
3
4
  "no-array-callback-reference": "off",
4
5
  "no-array-reduce": "off",
5
6
  "no-immediate-mutation": "off",
7
+ "no-null": "off",
6
8
  });
@@ -1,2 +1,5 @@
1
1
  export { baseConfig } from "./baseConfig/baseConfig.ts";
2
+ export { nextConfig } from "./nextConfig/nextConfig.ts";
2
3
  export { reactConfig } from "./reactConfig/reactConfig.ts";
4
+ export { storybookConfig } from "./storybookConfig/storybookConfig.ts";
5
+ export { vitestConfig } from "./vitestConfig/vitestConfig.ts";
@@ -1,2 +1,5 @@
1
1
  export { baseConfig } from "./baseConfig/baseConfig.js";
2
+ export { nextConfig } from "./nextConfig/nextConfig.js";
2
3
  export { reactConfig } from "./reactConfig/reactConfig.js";
4
+ export { storybookConfig } from "./storybookConfig/storybookConfig.js";
5
+ export { vitestConfig } from "./vitestConfig/vitestConfig.js";
@@ -0,0 +1,153 @@
1
+ export declare const nextConfig: {
2
+ extends: {
3
+ extends: {
4
+ categories: {
5
+ correctness: "error";
6
+ nursery: "off";
7
+ pedantic: "error";
8
+ perf: "error";
9
+ restriction: "error";
10
+ style: "error";
11
+ suspicious: "error";
12
+ };
13
+ overrides: {
14
+ files: string[];
15
+ rules: {
16
+ "typescript/consistent-type-definitions": "off";
17
+ };
18
+ }[];
19
+ plugins: ("eslint" | "import" | "oxc" | "unicorn")[];
20
+ rules: {
21
+ "unicorn/filename-case": "off";
22
+ "unicorn/no-array-callback-reference": "off";
23
+ "unicorn/no-array-reduce": "off";
24
+ "unicorn/no-immediate-mutation": "off";
25
+ "unicorn/no-null": "off";
26
+ "typescript/require-await": "error";
27
+ "typescript/consistent-type-definitions": ["error", "type"];
28
+ "typescript/explicit-function-return-type": "off";
29
+ "typescript/explicit-module-boundary-types": "off";
30
+ "typescript/prefer-readonly-parameter-types": "off";
31
+ "typescript/promise-function-async": "error";
32
+ "typescript/restrict-template-expressions": ["error", {
33
+ readonly allowBoolean: true;
34
+ readonly allowNumber: true;
35
+ }];
36
+ "oxc/no-async-await": "off";
37
+ "oxc/no-optional-chaining": "off";
38
+ "oxc/no-rest-spread-properties": "off";
39
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"];
40
+ "import/exports-last": "off";
41
+ "import/group-exports": "off";
42
+ "import/max-dependencies": "off";
43
+ "import/no-named-export": "off";
44
+ "import/no-relative-parent-imports": "off";
45
+ "import/prefer-default-export": "off";
46
+ "eslint/arrow-body-style": ["error", "as-needed"];
47
+ "eslint/complexity": ["error", 5];
48
+ "eslint/curly": ["warn", "all"];
49
+ "eslint/id-length": ["error", {
50
+ readonly exceptions: ["_"];
51
+ readonly min: 2;
52
+ }];
53
+ "eslint/max-depth": ["error", 3];
54
+ "eslint/max-lines": ["error", {
55
+ readonly max: 100;
56
+ }];
57
+ "eslint/max-lines-per-function": ["error", {
58
+ readonly IIFEs: true;
59
+ readonly max: 50;
60
+ readonly skipBlankLines: true;
61
+ readonly skipComments: true;
62
+ }];
63
+ "eslint/max-nested-callbacks": ["error", 3];
64
+ "eslint/max-params": ["warn", 3];
65
+ "eslint/max-statements": ["error", 10];
66
+ "eslint/no-duplicate-imports": ["error", {
67
+ readonly allowSeparateTypeImports: true;
68
+ }];
69
+ "eslint/no-implicit-coercion": ["warn", {
70
+ readonly boolean: true;
71
+ readonly number: true;
72
+ readonly string: true;
73
+ }];
74
+ "eslint/no-inline-comments": "off";
75
+ "eslint/no-magic-numbers": ["warn", {
76
+ readonly ignoreNumericLiteralTypes: true;
77
+ readonly ignoreReadonlyClassProperties: true;
78
+ readonly ignoreTypeIndexes: true;
79
+ }];
80
+ "eslint/no-nested-ternary": "error";
81
+ "eslint/no-param-reassign": ["error", {
82
+ readonly props: true;
83
+ }];
84
+ "eslint/no-ternary": "off";
85
+ "eslint/no-undefined": "off";
86
+ "eslint/no-unneeded-ternary": "error";
87
+ "eslint/no-use-before-define": "error";
88
+ "eslint/no-warning-comments": "off";
89
+ "eslint/one-var": "off";
90
+ "eslint/prefer-named-capture-group": "warn";
91
+ "eslint/require-await": "off";
92
+ "eslint/sort-imports": "off";
93
+ "eslint/sort-keys": ["warn", "asc", {
94
+ readonly allowLineSeparatedGroups: true;
95
+ }];
96
+ };
97
+ }[];
98
+ plugins: ("react" | "react-perf")[];
99
+ rules: {
100
+ "react-perf/jsx-no-jsx-as-prop": "off";
101
+ "react-perf/jsx-no-new-array-as-prop": "off";
102
+ "react-perf/jsx-no-new-function-as-prop": "off";
103
+ "react-perf/jsx-no-new-object-as-prop": "off";
104
+ "react/forbid-component-props": ["error", {
105
+ readonly forbid: ["style"];
106
+ }];
107
+ "react/function-component-definition": ["error", {
108
+ readonly namedComponents: "arrow-function";
109
+ }];
110
+ "react/jsx-filename-extension": ["error", {
111
+ readonly extensions: ["tsx"];
112
+ }];
113
+ "react/jsx-fragments": ["error", "element"];
114
+ "react/jsx-max-depth": ["error", {
115
+ readonly max: 5;
116
+ }];
117
+ "react/jsx-no-literals": "off";
118
+ "react/jsx-props-no-spreading": "off";
119
+ "react/react-in-jsx-scope": "off";
120
+ };
121
+ }[];
122
+ ignorePatterns: string[];
123
+ overrides: ({
124
+ files: never[];
125
+ rules: {
126
+ "import/no-unassigned-import": "off";
127
+ };
128
+ } | {
129
+ files: string[];
130
+ rules: {
131
+ "react/only-export-components": ["error", {
132
+ readonly allowExportNames: ["dynamic", "generateMetadata", "generateStaticParams", "metadata", "revalidate"];
133
+ }];
134
+ "import/no-default-export": "off";
135
+ };
136
+ } | {
137
+ files: string[];
138
+ rules: {
139
+ "oxc/no-async-await": "off";
140
+ "import/no-unassigned-import": ["error", {
141
+ readonly allow: ["**/*.css"];
142
+ }];
143
+ "import/no-default-export": "off";
144
+ "eslint/new-cap": "off";
145
+ };
146
+ } | {
147
+ files: string[];
148
+ rules: {
149
+ "import/no-default-export": "off";
150
+ };
151
+ })[];
152
+ plugins: "nextjs"[];
153
+ };
@@ -0,0 +1,63 @@
1
+ import { defineConfig } from "oxlint";
2
+ import { withRulePrefix } from "../../utilities/withRulePrefix/withRulePrefix.js";
3
+ import { reactConfig } from "../reactConfig/reactConfig.js";
4
+ export const nextConfig = defineConfig({
5
+ extends: [reactConfig],
6
+ ignorePatterns: ["**/next-env.d.ts"],
7
+ overrides: [
8
+ {
9
+ files: [],
10
+ rules: {
11
+ ...withRulePrefix("import", {
12
+ "no-unassigned-import": "off",
13
+ }),
14
+ },
15
+ },
16
+ {
17
+ files: ["**/app/**/{page,layout,loading,error,not-found,global-error,template}.tsx"],
18
+ rules: {
19
+ ...withRulePrefix("import", {
20
+ "no-default-export": "off",
21
+ }),
22
+ ...withRulePrefix("react", {
23
+ "only-export-components": [
24
+ "error",
25
+ {
26
+ allowExportNames: [
27
+ "dynamic",
28
+ "generateMetadata",
29
+ "generateStaticParams",
30
+ "metadata",
31
+ "revalidate",
32
+ ],
33
+ },
34
+ ],
35
+ }),
36
+ },
37
+ },
38
+ {
39
+ files: ["**/app/**/layout.tsx"],
40
+ rules: {
41
+ ...withRulePrefix("eslint", {
42
+ "new-cap": "off",
43
+ }),
44
+ ...withRulePrefix("import", {
45
+ "no-default-export": "off",
46
+ "no-unassigned-import": ["error", { allow: ["**/*.css"] }],
47
+ }),
48
+ ...withRulePrefix("oxc", {
49
+ "no-async-await": "off",
50
+ }),
51
+ },
52
+ },
53
+ {
54
+ files: ["**/proxy.ts"],
55
+ rules: {
56
+ ...withRulePrefix("import", {
57
+ "no-default-export": "off",
58
+ }),
59
+ },
60
+ },
61
+ ],
62
+ plugins: ["nextjs"],
63
+ });
@@ -9,50 +9,112 @@ export declare const reactConfig: {
9
9
  style: "error";
10
10
  suspicious: "error";
11
11
  };
12
- plugins: ("eslint" | "unicorn" | "oxc" | "import")[];
12
+ overrides: {
13
+ files: string[];
14
+ rules: {
15
+ "typescript/consistent-type-definitions": "off";
16
+ };
17
+ }[];
18
+ plugins: ("eslint" | "import" | "oxc" | "unicorn")[];
13
19
  rules: {
14
- "explicit-function-return-type": "off";
15
- "explicit-module-boundary-types": "off";
16
- "exports-last": "off";
17
- "filename-case": "off";
18
- "group-exports": "off";
19
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"];
20
- "import/no-relative-parent-imports": "off";
21
- "no-duplicate-imports": ["error", {
22
- allowSeparateTypeImports: true;
23
- }];
24
- "no-inline-comments": "off";
25
- "no-named-export": "off";
26
- "no-nested-ternary": "error";
27
- "no-null": "off";
28
- "no-rest-spread-properties": "off";
29
- "no-ternary": "off";
30
- "no-undefined": "off";
31
- "no-unneeded-ternary": "error";
32
- "no-warning-comments": "off";
33
- "one-var": "off";
20
+ "unicorn/filename-case": "off";
21
+ "unicorn/no-array-callback-reference": "off";
22
+ "unicorn/no-array-reduce": "off";
23
+ "unicorn/no-immediate-mutation": "off";
24
+ "unicorn/no-null": "off";
25
+ "typescript/require-await": "error";
26
+ "typescript/consistent-type-definitions": ["error", "type"];
27
+ "typescript/explicit-function-return-type": "off";
28
+ "typescript/explicit-module-boundary-types": "off";
29
+ "typescript/prefer-readonly-parameter-types": "off";
30
+ "typescript/promise-function-async": "error";
31
+ "typescript/restrict-template-expressions": ["error", {
32
+ readonly allowBoolean: true;
33
+ readonly allowNumber: true;
34
+ }];
34
35
  "oxc/no-async-await": "off";
35
36
  "oxc/no-optional-chaining": "off";
36
- "prefer-default-export": "off";
37
- "sort-imports": "off";
37
+ "oxc/no-rest-spread-properties": "off";
38
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"];
39
+ "import/exports-last": "off";
40
+ "import/group-exports": "off";
41
+ "import/max-dependencies": "off";
42
+ "import/no-named-export": "off";
43
+ "import/no-relative-parent-imports": "off";
44
+ "import/prefer-default-export": "off";
45
+ "eslint/arrow-body-style": ["error", "as-needed"];
46
+ "eslint/complexity": ["error", 5];
47
+ "eslint/curly": ["warn", "all"];
48
+ "eslint/id-length": ["error", {
49
+ readonly exceptions: ["_"];
50
+ readonly min: 2;
51
+ }];
52
+ "eslint/max-depth": ["error", 3];
53
+ "eslint/max-lines": ["error", {
54
+ readonly max: 100;
55
+ }];
56
+ "eslint/max-lines-per-function": ["error", {
57
+ readonly IIFEs: true;
58
+ readonly max: 50;
59
+ readonly skipBlankLines: true;
60
+ readonly skipComments: true;
61
+ }];
62
+ "eslint/max-nested-callbacks": ["error", 3];
63
+ "eslint/max-params": ["warn", 3];
64
+ "eslint/max-statements": ["error", 10];
65
+ "eslint/no-duplicate-imports": ["error", {
66
+ readonly allowSeparateTypeImports: true;
67
+ }];
68
+ "eslint/no-implicit-coercion": ["warn", {
69
+ readonly boolean: true;
70
+ readonly number: true;
71
+ readonly string: true;
72
+ }];
73
+ "eslint/no-inline-comments": "off";
74
+ "eslint/no-magic-numbers": ["warn", {
75
+ readonly ignoreNumericLiteralTypes: true;
76
+ readonly ignoreReadonlyClassProperties: true;
77
+ readonly ignoreTypeIndexes: true;
78
+ }];
79
+ "eslint/no-nested-ternary": "error";
80
+ "eslint/no-param-reassign": ["error", {
81
+ readonly props: true;
82
+ }];
83
+ "eslint/no-ternary": "off";
84
+ "eslint/no-undefined": "off";
85
+ "eslint/no-unneeded-ternary": "error";
86
+ "eslint/no-use-before-define": "error";
87
+ "eslint/no-warning-comments": "off";
88
+ "eslint/one-var": "off";
89
+ "eslint/prefer-named-capture-group": "warn";
90
+ "eslint/require-await": "off";
91
+ "eslint/sort-imports": "off";
92
+ "eslint/sort-keys": ["warn", "asc", {
93
+ readonly allowLineSeparatedGroups: true;
94
+ }];
38
95
  };
39
96
  }[];
40
97
  plugins: ("react" | "react-perf")[];
41
98
  rules: {
42
- "react-in-jsx-scope": "off";
99
+ "react-perf/jsx-no-jsx-as-prop": "off";
100
+ "react-perf/jsx-no-new-array-as-prop": "off";
101
+ "react-perf/jsx-no-new-function-as-prop": "off";
102
+ "react-perf/jsx-no-new-object-as-prop": "off";
43
103
  "react/forbid-component-props": ["error", {
44
- forbid: string[];
104
+ readonly forbid: ["style"];
45
105
  }];
46
106
  "react/function-component-definition": ["error", {
47
- namedComponents: "arrow-function";
107
+ readonly namedComponents: "arrow-function";
48
108
  }];
49
109
  "react/jsx-filename-extension": ["error", {
50
- extensions: string[];
110
+ readonly extensions: ["tsx"];
51
111
  }];
112
+ "react/jsx-fragments": ["error", "element"];
52
113
  "react/jsx-max-depth": ["error", {
53
- max: number;
114
+ readonly max: 5;
54
115
  }];
55
116
  "react/jsx-no-literals": "off";
56
117
  "react/jsx-props-no-spreading": "off";
118
+ "react/react-in-jsx-scope": "off";
57
119
  };
58
120
  };
@@ -1,25 +1,12 @@
1
1
  import { defineConfig } from "oxlint";
2
2
  import { baseConfig } from "../baseConfig/baseConfig.js";
3
+ import { reactPerformanceRules } from "./rules/reactPerformanceRules/reactPerformanceRules.js";
4
+ import { reactRules } from "./rules/reactRules/reactRules.js";
3
5
  export const reactConfig = defineConfig({
4
6
  extends: [baseConfig],
5
7
  plugins: ["react", "react-perf"],
6
8
  rules: {
7
- "react-in-jsx-scope": "off",
8
- "react/forbid-component-props": ["error", { forbid: ["style"] }],
9
- "react/function-component-definition": [
10
- "error",
11
- {
12
- namedComponents: "arrow-function",
13
- },
14
- ],
15
- "react/jsx-filename-extension": [
16
- "error",
17
- {
18
- extensions: ["tsx"],
19
- },
20
- ],
21
- "react/jsx-max-depth": ["error", { max: 5 }],
22
- "react/jsx-no-literals": "off",
23
- "react/jsx-props-no-spreading": "off",
9
+ ...reactRules,
10
+ ...reactPerformanceRules,
24
11
  },
25
12
  });
@@ -0,0 +1,6 @@
1
+ export declare const reactPerformanceRules: {
2
+ "react-perf/jsx-no-jsx-as-prop": "off";
3
+ "react-perf/jsx-no-new-array-as-prop": "off";
4
+ "react-perf/jsx-no-new-function-as-prop": "off";
5
+ "react-perf/jsx-no-new-object-as-prop": "off";
6
+ };
@@ -0,0 +1,8 @@
1
+ import { withRulePrefix } from "../../../../utilities/withRulePrefix/withRulePrefix.js";
2
+ export const reactPerformanceRules = withRulePrefix("react-perf", {
3
+ // メモ化の必要性は実行環境やレンダリングコストに依存するため、一律に強制しない
4
+ "jsx-no-jsx-as-prop": "off",
5
+ "jsx-no-new-array-as-prop": "off",
6
+ "jsx-no-new-function-as-prop": "off",
7
+ "jsx-no-new-object-as-prop": "off",
8
+ });
@@ -0,0 +1,18 @@
1
+ export declare const reactRules: {
2
+ "react/forbid-component-props": ["error", {
3
+ readonly forbid: ["style"];
4
+ }];
5
+ "react/function-component-definition": ["error", {
6
+ readonly namedComponents: "arrow-function";
7
+ }];
8
+ "react/jsx-filename-extension": ["error", {
9
+ readonly extensions: ["tsx"];
10
+ }];
11
+ "react/jsx-fragments": ["error", "element"];
12
+ "react/jsx-max-depth": ["error", {
13
+ readonly max: 5;
14
+ }];
15
+ "react/jsx-no-literals": "off";
16
+ "react/jsx-props-no-spreading": "off";
17
+ "react/react-in-jsx-scope": "off";
18
+ };
@@ -0,0 +1,21 @@
1
+ import { withRulePrefix } from "../../../../utilities/withRulePrefix/withRulePrefix.js";
2
+ export const reactRules = withRulePrefix("react", {
3
+ "forbid-component-props": ["error", { forbid: ["style"] }],
4
+ "function-component-definition": [
5
+ "error",
6
+ {
7
+ namedComponents: "arrow-function",
8
+ },
9
+ ],
10
+ "jsx-filename-extension": [
11
+ "error",
12
+ {
13
+ extensions: ["tsx"],
14
+ },
15
+ ],
16
+ "jsx-fragments": ["error", "element"],
17
+ "jsx-max-depth": ["error", { max: 5 }],
18
+ "jsx-no-literals": "off",
19
+ "jsx-props-no-spreading": "off",
20
+ "react-in-jsx-scope": "off",
21
+ });
@@ -0,0 +1,22 @@
1
+ export declare const storybookConfig: {
2
+ overrides: ({
3
+ files: string[];
4
+ rules: {
5
+ "eslint/prefer-named-capture-group": "off";
6
+ "eslint/require-unicode-regexp": "off";
7
+ "import/no-unassigned-import": "off";
8
+ "import/no-default-export": "off";
9
+ "import/no-nodejs-modules": "off";
10
+ };
11
+ } | {
12
+ files: string[];
13
+ rules: {
14
+ "typescript/restrict-template-expressions": "off";
15
+ "typescript/strict-void-return": "off";
16
+ "import/no-default-export": "off";
17
+ "eslint/max-lines": ["error", 300];
18
+ "eslint/no-magic-numbers": "off";
19
+ "eslint/no-param-reassign": "off";
20
+ };
21
+ })[];
22
+ };
@@ -0,0 +1,38 @@
1
+ import { defineConfig } from "oxlint";
2
+ import { withRulePrefix } from "../../utilities/withRulePrefix/withRulePrefix.js";
3
+ /* oxlint-disable no-magic-numbers */
4
+ export const storybookConfig = defineConfig({
5
+ overrides: [
6
+ {
7
+ files: ["**/.storybook/**"],
8
+ rules: {
9
+ ...withRulePrefix("import", {
10
+ "no-default-export": "off",
11
+ "no-nodejs-modules": "off",
12
+ "no-unassigned-import": "off",
13
+ }),
14
+ ...withRulePrefix("eslint", {
15
+ "prefer-named-capture-group": "off",
16
+ "require-unicode-regexp": "off",
17
+ }),
18
+ },
19
+ },
20
+ {
21
+ files: ["**/*.stories.*"],
22
+ rules: {
23
+ ...withRulePrefix("eslint", {
24
+ "max-lines": ["error", 300],
25
+ "no-magic-numbers": "off",
26
+ "no-param-reassign": "off",
27
+ }),
28
+ ...withRulePrefix("import", {
29
+ "no-default-export": "off",
30
+ }),
31
+ ...withRulePrefix("typescript", {
32
+ "restrict-template-expressions": "off",
33
+ "strict-void-return": "off",
34
+ }),
35
+ },
36
+ },
37
+ ],
38
+ });
@@ -0,0 +1,24 @@
1
+ export declare const vitestConfig: {
2
+ overrides: {
3
+ files: string[];
4
+ rules: {
5
+ "vitest/prefer-importing-vitest-globals": "error";
6
+ "eslint/no-magic-numbers": "off";
7
+ };
8
+ }[];
9
+ plugins: "vitest"[];
10
+ rules: {
11
+ "vitest/prefer-importing-vitest-globals": "off";
12
+ "vitest/no-hooks": "off";
13
+ "vitest/no-importing-vitest-globals": "off";
14
+ "vitest/prefer-expect-assertions": ["error", {
15
+ readonly onlyFunctionsWithAsyncKeyword: true;
16
+ readonly onlyFunctionsWithExpectInCallback: true;
17
+ readonly onlyFunctionsWithExpectInLoop: true;
18
+ }];
19
+ "vitest/require-test-timeout": "off";
20
+ "vitest/valid-title": ["error", {
21
+ readonly allowArguments: true;
22
+ }];
23
+ };
24
+ };
@@ -0,0 +1,35 @@
1
+ import { defineConfig } from "oxlint";
2
+ import { withRulePrefix } from "../../utilities/withRulePrefix/withRulePrefix.js";
3
+ export const vitestConfig = defineConfig({
4
+ overrides: [
5
+ {
6
+ files: ["**/*.{spec,test}.{cjs,cts,js,jsx,mjs,mts,ts,tsx}", "**/spec/**"],
7
+ rules: {
8
+ ...withRulePrefix("eslint", {
9
+ // テストは期待値をハードコーディングするため
10
+ "no-magic-numbers": "off",
11
+ }),
12
+ ...withRulePrefix("vitest", {
13
+ // Storybook の play 関数などで storybook/test から import した expect を誤検知しないよう、vitest のテストファイルに限る
14
+ "prefer-importing-vitest-globals": "error",
15
+ }),
16
+ },
17
+ },
18
+ ],
19
+ plugins: ["vitest"],
20
+ rules: withRulePrefix("vitest", {
21
+ "no-hooks": "off",
22
+ "no-importing-vitest-globals": "off",
23
+ "prefer-expect-assertions": [
24
+ "error",
25
+ {
26
+ onlyFunctionsWithAsyncKeyword: true,
27
+ onlyFunctionsWithExpectInCallback: true,
28
+ onlyFunctionsWithExpectInLoop: true,
29
+ },
30
+ ],
31
+ "prefer-importing-vitest-globals": "off",
32
+ "require-test-timeout": "off",
33
+ "valid-title": ["error", { allowArguments: true }],
34
+ }),
35
+ });
@@ -1 +1,6 @@
1
- export declare const withRulePrefix: <const Prefix extends string, Value>(prefix: Prefix, rules: Record<string, Value>) => Record<`${Prefix}/${string}`, Value>;
1
+ import type { DummyRuleMap } from "oxlint";
2
+ type PrefixedRules<Prefix extends string, Rules extends DummyRuleMap> = {
3
+ [Key in keyof Rules & string as `${Prefix}/${Key}`]: Rules[Key];
4
+ };
5
+ export declare const withRulePrefix: <const Prefix extends string, const Rules extends DummyRuleMap>(prefix: Prefix, rules: Rules) => PrefixedRules<Prefix, Rules>;
6
+ export {};
@@ -3,5 +3,6 @@ export const withRulePrefix = (prefix, rules) => {
3
3
  for (const [name, value] of Object.entries(rules)) {
4
4
  result[`${prefix}/${name}`] = value;
5
5
  }
6
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- TS cannot infer key-remapped mapped types from a loop; the runtime shape is covered by tests
6
7
  return result;
7
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-items/oxlint-config",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "Strict shared oxlint configuration",
5
5
  "homepage": "https://github.com/akky-xxxx/project-ts-items/tree/main/workspaces/packages/configurations/oxlint-config#readme",
6
6
  "bugs": {