oxlint 1.75.0 → 1.77.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/configuration_schema.json +329 -18
- package/dist/bindings.js +96 -42
- package/dist/index.d.ts +195 -13
- package/dist/lint.js +272 -142
- package/dist/plugins-dev.d.ts +1 -1
- package/dist/plugins-dev.js +15 -15
- package/dist/plugins.js +1 -1
- package/dist/workspace2.js +2 -1
- package/package.json +20 -20
package/dist/index.d.ts
CHANGED
|
@@ -88,8 +88,8 @@ type MaxDependenciesConfigJson = number | MaxDependenciesConfig;
|
|
|
88
88
|
type Target = "single" | "any";
|
|
89
89
|
type TestCaseName = "it" | "test";
|
|
90
90
|
type JestFnType = "hook" | "describe" | "test" | "expect" | "jest" | "unknown";
|
|
91
|
-
type DummyRule = AllowWarnDeny | [AllowWarnDeny, ...unknown[]];
|
|
92
91
|
type SnapshotHintMode = "always" | "multi";
|
|
92
|
+
type DummyRule = AllowWarnDeny | [AllowWarnDeny, ...unknown[]];
|
|
93
93
|
type AltTextElements = "img" | "object" | "area" | 'input[type="image"]';
|
|
94
94
|
type AnchorIsValidAspect = "noHref" | "invalidHref" | "preferButton";
|
|
95
95
|
type Assert = "htmlFor" | "nesting" | "both" | "either";
|
|
@@ -116,6 +116,8 @@ type NoInnerDeclarationsConfig = "functions" | "both";
|
|
|
116
116
|
type BlockScopedFunctions = "allow" | "disallow";
|
|
117
117
|
type Namespaces = "allow" | "disallow";
|
|
118
118
|
type NoMagicNumbersNumber = number | string;
|
|
119
|
+
type NoRestrictedGlobalsConfigEnum = string | RestrictedGlobal | NoRestrictedGlobalsObjectConfig;
|
|
120
|
+
type GlobalNameOrObject = string | RestrictedGlobal;
|
|
119
121
|
type NoRestrictedImportsConfigEnum = string | RestrictedPath | NoRestrictedImportsConfig;
|
|
120
122
|
type PossiblePaths = string | RestrictedPath;
|
|
121
123
|
type PossiblePatterns = string | RestrictedPattern;
|
|
@@ -138,6 +140,7 @@ type Location = "start" | "anywhere";
|
|
|
138
140
|
* The rule takes a single option - an array of possible callback names - which may include object methods. The default callback names are `callback`, `cb`, `next`.
|
|
139
141
|
*/
|
|
140
142
|
type CallbackReturn = string[];
|
|
143
|
+
type ExportsStyleMode = "module.exports" | "exports";
|
|
141
144
|
/**
|
|
142
145
|
* The rule takes a single string option: the name of the error parameter.
|
|
143
146
|
*
|
|
@@ -476,9 +479,23 @@ interface Oxlintrc$1 {
|
|
|
476
479
|
*/
|
|
477
480
|
env?: OxlintEnv;
|
|
478
481
|
/**
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
+
* Configurations that this configuration file extends (inherits from).
|
|
483
|
+
*
|
|
484
|
+
* In `.oxlintrc.json`, `extends` has type `string[]`. Each string is a path to a configuration
|
|
485
|
+
* file, resolved relative to the location of the configuration file that contains the
|
|
486
|
+
* `extends` property.
|
|
487
|
+
*
|
|
488
|
+
* In `oxlint.config.ts`, `extends` has type `OxlintConfig[]`. Import each configuration and
|
|
489
|
+
* pass the configuration object directly:
|
|
490
|
+
*
|
|
491
|
+
* ```ts
|
|
492
|
+
* import { defineConfig } from "oxlint";
|
|
493
|
+
* import baseConfig from "./base-config.ts";
|
|
494
|
+
*
|
|
495
|
+
* export default defineConfig({ extends: [baseConfig] });
|
|
496
|
+
* ```
|
|
497
|
+
*
|
|
498
|
+
* Configurations are merged from the first to the last, with the last configuration
|
|
482
499
|
* overriding the previous ones.
|
|
483
500
|
*/
|
|
484
501
|
extends?: string[];
|
|
@@ -829,6 +846,7 @@ interface DummyRuleMap {
|
|
|
829
846
|
"getter-return"?: RuleNoConfig | [AllowWarnDeny, GetterReturn];
|
|
830
847
|
"grouped-accessor-pairs"?: RuleNoConfig | [AllowWarnDeny, PairOrder] | [AllowWarnDeny, PairOrder, GroupedAccessorPairsConfig];
|
|
831
848
|
"guard-for-in"?: RuleNoConfig;
|
|
849
|
+
"id-denylist"?: RuleNoConfig | [AllowWarnDeny, string, ...string[]];
|
|
832
850
|
"id-length"?: RuleNoConfig | [AllowWarnDeny, IdLengthConfig];
|
|
833
851
|
"id-match"?: RuleNoConfig | [AllowWarnDeny, string] | [AllowWarnDeny, string, IdMatchOptions];
|
|
834
852
|
"import/consistent-type-specifier-style"?: RuleNoConfig | [AllowWarnDeny, Mode];
|
|
@@ -906,7 +924,7 @@ interface DummyRuleMap {
|
|
|
906
924
|
"jest/prefer-hooks-on-top"?: RuleNoConfig;
|
|
907
925
|
"jest/prefer-importing-jest-globals"?: RuleNoConfig | [AllowWarnDeny, PreferImportingJestGlobalsConfig];
|
|
908
926
|
"jest/prefer-jest-mocked"?: RuleNoConfig;
|
|
909
|
-
"jest/prefer-lowercase-title"?:
|
|
927
|
+
"jest/prefer-lowercase-title"?: RuleNoConfig | [AllowWarnDeny, PreferLowercaseTitleConfig];
|
|
910
928
|
"jest/prefer-mock-promise-shorthand"?: RuleNoConfig;
|
|
911
929
|
"jest/prefer-mock-return-shorthand"?: RuleNoConfig;
|
|
912
930
|
"jest/prefer-snapshot-hint"?: RuleNoConfig | [AllowWarnDeny, SnapshotHintMode];
|
|
@@ -1090,7 +1108,7 @@ interface DummyRuleMap {
|
|
|
1090
1108
|
"no-redeclare"?: RuleNoConfig | [AllowWarnDeny, NoRedeclare];
|
|
1091
1109
|
"no-regex-spaces"?: RuleNoConfig;
|
|
1092
1110
|
"no-restricted-exports"?: RuleNoConfig | [AllowWarnDeny, NoRestrictedExportsConfig];
|
|
1093
|
-
"no-restricted-globals"?:
|
|
1111
|
+
"no-restricted-globals"?: RuleNoConfig | [AllowWarnDeny, NoRestrictedGlobalsConfigEnum, ...NoRestrictedGlobalsConfigEnum[]];
|
|
1094
1112
|
"no-restricted-imports"?: RuleNoConfig | [AllowWarnDeny, NoRestrictedImportsConfigEnum, ...NoRestrictedImportsConfigEnum[]];
|
|
1095
1113
|
"no-restricted-properties"?: RuleNoConfig | [AllowWarnDeny, PropertyDetails, ...PropertyDetails[]];
|
|
1096
1114
|
"no-return-assign"?: RuleNoConfig | [AllowWarnDeny, NoReturnAssignMode];
|
|
@@ -1135,9 +1153,10 @@ interface DummyRuleMap {
|
|
|
1135
1153
|
"no-useless-return"?: RuleNoConfig;
|
|
1136
1154
|
"no-var"?: RuleNoConfig;
|
|
1137
1155
|
"no-void"?: RuleNoConfig | [AllowWarnDeny, NoVoid];
|
|
1138
|
-
"no-warning-comments"?: RuleNoConfig | [AllowWarnDeny,
|
|
1156
|
+
"no-warning-comments"?: RuleNoConfig | [AllowWarnDeny, NoWarningCommentsConfig];
|
|
1139
1157
|
"no-with"?: RuleNoConfig;
|
|
1140
1158
|
"node/callback-return"?: RuleNoConfig | [AllowWarnDeny, CallbackReturn];
|
|
1159
|
+
"node/exports-style"?: RuleNoConfig | [AllowWarnDeny, ExportsStyleMode] | [AllowWarnDeny, ExportsStyleMode, ExportsStyleOptions];
|
|
1141
1160
|
"node/global-require"?: RuleNoConfig;
|
|
1142
1161
|
"node/handle-callback-err"?: RuleNoConfig | [AllowWarnDeny, HandleCallbackErrConfig];
|
|
1143
1162
|
"node/no-exports-assign"?: RuleNoConfig;
|
|
@@ -1154,6 +1173,7 @@ interface DummyRuleMap {
|
|
|
1154
1173
|
"oxc/bad-bitwise-operator"?: RuleNoConfig;
|
|
1155
1174
|
"oxc/bad-char-at-comparison"?: RuleNoConfig;
|
|
1156
1175
|
"oxc/bad-comparison-sequence"?: RuleNoConfig;
|
|
1176
|
+
"oxc/bad-match-all-arg"?: RuleNoConfig;
|
|
1157
1177
|
"oxc/bad-min-max-func"?: RuleNoConfig;
|
|
1158
1178
|
"oxc/bad-object-literal-comparison"?: RuleNoConfig;
|
|
1159
1179
|
"oxc/bad-replace-all-arg"?: RuleNoConfig;
|
|
@@ -1579,7 +1599,7 @@ interface DummyRuleMap {
|
|
|
1579
1599
|
"vitest/prefer-hooks-on-top"?: RuleNoConfig;
|
|
1580
1600
|
"vitest/prefer-import-in-mock"?: RuleNoConfig | [AllowWarnDeny, PreferImportInMockConfig];
|
|
1581
1601
|
"vitest/prefer-importing-vitest-globals"?: RuleNoConfig;
|
|
1582
|
-
"vitest/prefer-lowercase-title"?:
|
|
1602
|
+
"vitest/prefer-lowercase-title"?: RuleNoConfig | [AllowWarnDeny, PreferLowercaseTitleConfig];
|
|
1583
1603
|
"vitest/prefer-mock-promise-shorthand"?: RuleNoConfig;
|
|
1584
1604
|
"vitest/prefer-mock-return-shorthand"?: RuleNoConfig;
|
|
1585
1605
|
"vitest/prefer-snapshot-hint"?: RuleNoConfig | [AllowWarnDeny, SnapshotHintMode];
|
|
@@ -2299,6 +2319,96 @@ interface PreferImportingJestGlobalsConfig {
|
|
|
2299
2319
|
*/
|
|
2300
2320
|
types?: JestFnType[];
|
|
2301
2321
|
}
|
|
2322
|
+
interface PreferLowercaseTitleConfig {
|
|
2323
|
+
/**
|
|
2324
|
+
* This array option allows specifying prefixes, which contain capitals that titles
|
|
2325
|
+
* can start with. This can be useful when writing tests for API endpoints, where
|
|
2326
|
+
* you'd like to prefix with the HTTP method.
|
|
2327
|
+
* By default, nothing is allowed (the equivalent of `{ "allowedPrefixes": [] }`).
|
|
2328
|
+
*
|
|
2329
|
+
* Example of **correct** code for the `{ "allowedPrefixes": ["GET"] }` option:
|
|
2330
|
+
* ```js
|
|
2331
|
+
* /* jest/prefer-lowercase-title: ["error", { "allowedPrefixes": ["GET"] }] * /
|
|
2332
|
+
* describe('GET /live');
|
|
2333
|
+
* ```
|
|
2334
|
+
*/
|
|
2335
|
+
allowedPrefixes?: string[];
|
|
2336
|
+
/**
|
|
2337
|
+
* This array option controls which Jest or Vitest functions are checked by this rule. There
|
|
2338
|
+
* are four possible values:
|
|
2339
|
+
* - `"describe"`
|
|
2340
|
+
* - `"test"`
|
|
2341
|
+
* - `"it"`
|
|
2342
|
+
* - `"bench"`
|
|
2343
|
+
*
|
|
2344
|
+
* By default, none of these options are enabled (the equivalent of
|
|
2345
|
+
* `{ "ignore": [] }`).
|
|
2346
|
+
*
|
|
2347
|
+
* Example of **correct** code for the `{ "ignore": ["describe"] }` option:
|
|
2348
|
+
* ```js
|
|
2349
|
+
* /* jest/prefer-lowercase-title: ["error", { "ignore": ["describe"] }] * /
|
|
2350
|
+
* describe('Uppercase description');
|
|
2351
|
+
* ```
|
|
2352
|
+
*
|
|
2353
|
+
* Example of **correct** code for the `{ "ignore": ["test"] }` option:
|
|
2354
|
+
* ```js
|
|
2355
|
+
* /* jest/prefer-lowercase-title: ["error", { "ignore": ["test"] }] * /
|
|
2356
|
+
* test('Uppercase description');
|
|
2357
|
+
* ```
|
|
2358
|
+
*
|
|
2359
|
+
* Example of **correct** code for the `{ "ignore": ["it"] }` option:
|
|
2360
|
+
* ```js
|
|
2361
|
+
* /* jest/prefer-lowercase-title: ["error", { "ignore": ["it"] }] * /
|
|
2362
|
+
* it('Uppercase description');
|
|
2363
|
+
* ```
|
|
2364
|
+
*/
|
|
2365
|
+
ignore?: string[];
|
|
2366
|
+
/**
|
|
2367
|
+
* This option can be set to allow only the top-level `describe` blocks to have a
|
|
2368
|
+
* title starting with an upper-case letter.
|
|
2369
|
+
*
|
|
2370
|
+
* Example of **correct** code for the `{ "ignoreTopLevelDescribe": true }` option:
|
|
2371
|
+
* ```js
|
|
2372
|
+
* /* jest/prefer-lowercase-title: ["error", { "ignoreTopLevelDescribe": true }] * /
|
|
2373
|
+
* describe('MyClass', () => {
|
|
2374
|
+
* describe('#myMethod', () => {
|
|
2375
|
+
* it('does things', () => {
|
|
2376
|
+
* //
|
|
2377
|
+
* });
|
|
2378
|
+
* });
|
|
2379
|
+
* });
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
ignoreTopLevelDescribe?: boolean;
|
|
2383
|
+
/**
|
|
2384
|
+
* This option can be set to only validate that the first character of a test name is lowercased.
|
|
2385
|
+
*
|
|
2386
|
+
* Example of **correct** code for the `{ "lowercaseFirstCharacterOnly": true }` option:
|
|
2387
|
+
* ```js
|
|
2388
|
+
* /* vitest/prefer-lowercase-title: ["error", { "lowercaseFirstCharacterOnly": true }] * /
|
|
2389
|
+
* describe('myClass', () => {
|
|
2390
|
+
* describe('myMethod', () => {
|
|
2391
|
+
* it('does things', () => {
|
|
2392
|
+
* //
|
|
2393
|
+
* });
|
|
2394
|
+
* });
|
|
2395
|
+
* });
|
|
2396
|
+
* ```
|
|
2397
|
+
*
|
|
2398
|
+
* Example of **incorrect** code for the `{ "lowercaseFirstCharacterOnly": true }` option:
|
|
2399
|
+
* ```js
|
|
2400
|
+
* /* vitest/prefer-lowercase-title: ["error", { "lowercaseFirstCharacterOnly": true }] * /
|
|
2401
|
+
* describe('MyClass', () => {
|
|
2402
|
+
* describe('MyMethod', () => {
|
|
2403
|
+
* it('does things', () => {
|
|
2404
|
+
* //
|
|
2405
|
+
* });
|
|
2406
|
+
* });
|
|
2407
|
+
* });
|
|
2408
|
+
* ```
|
|
2409
|
+
*/
|
|
2410
|
+
lowercaseFirstCharacterOnly?: boolean;
|
|
2411
|
+
}
|
|
2302
2412
|
interface RequireHookConfig {
|
|
2303
2413
|
/**
|
|
2304
2414
|
* An array of function names that are allowed to be called outside of hooks.
|
|
@@ -3382,6 +3492,38 @@ interface RestrictDefaultExports {
|
|
|
3382
3492
|
*/
|
|
3383
3493
|
namespaceFrom?: boolean;
|
|
3384
3494
|
}
|
|
3495
|
+
/**
|
|
3496
|
+
* A restricted global with an optional custom message.
|
|
3497
|
+
*/
|
|
3498
|
+
interface RestrictedGlobal {
|
|
3499
|
+
/**
|
|
3500
|
+
* A custom message shown when the restricted global is used.
|
|
3501
|
+
*/
|
|
3502
|
+
message?: string;
|
|
3503
|
+
/**
|
|
3504
|
+
* The name of the restricted global.
|
|
3505
|
+
*/
|
|
3506
|
+
name: string;
|
|
3507
|
+
}
|
|
3508
|
+
/**
|
|
3509
|
+
* Object form of the configuration, which additionally allows detecting
|
|
3510
|
+
* restricted globals accessed via global objects.
|
|
3511
|
+
*/
|
|
3512
|
+
interface NoRestrictedGlobalsObjectConfig {
|
|
3513
|
+
/**
|
|
3514
|
+
* Whether to also detect restricted globals accessed via global objects. Default is `false`.
|
|
3515
|
+
*/
|
|
3516
|
+
checkGlobalObject?: boolean;
|
|
3517
|
+
/**
|
|
3518
|
+
* Additional global object names to check when `checkGlobalObject` is enabled.
|
|
3519
|
+
* By default, the rule checks these global objects: `globalThis`, `self`, and `window`.
|
|
3520
|
+
*/
|
|
3521
|
+
globalObjects?: string[];
|
|
3522
|
+
/**
|
|
3523
|
+
* The restricted globals, as names or `{ "name", "message" }` objects.
|
|
3524
|
+
*/
|
|
3525
|
+
globals: GlobalNameOrObject[];
|
|
3526
|
+
}
|
|
3385
3527
|
interface RestrictedPath {
|
|
3386
3528
|
allowImportNames?: string[];
|
|
3387
3529
|
allowTypeImports?: boolean;
|
|
@@ -3920,11 +4062,28 @@ interface NoVoid {
|
|
|
3920
4062
|
*/
|
|
3921
4063
|
allowAsStatement?: boolean;
|
|
3922
4064
|
}
|
|
3923
|
-
interface
|
|
4065
|
+
interface NoWarningCommentsConfig {
|
|
4066
|
+
/**
|
|
4067
|
+
* An array of characters to ignore at the start of comments when `location` is `"start"`.
|
|
4068
|
+
*
|
|
4069
|
+
* Useful for ignoring common comment decorations like `*` in JSDoc-style comments.
|
|
4070
|
+
*/
|
|
3924
4071
|
decoration?: string[];
|
|
4072
|
+
/**
|
|
4073
|
+
* Where to check for the terms.
|
|
4074
|
+
*/
|
|
3925
4075
|
location?: Location;
|
|
4076
|
+
/**
|
|
4077
|
+
* An array of terms to match. The matching is case-insensitive.
|
|
4078
|
+
*/
|
|
3926
4079
|
terms?: string[];
|
|
3927
4080
|
}
|
|
4081
|
+
interface ExportsStyleOptions {
|
|
4082
|
+
/**
|
|
4083
|
+
* If this option is set to `true`, `module.exports = exports = obj` are allowed.
|
|
4084
|
+
*/
|
|
4085
|
+
allowBatchAssign?: boolean;
|
|
4086
|
+
}
|
|
3928
4087
|
interface NoMixedRequiresOptions {
|
|
3929
4088
|
allowCall?: boolean;
|
|
3930
4089
|
grouping?: boolean;
|
|
@@ -5507,12 +5666,30 @@ interface NoUnnecessaryBooleanLiteralCompareConfig {
|
|
|
5507
5666
|
}
|
|
5508
5667
|
interface NoUnnecessaryConditionConfig {
|
|
5509
5668
|
/**
|
|
5510
|
-
*
|
|
5511
|
-
*
|
|
5669
|
+
* Controls which constant conditions are allowed in `while`, `do...while`, and `for` loops.
|
|
5670
|
+
*
|
|
5671
|
+
* - `"never"` (or `false`) reports all constant loop conditions.
|
|
5672
|
+
* - `"always"` (or `true`) allows conditions whose type is the literal type `true`, such as
|
|
5673
|
+
* `while (true)` or `while (variable)` when `variable` has type `true`.
|
|
5674
|
+
* - `"only-allowed-literals"` allows only the literal expressions `true`, `false`, `0`, and
|
|
5675
|
+
* `1`. Variables whose types are those literal types are still reported.
|
|
5512
5676
|
*/
|
|
5513
5677
|
allowConstantLoopConditions?: AllowConstantLoopConditions;
|
|
5514
5678
|
/**
|
|
5515
|
-
* Whether to check type predicate functions.
|
|
5679
|
+
* Whether to check arguments passed to type predicate and assertion functions.
|
|
5680
|
+
*
|
|
5681
|
+
* When enabled, the rule reports a call if the argument already satisfies the predicate or
|
|
5682
|
+
* if an assertion function receives an argument that is always truthy or always falsy.
|
|
5683
|
+
*
|
|
5684
|
+
* For example, `narrow(value)` is unnecessary because `value` already has type `true`:
|
|
5685
|
+
*
|
|
5686
|
+
* ```ts
|
|
5687
|
+
* declare const narrow: (value: unknown) => value is true;
|
|
5688
|
+
* const value = true;
|
|
5689
|
+
* if (narrow(value)) {
|
|
5690
|
+
* // ...
|
|
5691
|
+
* }
|
|
5692
|
+
* ```
|
|
5516
5693
|
*/
|
|
5517
5694
|
checkTypePredicates?: boolean;
|
|
5518
5695
|
}
|
|
@@ -6741,6 +6918,11 @@ interface VitestPluginSettings {
|
|
|
6741
6918
|
type Oxlintrc = Omit<Oxlintrc$1, "$schema" | "extends">;
|
|
6742
6919
|
type ExternalPluginsConfig = Exclude<Oxlintrc["jsPlugins"], undefined | null>;
|
|
6743
6920
|
interface OxlintConfig extends Oxlintrc {
|
|
6921
|
+
/**
|
|
6922
|
+
* Configuration objects to extend.
|
|
6923
|
+
*
|
|
6924
|
+
* Import configurations and pass them directly instead of using file paths.
|
|
6925
|
+
*/
|
|
6744
6926
|
extends?: OxlintConfig[];
|
|
6745
6927
|
}
|
|
6746
6928
|
/**
|
|
@@ -6749,6 +6931,6 @@ interface OxlintConfig extends Oxlintrc {
|
|
|
6749
6931
|
* @param config - Oxlint configuration
|
|
6750
6932
|
* @returns Config unchanged
|
|
6751
6933
|
*/
|
|
6752
|
-
declare function defineConfig<T extends OxlintConfig>(config: T): T;
|
|
6934
|
+
declare function defineConfig<T extends OxlintConfig>(config: T & OxlintConfig): T;
|
|
6753
6935
|
//#endregion
|
|
6754
6936
|
export { type AllowWarnDeny, type DummyRule, type DummyRuleMap, type ExternalPluginEntry, type ExternalPluginsConfig, type OxlintConfig, type OxlintEnv, type OxlintGlobals, type OxlintOverride, type RuleCategories, defineConfig };
|