@ts-items/oxlint-config 0.0.1-alpha.1 → 0.1.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/README.md CHANGED
@@ -43,3 +43,31 @@ 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
+ ```
@@ -34,5 +34,50 @@ export declare const baseConfig: {
34
34
  "oxc/no-optional-chaining": "off";
35
35
  "prefer-default-export": "off";
36
36
  "sort-imports": "off";
37
+ "unicorn/no-array-callback-reference": "off";
38
+ "unicorn/no-array-reduce": "off";
39
+ "unicorn/no-immediate-mutation": "off";
40
+ "typescript/require-await": "error";
41
+ "typescript/prefer-readonly-parameter-types": "off";
42
+ "typescript/promise-function-async": "error";
43
+ "typescript/restrict-template-expressions": ["error", {
44
+ readonly allowBoolean: true;
45
+ readonly allowNumber: true;
46
+ }];
47
+ "eslint/arrow-body-style": ["error", "as-needed"];
48
+ "eslint/complexity": ["error", 5];
49
+ "eslint/curly": ["warn", "all"];
50
+ "eslint/id-length": ["error", {
51
+ readonly exceptions: ["_"];
52
+ readonly min: 2;
53
+ }];
54
+ "eslint/max-depth": ["error", 3];
55
+ "eslint/max-lines": ["error", {
56
+ readonly max: 100;
57
+ }];
58
+ "eslint/max-lines-per-function": ["error", {
59
+ readonly IIFEs: true;
60
+ readonly max: 50;
61
+ readonly skipBlankLines: true;
62
+ readonly skipComments: true;
63
+ }];
64
+ "eslint/max-nested-callbacks": ["error", 3];
65
+ "eslint/max-params": ["warn", 3];
66
+ "eslint/max-statements": ["error", 10];
67
+ "eslint/no-implicit-coercion": ["warn", {
68
+ readonly boolean: true;
69
+ readonly number: true;
70
+ readonly string: true;
71
+ }];
72
+ "eslint/no-magic-numbers": "warn";
73
+ "eslint/no-param-reassign": ["error", {
74
+ readonly props: true;
75
+ }];
76
+ "eslint/no-use-before-define": "error";
77
+ "eslint/prefer-named-capture-group": "warn";
78
+ "eslint/require-await": "off";
79
+ "eslint/sort-keys": ["warn", "asc", {
80
+ readonly allowLineSeparatedGroups: true;
81
+ }];
37
82
  };
38
83
  };
@@ -1,16 +1,37 @@
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-implicit-coercion": ["warn", {
23
+ readonly boolean: true;
24
+ readonly number: true;
25
+ readonly string: true;
26
+ }];
27
+ "eslint/no-magic-numbers": "warn";
28
+ "eslint/no-param-reassign": ["error", {
29
+ readonly props: true;
30
+ }];
31
+ "eslint/no-use-before-define": "error";
32
+ "eslint/prefer-named-capture-group": "warn";
33
+ "eslint/require-await": "off";
34
+ "eslint/sort-keys": ["warn", "asc", {
35
+ readonly allowLineSeparatedGroups: true;
36
+ }];
37
+ };
@@ -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": [
@@ -1 +1,9 @@
1
- export declare const typescriptRules: Record<`typescript/${string}`, "off" | "error">;
1
+ export declare const typescriptRules: {
2
+ "typescript/require-await": "error";
3
+ "typescript/prefer-readonly-parameter-types": "off";
4
+ "typescript/promise-function-async": "error";
5
+ "typescript/restrict-template-expressions": ["error", {
6
+ readonly allowBoolean: true;
7
+ readonly allowNumber: true;
8
+ }];
9
+ };
@@ -3,4 +3,5 @@ export const typescriptRules = withRulePrefix("typescript", {
3
3
  "prefer-readonly-parameter-types": "off",
4
4
  "promise-function-async": "error",
5
5
  "require-await": "error",
6
+ "restrict-template-expressions": ["error", { allowBoolean: true, allowNumber: true }],
6
7
  });
@@ -1 +1,5 @@
1
- export declare const unicornRules: Record<`unicorn/${string}`, "off">;
1
+ export declare const unicornRules: {
2
+ "unicorn/no-array-callback-reference": "off";
3
+ "unicorn/no-array-reduce": "off";
4
+ "unicorn/no-immediate-mutation": "off";
5
+ };
@@ -1,2 +1,4 @@
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";
@@ -1,2 +1,4 @@
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";
@@ -0,0 +1,137 @@
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
+ plugins: ("eslint" | "unicorn" | "oxc" | "import")[];
14
+ rules: {
15
+ "explicit-function-return-type": "off";
16
+ "explicit-module-boundary-types": "off";
17
+ "exports-last": "off";
18
+ "filename-case": "off";
19
+ "group-exports": "off";
20
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"];
21
+ "import/no-relative-parent-imports": "off";
22
+ "no-duplicate-imports": ["error", {
23
+ allowSeparateTypeImports: true;
24
+ }];
25
+ "no-inline-comments": "off";
26
+ "no-named-export": "off";
27
+ "no-nested-ternary": "error";
28
+ "no-null": "off";
29
+ "no-rest-spread-properties": "off";
30
+ "no-ternary": "off";
31
+ "no-undefined": "off";
32
+ "no-unneeded-ternary": "error";
33
+ "no-warning-comments": "off";
34
+ "one-var": "off";
35
+ "oxc/no-async-await": "off";
36
+ "oxc/no-optional-chaining": "off";
37
+ "prefer-default-export": "off";
38
+ "sort-imports": "off";
39
+ "unicorn/no-array-callback-reference": "off";
40
+ "unicorn/no-array-reduce": "off";
41
+ "unicorn/no-immediate-mutation": "off";
42
+ "typescript/require-await": "error";
43
+ "typescript/prefer-readonly-parameter-types": "off";
44
+ "typescript/promise-function-async": "error";
45
+ "typescript/restrict-template-expressions": ["error", {
46
+ readonly allowBoolean: true;
47
+ readonly allowNumber: true;
48
+ }];
49
+ "eslint/arrow-body-style": ["error", "as-needed"];
50
+ "eslint/complexity": ["error", 5];
51
+ "eslint/curly": ["warn", "all"];
52
+ "eslint/id-length": ["error", {
53
+ readonly exceptions: ["_"];
54
+ readonly min: 2;
55
+ }];
56
+ "eslint/max-depth": ["error", 3];
57
+ "eslint/max-lines": ["error", {
58
+ readonly max: 100;
59
+ }];
60
+ "eslint/max-lines-per-function": ["error", {
61
+ readonly IIFEs: true;
62
+ readonly max: 50;
63
+ readonly skipBlankLines: true;
64
+ readonly skipComments: true;
65
+ }];
66
+ "eslint/max-nested-callbacks": ["error", 3];
67
+ "eslint/max-params": ["warn", 3];
68
+ "eslint/max-statements": ["error", 10];
69
+ "eslint/no-implicit-coercion": ["warn", {
70
+ readonly boolean: true;
71
+ readonly number: true;
72
+ readonly string: true;
73
+ }];
74
+ "eslint/no-magic-numbers": "warn";
75
+ "eslint/no-param-reassign": ["error", {
76
+ readonly props: true;
77
+ }];
78
+ "eslint/no-use-before-define": "error";
79
+ "eslint/prefer-named-capture-group": "warn";
80
+ "eslint/require-await": "off";
81
+ "eslint/sort-keys": ["warn", "asc", {
82
+ readonly allowLineSeparatedGroups: true;
83
+ }];
84
+ };
85
+ }[];
86
+ plugins: ("react" | "react-perf")[];
87
+ rules: {
88
+ "react-in-jsx-scope": "off";
89
+ "react/forbid-component-props": ["error", {
90
+ forbid: string[];
91
+ }];
92
+ "react/function-component-definition": ["error", {
93
+ namedComponents: "arrow-function";
94
+ }];
95
+ "react/jsx-filename-extension": ["error", {
96
+ extensions: string[];
97
+ }];
98
+ "react/jsx-fragments": ["error", "element"];
99
+ "react/jsx-max-depth": ["error", {
100
+ max: number;
101
+ }];
102
+ "react/jsx-no-literals": "off";
103
+ "react/jsx-props-no-spreading": "off";
104
+ };
105
+ }[];
106
+ ignorePatterns: string[];
107
+ overrides: ({
108
+ files: never[];
109
+ rules: {
110
+ "import/no-unassigned-import": "off";
111
+ };
112
+ } | {
113
+ files: string[];
114
+ rules: {
115
+ "react/only-export-components": ["error", {
116
+ readonly allowExportNames: ["dynamic", "generateMetadata", "generateStaticParams", "metadata", "revalidate"];
117
+ }];
118
+ "import/no-default-export": "off";
119
+ };
120
+ } | {
121
+ files: string[];
122
+ rules: {
123
+ "oxc/no-async-await": "off";
124
+ "import/no-unassigned-import": ["error", {
125
+ readonly allow: ["**/*.css"];
126
+ }];
127
+ "import/no-default-export": "off";
128
+ "eslint/new-cap": "off";
129
+ };
130
+ } | {
131
+ files: string[];
132
+ rules: {
133
+ "import/no-default-export": "off";
134
+ };
135
+ })[];
136
+ plugins: "nextjs"[];
137
+ };
@@ -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
+ });
@@ -35,6 +35,51 @@ export declare const reactConfig: {
35
35
  "oxc/no-optional-chaining": "off";
36
36
  "prefer-default-export": "off";
37
37
  "sort-imports": "off";
38
+ "unicorn/no-array-callback-reference": "off";
39
+ "unicorn/no-array-reduce": "off";
40
+ "unicorn/no-immediate-mutation": "off";
41
+ "typescript/require-await": "error";
42
+ "typescript/prefer-readonly-parameter-types": "off";
43
+ "typescript/promise-function-async": "error";
44
+ "typescript/restrict-template-expressions": ["error", {
45
+ readonly allowBoolean: true;
46
+ readonly allowNumber: true;
47
+ }];
48
+ "eslint/arrow-body-style": ["error", "as-needed"];
49
+ "eslint/complexity": ["error", 5];
50
+ "eslint/curly": ["warn", "all"];
51
+ "eslint/id-length": ["error", {
52
+ readonly exceptions: ["_"];
53
+ readonly min: 2;
54
+ }];
55
+ "eslint/max-depth": ["error", 3];
56
+ "eslint/max-lines": ["error", {
57
+ readonly max: 100;
58
+ }];
59
+ "eslint/max-lines-per-function": ["error", {
60
+ readonly IIFEs: true;
61
+ readonly max: 50;
62
+ readonly skipBlankLines: true;
63
+ readonly skipComments: true;
64
+ }];
65
+ "eslint/max-nested-callbacks": ["error", 3];
66
+ "eslint/max-params": ["warn", 3];
67
+ "eslint/max-statements": ["error", 10];
68
+ "eslint/no-implicit-coercion": ["warn", {
69
+ readonly boolean: true;
70
+ readonly number: true;
71
+ readonly string: true;
72
+ }];
73
+ "eslint/no-magic-numbers": "warn";
74
+ "eslint/no-param-reassign": ["error", {
75
+ readonly props: true;
76
+ }];
77
+ "eslint/no-use-before-define": "error";
78
+ "eslint/prefer-named-capture-group": "warn";
79
+ "eslint/require-await": "off";
80
+ "eslint/sort-keys": ["warn", "asc", {
81
+ readonly allowLineSeparatedGroups: true;
82
+ }];
38
83
  };
39
84
  }[];
40
85
  plugins: ("react" | "react-perf")[];
@@ -49,6 +94,7 @@ export declare const reactConfig: {
49
94
  "react/jsx-filename-extension": ["error", {
50
95
  extensions: string[];
51
96
  }];
97
+ "react/jsx-fragments": ["error", "element"];
52
98
  "react/jsx-max-depth": ["error", {
53
99
  max: number;
54
100
  }];
@@ -18,6 +18,7 @@ export const reactConfig = defineConfig({
18
18
  extensions: ["tsx"],
19
19
  },
20
20
  ],
21
+ "react/jsx-fragments": ["error", "element"],
21
22
  "react/jsx-max-depth": ["error", { max: 5 }],
22
23
  "react/jsx-no-literals": "off",
23
24
  "react/jsx-props-no-spreading": "off",
@@ -0,0 +1,21 @@
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/no-magic-numbers": "off";
18
+ "eslint/no-param-reassign": "off";
19
+ };
20
+ })[];
21
+ };
@@ -0,0 +1,36 @@
1
+ import { defineConfig } from "oxlint";
2
+ import { withRulePrefix } from "../../utilities/withRulePrefix/withRulePrefix.js";
3
+ export const storybookConfig = defineConfig({
4
+ overrides: [
5
+ {
6
+ files: ["**/.storybook/**"],
7
+ rules: {
8
+ ...withRulePrefix("import", {
9
+ "no-default-export": "off",
10
+ "no-nodejs-modules": "off",
11
+ "no-unassigned-import": "off",
12
+ }),
13
+ ...withRulePrefix("eslint", {
14
+ "prefer-named-capture-group": "off",
15
+ "require-unicode-regexp": "off",
16
+ }),
17
+ },
18
+ },
19
+ {
20
+ files: ["**/*.stories.*"],
21
+ rules: {
22
+ ...withRulePrefix("eslint", {
23
+ "no-magic-numbers": "off",
24
+ "no-param-reassign": "off",
25
+ }),
26
+ ...withRulePrefix("import", {
27
+ "no-default-export": "off",
28
+ }),
29
+ ...withRulePrefix("typescript", {
30
+ "restrict-template-expressions": "off",
31
+ "strict-void-return": "off",
32
+ }),
33
+ },
34
+ },
35
+ ],
36
+ });
@@ -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-alpha.1",
3
+ "version": "0.1.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": {
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "build": "tsc -p tsconfig.build.json",
27
- "check-code": "run-p lint test -c --aggregate-output",
27
+ "check-code": "run-s test lint -c",
28
28
  "fix": "run-p fix:* -c --aggregate-output",
29
29
  "fix:oxfmt": "oxfmt -c ./oxfmt.config.mts",
30
30
  "fix:oxlint": "bun lint:oxlint --fix",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@ts-items/configurations": "0.0.0",
44
- "@ts-items/oxfmt-config": "0.0.1-alpha.1",
44
+ "@ts-items/oxfmt-config": "0.0.1",
45
45
  "@tsconfig/strictest": "2.0.8",
46
46
  "@types/bun": "1.4.4",
47
47
  "cspell": "10.4.0",