@homer0/oxlint-config 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.
@@ -0,0 +1,20 @@
1
+ export const tests = {
2
+ /**
3
+ * Enforce a maximum number of classes per file.
4
+ *
5
+ * @see https://eslint.org/docs/latest/rules/max-classes-per-file
6
+ */
7
+ 'max-classes-per-file': 'off',
8
+ /**
9
+ * Disallow magic numbers.
10
+ *
11
+ * @see https://eslint.org/docs/latest/rules/no-magic-numbers
12
+ */
13
+ 'no-magic-numbers': 'off',
14
+ /**
15
+ * Ensure all imports appear before other statements.
16
+ *
17
+ * @see https://github.com/un-ts/eslint-plugin-import-x/blob/v4.17.1/docs/rules/first.md
18
+ */
19
+ 'import/first': 'off',
20
+ } as const;
@@ -0,0 +1,20 @@
1
+ export const typeAware = {
2
+ /**
3
+ * Disallow use of APIs marked as deprecated by TypeScript declarations.
4
+ *
5
+ * @see https://typescript-eslint.io/rules/no-deprecated
6
+ */
7
+ 'typescript/no-deprecated': 'error',
8
+ /**
9
+ * Require promises to be awaited, returned, or explicitly ignored.
10
+ *
11
+ * @see https://typescript-eslint.io/rules/no-floating-promises
12
+ */
13
+ 'typescript/no-floating-promises': 'error',
14
+ /**
15
+ * Disallow promises in places that expect synchronous values or callbacks.
16
+ *
17
+ * @see https://typescript-eslint.io/rules/no-misused-promises
18
+ */
19
+ 'typescript/no-misused-promises': 'error',
20
+ } as const;
@@ -0,0 +1,178 @@
1
+ export const typescript = {
2
+ /**
3
+ * Disallow `@ts-<directive>` comments or require descriptions after directives.
4
+ *
5
+ * @see https://typescript-eslint.io/rules/ban-ts-comment
6
+ */
7
+ 'typescript/ban-ts-comment': [
8
+ 'error',
9
+ {
10
+ 'ts-expect-error': 'allow-with-description',
11
+ 'ts-ignore': 'allow-with-description',
12
+ 'ts-nocheck': 'allow-with-description',
13
+ 'ts-check': 'allow-with-description',
14
+ },
15
+ ],
16
+ /**
17
+ * Disallow `Array` constructors in favor of array literals.
18
+ *
19
+ * @see https://typescript-eslint.io/rules/no-array-constructor
20
+ */
21
+ 'typescript/no-array-constructor': 'error',
22
+ /**
23
+ * Disallow duplicate values in TypeScript enums.
24
+ *
25
+ * @see https://typescript-eslint.io/rules/no-duplicate-enum-values
26
+ */
27
+ 'typescript/no-duplicate-enum-values': 'error',
28
+ /**
29
+ * Disallow the empty object type.
30
+ *
31
+ * @see https://typescript-eslint.io/rules/no-empty-object-type
32
+ */
33
+ 'typescript/no-empty-object-type': 'error',
34
+ /**
35
+ * Disallow the `any` type.
36
+ *
37
+ * @see https://typescript-eslint.io/rules/no-explicit-any
38
+ */
39
+ 'typescript/no-explicit-any': 'error',
40
+ /**
41
+ * Disallow unnecessary non-null assertions.
42
+ *
43
+ * @see https://typescript-eslint.io/rules/no-extra-non-null-assertion
44
+ */
45
+ 'typescript/no-extra-non-null-assertion': 'error',
46
+ /**
47
+ * Disallow classes that are used as namespaces.
48
+ *
49
+ * @see https://typescript-eslint.io/rules/no-misused-new
50
+ */
51
+ 'typescript/no-misused-new': 'error',
52
+ /**
53
+ * Disallow TypeScript namespaces.
54
+ *
55
+ * @see https://typescript-eslint.io/rules/no-namespace
56
+ */
57
+ 'typescript/no-namespace': 'error',
58
+ /**
59
+ * Disallow non-null assertions after optional chains.
60
+ *
61
+ * @see https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain
62
+ */
63
+ 'typescript/no-non-null-asserted-optional-chain': 'error',
64
+ /**
65
+ * Disallow CommonJS `require()` imports.
66
+ *
67
+ * @see https://typescript-eslint.io/rules/no-require-imports
68
+ */
69
+ 'typescript/no-require-imports': 'error',
70
+ /**
71
+ * Disallow assigning `this` to another variable.
72
+ *
73
+ * @see https://typescript-eslint.io/rules/no-this-alias
74
+ */
75
+ 'typescript/no-this-alias': 'error',
76
+ /**
77
+ * Disallow unnecessary type constraints.
78
+ *
79
+ * @see https://typescript-eslint.io/rules/no-unnecessary-type-constraint
80
+ */
81
+ 'typescript/no-unnecessary-type-constraint': 'error',
82
+ /**
83
+ * Disallow unsafe declaration merging.
84
+ *
85
+ * @see https://typescript-eslint.io/rules/no-unsafe-declaration-merging
86
+ */
87
+ 'typescript/no-unsafe-declaration-merging': 'error',
88
+ /**
89
+ * Disallow unsafe built-in function types.
90
+ *
91
+ * @see https://typescript-eslint.io/rules/no-unsafe-function-type
92
+ */
93
+ 'typescript/no-unsafe-function-type': 'error',
94
+ /**
95
+ * Disallow unused expressions.
96
+ *
97
+ * @see https://typescript-eslint.io/rules/no-unused-expressions
98
+ */
99
+ 'typescript/no-unused-expressions': 'error',
100
+ /**
101
+ * Disallow unused variables.
102
+ *
103
+ * @see https://typescript-eslint.io/rules/no-unused-vars
104
+ */
105
+ 'typescript/no-unused-vars': 'error',
106
+ /**
107
+ * Disallow object-wrapper types.
108
+ *
109
+ * @see https://typescript-eslint.io/rules/no-wrapper-object-types
110
+ */
111
+ 'typescript/no-wrapper-object-types': 'error',
112
+ /**
113
+ * Require `as const` assertions for literal types.
114
+ *
115
+ * @see https://typescript-eslint.io/rules/prefer-as-const
116
+ */
117
+ 'typescript/prefer-as-const': 'error',
118
+ /**
119
+ * Require `namespace` instead of `module` declarations.
120
+ *
121
+ * @see https://typescript-eslint.io/rules/prefer-namespace-keyword
122
+ */
123
+ 'typescript/prefer-namespace-keyword': 'error',
124
+ /**
125
+ * Disallow triple-slash reference directives.
126
+ *
127
+ * @see https://typescript-eslint.io/rules/triple-slash-reference
128
+ */
129
+ 'typescript/triple-slash-reference': 'error',
130
+ /**
131
+ * Enforce dot notation whenever possible.
132
+ *
133
+ * @see https://typescript-eslint.io/rules/dot-notation
134
+ */
135
+ 'typescript/dot-notation': 'error',
136
+ /**
137
+ * Let the TypeScript-specific rule enforce array constructor usage.
138
+ *
139
+ * @see https://eslint.org/docs/latest/rules/no-array-constructor
140
+ */
141
+ 'no-array-constructor': 'off',
142
+ /**
143
+ * Allow empty functions for interface implementations and placeholders.
144
+ *
145
+ * @see https://eslint.org/docs/latest/rules/no-empty-function
146
+ */
147
+ 'no-empty-function': 'off',
148
+ /**
149
+ * Let the TypeScript-specific rule enforce dot notation.
150
+ *
151
+ * @see https://eslint.org/docs/latest/rules/dot-notation
152
+ */
153
+ 'dot-notation': 'off',
154
+ /**
155
+ * Let the TypeScript-specific rule detect unused expressions.
156
+ *
157
+ * @see https://eslint.org/docs/latest/rules/no-unused-expressions
158
+ */
159
+ 'no-unused-expressions': 'off',
160
+ /**
161
+ * Let the TypeScript-specific rule detect unused variables.
162
+ *
163
+ * @see https://eslint.org/docs/latest/rules/no-unused-vars
164
+ */
165
+ 'no-unused-vars': 'off',
166
+ /**
167
+ * Allow constructors that TypeScript requires for parameter properties.
168
+ *
169
+ * @see https://eslint.org/docs/latest/rules/no-useless-constructor
170
+ */
171
+ 'no-useless-constructor': 'off',
172
+ /**
173
+ * Ensure consistent use of file extension within the import path.
174
+ *
175
+ * @see https://github.com/un-ts/eslint-plugin-import-x/blob/v4.17.1/docs/rules/extensions.md
176
+ */
177
+ 'import/extensions': 'off',
178
+ } as const;
@@ -0,0 +1,44 @@
1
+ export const vitest = {
2
+ /**
3
+ * Disallow focused tests committed with `.only`.
4
+ *
5
+ * @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
6
+ */
7
+ 'vitest/no-focused-tests': 'error',
8
+ /**
9
+ * Disallow disabled tests committed with `.skip`.
10
+ *
11
+ * @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
12
+ */
13
+ 'vitest/no-disabled-tests': 'error',
14
+ /**
15
+ * Require unique test titles within a suite.
16
+ *
17
+ * @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
18
+ */
19
+ 'vitest/no-identical-title': 'error',
20
+ /**
21
+ * Disallow assertions that execute only in conditional branches.
22
+ *
23
+ * @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
24
+ */
25
+ 'vitest/no-conditional-expect': 'error',
26
+ /**
27
+ * Disallow assertions outside a test or hook callback.
28
+ *
29
+ * @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
30
+ */
31
+ 'vitest/no-standalone-expect': 'error',
32
+ /**
33
+ * Allow mock factories without explicit type parameters.
34
+ *
35
+ * @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-mock-type-parameters.md
36
+ */
37
+ 'vitest/require-mock-type-parameters': 'off',
38
+ /**
39
+ * Validate assertion matchers and their arguments.
40
+ *
41
+ * @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
42
+ */
43
+ 'vitest/valid-expect': 'error',
44
+ } as const;
package/src/types.ts ADDED
@@ -0,0 +1,109 @@
1
+ import type { ExtensionFragmentName, TestConvention } from './consts.js';
2
+
3
+ export type { ExtensionFragmentName } from './consts.js';
4
+
5
+ export type ConfigName = 'browser' | 'node';
6
+
7
+ export type RuleSettings = Record<string, unknown>;
8
+
9
+ /** Adds native Oxlint rules to a generated fragment without replacing its policy. */
10
+ export type ConfigFragment = {
11
+ rules?: RuleSettings;
12
+ };
13
+
14
+ /** Overrides are keyed by the generated fragment they extend. */
15
+ export type ExtensionFragments = Partial<Record<ExtensionFragmentName, ConfigFragment>>;
16
+
17
+ /** Selects a test framework-specific native rule policy. */
18
+ export type TestFramework = 'vitest';
19
+
20
+ /** Narrows a test override and optionally selects its environment, framework, and TypeScript policy. */
21
+ export type TestConfigOptions = {
22
+ configs?: ConfigName[];
23
+ framework?: TestFramework;
24
+ /** Uses a built-in convention or custom glob(s). */
25
+ files?: TestConvention | (string & {}) | string[];
26
+ ts?: boolean;
27
+ };
28
+
29
+ /** Selects both conventions, one built-in convention, or a custom test override. */
30
+ export type TestsOption = boolean | TestConvention | TestConfigOptions;
31
+
32
+ export type CreateConfigOptions = {
33
+ configs: ConfigName[];
34
+ extensions?: ExtensionFragments;
35
+ ignores?: string[];
36
+ /** Enables the native subset of JSDoc policy. */
37
+ jsdoc?: boolean;
38
+ tests?: TestsOption;
39
+ /** Defaults to `true`. */
40
+ ts?: boolean;
41
+ /** Enables Oxlint's root-only type-aware mode. Requires oxlint-tsgolint and TypeScript 7+. */
42
+ typeAware?: boolean;
43
+ };
44
+
45
+ export type CreateReactConfigOptions = CreateConfigOptions;
46
+
47
+ export type CreateNextjsConfigOptions = Omit<CreateConfigOptions, 'configs' | 'ts'>;
48
+
49
+ export type CreateConfigSettings = CreateConfigOptions & {
50
+ nextjs?: boolean;
51
+ react?: boolean;
52
+ };
53
+
54
+ export type ResolveTestConfigOptions = {
55
+ tests: TestsOption | undefined;
56
+ productionConfig: ConfigName;
57
+ productionTs: boolean;
58
+ };
59
+
60
+ export type ResolvedTestConfig = {
61
+ configs: ConfigName[];
62
+ files: string[];
63
+ framework?: TestFramework;
64
+ ts: boolean;
65
+ };
66
+
67
+ export type GeneratedConfigOverride = {
68
+ files: string[];
69
+ globals: Record<string, boolean | string>;
70
+ rules: RuleSettings;
71
+ };
72
+
73
+ /** Native Oxlint configuration generated by this package's factories. */
74
+ export type GeneratedConfig = {
75
+ globals: Record<string, boolean | string>;
76
+ ignorePatterns?: string[];
77
+ options?: {
78
+ typeAware: true;
79
+ };
80
+ overrides?: GeneratedConfigOverride[];
81
+ plugins: string[];
82
+ rules: RuleSettings;
83
+ };
84
+
85
+ export type CreateTestOverrideOptions = {
86
+ testConfig: ResolvedTestConfig;
87
+ extensions?: ExtensionFragments;
88
+ };
89
+
90
+ export type ResolveConfigComponentsOptions = CreateConfigSettings & {
91
+ testConfig?: ResolvedTestConfig;
92
+ baseFragment?: ConfigFragment;
93
+ baseExtensionFragment?: ConfigFragment;
94
+ };
95
+
96
+ export type ResolveTestConfigComponentsOptions = {
97
+ config: ConfigName;
98
+ testConfig?: ResolvedTestConfig;
99
+ tests?: TestsOption;
100
+ ts?: boolean;
101
+ };
102
+
103
+ export type ResolveConfigComponentsResult = {
104
+ config: ConfigName;
105
+ testConfig?: ResolvedTestConfig;
106
+ fragments: ConfigFragment[];
107
+ plugins: string[];
108
+ configGlobals?: Record<string, boolean | string>;
109
+ };