@homer0/oxlint-config 1.0.3 → 2.0.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 +92 -20
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/consts.ts +3 -0
- package/src/createConfig.ts +275 -45
- package/src/createNextjsConfig.ts +3 -1
- package/src/index.ts +3 -13
- package/src/rules/base.ts +15 -10
- package/src/rules/index.ts +1 -1
- package/src/types.ts +76 -29
package/src/types.ts
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type globals from 'globals';
|
|
2
|
+
import type { ExtensionFragmentName, TestConvention, ConfigEnv } from './consts.js';
|
|
2
3
|
|
|
3
|
-
export type
|
|
4
|
+
export type RuleSettings = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
export type DangleRuleOptions = {
|
|
7
|
+
allow?: string[];
|
|
8
|
+
allowAfterThis?: boolean;
|
|
9
|
+
allowAfterSuper?: boolean;
|
|
10
|
+
enforceInMethodNames?: boolean;
|
|
11
|
+
};
|
|
4
12
|
|
|
5
|
-
export type
|
|
13
|
+
export type DangleRuleSettings = [unknown, DangleRuleOptions?];
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
/** Controls whether a named global can be reassigned. */
|
|
16
|
+
export type GlobalVarMode = 'readonly' | 'writable' | 'off';
|
|
17
|
+
|
|
18
|
+
/** Adds named globals and `$`-prefixed global groups from the `globals` package. */
|
|
19
|
+
export type GlobalVars = Partial<{
|
|
20
|
+
[K in keyof typeof globals as `$${K}`]: true;
|
|
21
|
+
}> & {
|
|
22
|
+
[key: string]: true | GlobalVarMode;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type ResolvedGlobalVars = Record<string, boolean | string>;
|
|
8
26
|
|
|
9
27
|
/** Adds native Oxlint rules to a generated fragment without replacing its policy. */
|
|
10
28
|
export type ConfigFragment = {
|
|
@@ -17,40 +35,52 @@ export type ExtensionFragments = Partial<Record<ExtensionFragmentName, ConfigFra
|
|
|
17
35
|
/** Selects a test framework-specific native rule policy. */
|
|
18
36
|
export type TestFramework = 'vitest';
|
|
19
37
|
|
|
38
|
+
type TestConfigBaseOptions = {
|
|
39
|
+
env?: ConfigEnv;
|
|
40
|
+
framework?: TestFramework;
|
|
41
|
+
ts?: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
20
44
|
/**
|
|
21
45
|
* Narrows a test override and optionally selects its environment, framework, and
|
|
22
46
|
* TypeScript policy.
|
|
23
47
|
*/
|
|
24
|
-
export type TestConfigOptions = {
|
|
25
|
-
configs?: ConfigName[];
|
|
26
|
-
framework?: TestFramework;
|
|
48
|
+
export type TestConfigOptions = TestConfigBaseOptions & {
|
|
27
49
|
/** Uses a built-in convention or custom glob(s). */
|
|
28
50
|
files?: TestConvention | (string & {}) | string[];
|
|
29
|
-
ts?: boolean;
|
|
30
51
|
};
|
|
31
52
|
|
|
32
53
|
/** Selects both conventions, one built-in convention, or a custom test override. */
|
|
33
54
|
export type TestsOption = boolean | TestConvention | TestConfigOptions;
|
|
34
55
|
|
|
35
|
-
|
|
36
|
-
|
|
56
|
+
type CreateConfigBaseOptions = {
|
|
57
|
+
env: ConfigEnv;
|
|
58
|
+
allowedDangleNames?: string[];
|
|
37
59
|
extensions?: ExtensionFragments;
|
|
60
|
+
globals?: GlobalVars;
|
|
38
61
|
ignores?: string[];
|
|
39
|
-
/** Enables the native subset of JSDoc policy. */
|
|
40
62
|
jsdoc?: boolean;
|
|
41
|
-
tests?: TestsOption;
|
|
42
|
-
/** Defaults to `true`. */
|
|
43
63
|
ts?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Enables Oxlint's root-only type-aware mode. Requires oxlint-tsgolint and TypeScript
|
|
46
|
-
* 7+.
|
|
47
|
-
*/
|
|
48
|
-
typeAware?: boolean;
|
|
49
64
|
};
|
|
50
65
|
|
|
51
|
-
export type
|
|
66
|
+
export type TestConfigOverrideOptions = TestConfigBaseOptions & {
|
|
67
|
+
files: string | string[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type ConfigOverrideOptions = {
|
|
71
|
+
files: string | string[];
|
|
72
|
+
rules?: RuleSettings;
|
|
73
|
+
tests?: TestConfigOverrideOptions;
|
|
74
|
+
} & Partial<CreateConfigBaseOptions>;
|
|
52
75
|
|
|
53
|
-
export type
|
|
76
|
+
export type CreateConfigOptions = CreateConfigBaseOptions & {
|
|
77
|
+
tests?: TestsOption;
|
|
78
|
+
overrides?: RuleSettings | Array<ConfigOverrideOptions | RuleSettings>;
|
|
79
|
+
/** Enables Oxlint's root-only type-aware mode. Requires oxlint-tsgolint and TS 7+ */
|
|
80
|
+
typeAware?: boolean;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type CreateNextjsConfigOptions = Omit<CreateConfigOptions, 'env' | 'ts'>;
|
|
54
84
|
|
|
55
85
|
export type CreateConfigSettings = CreateConfigOptions & {
|
|
56
86
|
nextjs?: boolean;
|
|
@@ -58,27 +88,28 @@ export type CreateConfigSettings = CreateConfigOptions & {
|
|
|
58
88
|
};
|
|
59
89
|
|
|
60
90
|
export type ResolveTestConfigOptions = {
|
|
61
|
-
tests: TestsOption
|
|
62
|
-
|
|
91
|
+
tests: Exclude<TestsOption, false>;
|
|
92
|
+
productionEnv: ConfigEnv;
|
|
63
93
|
productionTs: boolean;
|
|
64
94
|
};
|
|
65
95
|
|
|
66
96
|
export type ResolvedTestConfig = {
|
|
67
|
-
|
|
97
|
+
env: ConfigEnv;
|
|
68
98
|
files: string[];
|
|
69
99
|
framework?: TestFramework;
|
|
70
100
|
ts: boolean;
|
|
71
101
|
};
|
|
72
102
|
|
|
73
103
|
export type GeneratedConfigOverride = {
|
|
104
|
+
excludeFiles?: string[];
|
|
74
105
|
files: string[];
|
|
75
|
-
globals:
|
|
106
|
+
globals: ResolvedGlobalVars;
|
|
76
107
|
rules: RuleSettings;
|
|
77
108
|
};
|
|
78
109
|
|
|
79
110
|
/** Native Oxlint configuration generated by this package's factories. */
|
|
80
111
|
export type GeneratedConfig = {
|
|
81
|
-
globals:
|
|
112
|
+
globals: ResolvedGlobalVars;
|
|
82
113
|
ignorePatterns?: string[];
|
|
83
114
|
options?: {
|
|
84
115
|
typeAware: true;
|
|
@@ -89,27 +120,43 @@ export type GeneratedConfig = {
|
|
|
89
120
|
};
|
|
90
121
|
|
|
91
122
|
export type CreateTestOverrideOptions = {
|
|
123
|
+
parentEnv: ConfigEnv;
|
|
92
124
|
testConfig: ResolvedTestConfig;
|
|
125
|
+
allowedDangleNames?: string[];
|
|
126
|
+
extraRules?: RuleSettings[];
|
|
93
127
|
extensions?: ExtensionFragments;
|
|
128
|
+
globals?: GlobalVars | ResolvedGlobalVars;
|
|
94
129
|
};
|
|
95
130
|
|
|
96
|
-
export type ResolveConfigComponentsOptions = CreateConfigSettings & {
|
|
131
|
+
export type ResolveConfigComponentsOptions = Omit<CreateConfigSettings, 'globals'> & {
|
|
97
132
|
testConfig?: ResolvedTestConfig;
|
|
98
133
|
baseFragment?: ConfigFragment;
|
|
99
134
|
baseExtensionFragment?: ConfigFragment;
|
|
135
|
+
globals?: GlobalVars | ResolvedGlobalVars;
|
|
100
136
|
};
|
|
101
137
|
|
|
102
138
|
export type ResolveTestConfigComponentsOptions = {
|
|
103
|
-
|
|
139
|
+
env: ConfigEnv;
|
|
104
140
|
testConfig?: ResolvedTestConfig;
|
|
105
141
|
tests?: TestsOption;
|
|
106
142
|
ts?: boolean;
|
|
107
143
|
};
|
|
108
144
|
|
|
145
|
+
export type ResolveTestConfigComponentsResult = {
|
|
146
|
+
doingTestsSetup: boolean;
|
|
147
|
+
testConfig?: ResolvedTestConfig;
|
|
148
|
+
};
|
|
149
|
+
|
|
109
150
|
export type ResolveConfigComponentsResult = {
|
|
110
|
-
|
|
151
|
+
env: ConfigEnv;
|
|
152
|
+
globals: ResolvedGlobalVars;
|
|
111
153
|
testConfig?: ResolvedTestConfig;
|
|
112
154
|
fragments: ConfigFragment[];
|
|
113
155
|
plugins: string[];
|
|
114
|
-
configGlobals?:
|
|
156
|
+
configGlobals?: ResolvedGlobalVars;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export type ResolveGlobalsOptions = {
|
|
160
|
+
globals?: GlobalVars | ResolvedGlobalVars;
|
|
161
|
+
doingTestsSetup?: boolean;
|
|
115
162
|
};
|