diff --git a/src/docs/guide/usage/linter/generated-config.md b/src/docs/guide/usage/linter/generated-config.md index 40c56bfa5b1..c6e2c3a0a9b 100644 --- a/src/docs/guide/usage/linter/generated-config.md +++ b/src/docs/guide/usage/linter/generated-config.md @@ -147,8 +147,6 @@ Globs to ignore during linting. These are resolved from the configuration file p type: `string[]` -default: `null` - JS plugins. Note: JS plugins are experimental and not subject to semver. diff --git a/src/docs/guide/usage/linter/generated-rules.md b/src/docs/guide/usage/linter/generated-rules.md index 4ec5462b6d1..23e9801a02b 100644 --- a/src/docs/guide/usage/linter/generated-rules.md +++ b/src/docs/guide/usage/linter/generated-rules.md @@ -2,7 +2,7 @@ The progress of all rule implementations is tracked [here](https://github.com/oxc-project/oxc/issues/481). -- Total number of rules: 607 +- Total number of rules: 610 - Rules turned on by default: 103 **Legend for 'Fixable?' column:** @@ -235,7 +235,7 @@ Code that can be written to run faster. | [prefer-array-flat-map](/docs/guide/usage/linter/rules/unicorn/prefer-array-flat-map.html) | unicorn | | 🛠️ | | [prefer-set-has](/docs/guide/usage/linter/rules/unicorn/prefer-set-has.html) | unicorn | | ⚠️🛠️️ | -## Restriction (77): +## Restriction (78): Lints which prevent the use of language and library features. Must not be enabled as a whole, should be considered on a case-by-case basis before enabling. @@ -274,7 +274,7 @@ Lints which prevent the use of language and library features. Must not be enable | [anchor-ambiguous-text](/docs/guide/usage/linter/rules/jsx_a11y/anchor-ambiguous-text.html) | jsx_a11y | | | | [no-new-require](/docs/guide/usage/linter/rules/node/no-new-require.html) | node | | | | [no-process-env](/docs/guide/usage/linter/rules/node/no-process-env.html) | node | | | -| [bad-bitwise-operator](/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.html) | oxc | | | +| [bad-bitwise-operator](/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.html) | oxc | | 🚧 | | [no-async-await](/docs/guide/usage/linter/rules/oxc/no-async-await.html) | oxc | | | | [no-barrel-file](/docs/guide/usage/linter/rules/oxc/no-barrel-file.html) | oxc | | | | [no-const-enum](/docs/guide/usage/linter/rules/oxc/no-const-enum.html) | oxc | | 🛠️ | @@ -283,6 +283,7 @@ Lints which prevent the use of language and library features. Must not be enable | [catch-or-return](/docs/guide/usage/linter/rules/promise/catch-or-return.html) | promise | | | | [spec-only](/docs/guide/usage/linter/rules/promise/spec-only.html) | promise | | | | [button-has-type](/docs/guide/usage/linter/rules/react/button-has-type.html) | react | | | +| [forbid-dom-props](/docs/guide/usage/linter/rules/react/forbid-dom-props.html) | react | | | | [forbid-elements](/docs/guide/usage/linter/rules/react/forbid-elements.html) | react | | | | [jsx-filename-extension](/docs/guide/usage/linter/rules/react/jsx-filename-extension.html) | react | | 🚧 | | [no-danger](/docs/guide/usage/linter/rules/react/no-danger.html) | react | | | @@ -373,7 +374,7 @@ code that is most likely wrong or useless. | [no-required-prop-with-default](/docs/guide/usage/linter/rules/vue/no-required-prop-with-default.html) | vue | | 🚧 | | [require-default-export](/docs/guide/usage/linter/rules/vue/require-default-export.html) | vue | | | -## Pedantic (101): +## Pedantic (102): Lints which are rather strict or have occasional false positives. @@ -400,6 +401,7 @@ Lints which are rather strict or have occasional false positives. | [no-redeclare](/docs/guide/usage/linter/rules/eslint/no-redeclare.html) | eslint | | | | [no-self-compare](/docs/guide/usage/linter/rules/eslint/no-self-compare.html) | eslint | | | | [no-throw-literal](/docs/guide/usage/linter/rules/eslint/no-throw-literal.html) | eslint | | 💡 | +| [no-warning-comments](/docs/guide/usage/linter/rules/eslint/no-warning-comments.html) | eslint | | | | [radix](/docs/guide/usage/linter/rules/eslint/radix.html) | eslint | | ⚠️🛠️️ | | [require-await](/docs/guide/usage/linter/rules/eslint/require-await.html) | eslint | | ⚠️🛠️️ | | [sort-vars](/docs/guide/usage/linter/rules/eslint/sort-vars.html) | eslint | | 🚧 | @@ -652,12 +654,13 @@ Code that should be written in a more idiomatic way. | [define-props-destructuring](/docs/guide/usage/linter/rules/vue/define-props-destructuring.html) | vue | | | | [require-typed-ref](/docs/guide/usage/linter/rules/vue/require-typed-ref.html) | vue | | | -## Nursery (10): +## Nursery (11): New lints that are still under development. | Rule name | Source | Default | Fixable? | | --------------------------------------------------------------------------------------------------------- | ------- | ------- | -------- | +| [constructor-super](/docs/guide/usage/linter/rules/eslint/constructor-super.html) | eslint | | | | [getter-return](/docs/guide/usage/linter/rules/eslint/getter-return.html) | eslint | | | | [no-misleading-character-class](/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.html) | eslint | | | | [no-undef](/docs/guide/usage/linter/rules/eslint/no-undef.html) | eslint | | | diff --git a/src/docs/guide/usage/linter/rules/eslint/constructor-super.md b/src/docs/guide/usage/linter/rules/eslint/constructor-super.md index 3ace2eb9079..f42bbe2b5dd 100644 --- a/src/docs/guide/usage/linter/rules/eslint/constructor-super.md +++ b/src/docs/guide/usage/linter/rules/eslint/constructor-super.md @@ -1,5 +1,10 @@ + + # eslint/constructor-super
@@ -7,16 +12,67 @@ ### What it does -Require 'super()' calls in constructors. +Requires `super()` calls in constructors of derived classes and disallows `super()` calls +in constructors of non-derived classes. ### Why is this bad? -### Example +In JavaScript, calling `super()` in the constructor of a derived class (a class that extends +another class) is required. Failing to do so will result in a ReferenceError at runtime. +Conversely, calling `super()` in a non-derived class is a syntax error. + +### Examples + +Examples of **incorrect** code for this rule: -```javascript +```js +// Missing super() call class A extends B { constructor() {} } + +// super() in non-derived class +class A { + constructor() { + super(); + } +} + +// super() only in some code paths +class C extends D { + constructor() { + if (condition) { + super(); + } + } +} +``` + +Examples of **correct** code for this rule: + +```js +// Proper super() call in derived class +class A extends B { + constructor() { + super(); + } +} + +// No super() in non-derived class +class A { + constructor() {} +} + +// super() in all code paths +class C extends D { + constructor() { + if (condition) { + super(); + } else { + super(); + } + } +} ``` ## How to use @@ -41,4 +97,4 @@ oxlint --deny constructor-super ## References -- [Rule Source](https://github.com/oxc-project/oxc/blob/c22276e8fbbf443c4293a3cfe7758ac1ceea325c/crates/oxc_linter/src/rules/eslint/constructor_super.rs) +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/eslint/func-style.md b/src/docs/guide/usage/linter/rules/eslint/func-style.md index ad4bee83480..b5a4cf4ec2b 100644 --- a/src/docs/guide/usage/linter/rules/eslint/func-style.md +++ b/src/docs/guide/usage/linter/rules/eslint/func-style.md @@ -154,18 +154,24 @@ type: `boolean` default: `false` +When true, arrow functions are allowed regardless of the style setting. + ### allowTypeAnnotation type: `boolean` default: `false` +When true, functions with type annotations are allowed regardless of the style setting. + ### style type: `"expression" | "declaration"` default: `"expression"` +The style to enforce. Either "expression" (default) or "declaration". + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/max-depth.md b/src/docs/guide/usage/linter/rules/eslint/max-depth.md index 8d1765b0667..85196913527 100644 --- a/src/docs/guide/usage/linter/rules/eslint/max-depth.md +++ b/src/docs/guide/usage/linter/rules/eslint/max-depth.md @@ -91,6 +91,14 @@ Example: ] ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### max + +type: `integer` + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/max-params.md b/src/docs/guide/usage/linter/rules/eslint/max-params.md index f703fdd0da6..bda03cad62a 100644 --- a/src/docs/guide/usage/linter/rules/eslint/max-params.md +++ b/src/docs/guide/usage/linter/rules/eslint/max-params.md @@ -55,7 +55,7 @@ let foo = (bar, baz, qux) => { ### Options -### max +#### max `{ "max": number }` @@ -64,7 +64,7 @@ This option is for changing the maximum allowed number of function parameters. For example `{ "max": 4 }` would mean that having a function take four parameters is allowed which overrides the default of three. -### countVoidThis +#### countVoidThis `{ "countVoidThis": boolean }` diff --git a/src/docs/guide/usage/linter/rules/eslint/no-empty-function.md b/src/docs/guide/usage/linter/rules/eslint/no-empty-function.md index f045b0ae71b..2378e725fb1 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-empty-function.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-empty-function.md @@ -19,17 +19,23 @@ Disallows the usages of empty functions Empty functions can reduce readability because readers need to guess whether it's intentional or not. So writing a clear comment for empty functions is a good practice. -### Configuration +### Options -You may pass an object containing a list of `allow`ed function kinds. -For example: +#### allow + +`{ type: string[], default: [] }` + +You may pass a list of allowed function kinds, which will allow functions of +these kinds to be empty. + +Example: ```json -// oxlint.json { - "rules": { - "no-empty-function": ["error", { "allow": ["functions"] }] - } + "no-empty-function": [ + "error", + { "allow": ["functions"] } + ] } ``` diff --git a/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md b/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md index 87c296783c7..9d3a3a8eaef 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md @@ -40,6 +40,18 @@ new RegExp(); this.RegExp("["); ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### allowConstructorFlags + +type: `string[]` + +default: `[]` + +Case-sensitive array of flags that will be allowed. + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.md b/src/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.md index 181482070c8..9aee11c8032 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.md @@ -36,11 +36,11 @@ function example() { Examples of **correct** code for this rule: -````javascript +```javascript function example() { - var foo = 'bar'; // regular spaces only + var foo = "bar"; // regular spaces only } - +``` ## How to use @@ -50,7 +50,7 @@ To **enable** this rule in the CLI or using the config file, you can use: ```bash [CLI] oxlint --deny no-irregular-whitespace -```` +``` ```json [Config (.oxlintrc.json)] { diff --git a/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md b/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md index bf37ac621fb..58b9761b900 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md @@ -32,6 +32,34 @@ function baz(qux) { } ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### ignorePropertyModificationsFor + +type: `string[]` + +default: `[]` + +An array of parameter names whose property modifications should be ignored. + +### ignorePropertyModificationsForRegex + +type: `string[]` + +An array of regex patterns (as strings) for parameter names whose property modifications should be ignored. +Note that this uses [Rust regex syntax](https://docs.rs/regex/latest/regex/) and so may not have all features +available to JavaScript regexes. + +### props + +type: `boolean` + +default: `false` + +When true, also check for modifications to properties of parameters. + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md b/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md index de639a58484..890a20dbfb4 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md @@ -56,28 +56,27 @@ for (let i = 0; i < l; i++) { Examples of **correct** code for this rule: -````js -var x = 0; x += 1; -var y = 0; y -= 1; +```js +var x = 0; +x += 1; +var y = 0; +y -= 1; for (let i = 0; i < l; i += 1) { - doSomething(i); + doSomething(i); } +``` + +## Configuration -### Options +This rule accepts a configuration object with the following properties: -#### allowForLoopAfterthoughts +### allowForLoopAfterthoughts -`{ type: boolean, default: false }` +type: `boolean` -Pass `"allowForLoopAfterthoughts": true` to allow `++` and `--` in for loop afterthoughts. +default: `false` -Example: -```json -"no-plusplus": [ - "error", - { "allowForLoopAfterthoughts": true } -] -```` +Whether to allow `++` and `--` in for loop afterthoughts. ## How to use diff --git a/src/docs/guide/usage/linter/rules/eslint/no-shadow-restricted-names.md b/src/docs/guide/usage/linter/rules/eslint/no-shadow-restricted-names.md index 685a61fe695..16861ba7973 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-shadow-restricted-names.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-shadow-restricted-names.md @@ -15,8 +15,8 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin ### What it does -Disallows the redefining of global variables such as `undefined`, `NaN`, `Infinity`, `eval` -and `arguments`. +Disallows the redefining of global variables such as `undefined`, `NaN`, `Infinity`, +`eval`, and `arguments`. ### Why is this bad? @@ -71,6 +71,18 @@ var undefined; import { undefined as undef } from "bar"; ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### reportGlobalThis + +type: `boolean` + +default: `false` + +If true, also report shadowing of `globalThis`. + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md b/src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md index b5c90789477..700ab1587a2 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md @@ -181,6 +181,200 @@ Examples of **incorrect** code for `/* exported variableName */` operation: var global_var = 42; ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### args + +Controls how unused arguments are checked. + +This option has three settings: + +1. `after-used` - Unused positional arguments that occur before the last + used argument will not be checked, but all named arguments and all + positional arguments after the last used argument will be checked. + This is the default setting. +2. `all` - All named arguments must be used. +3. `none` - Do not check arguments. + +### caughtErrors + +type: `boolean` + +Used for `catch` block validation. + +It has two settings: + +- `none` - do not check error objects. This is the default setting. +- `all` - all named arguments must be used`.`none`corresponds to`false`, while`all`corresponds to`true`. + +### ignoreClassWithStaticInitBlock + +type: `boolean` + +The `ignoreClassWithStaticInitBlock` option is a boolean (default: +`false`). Static initialization blocks allow you to initialize static +variables and execute code during the evaluation of a class definition, +meaning the static block code is executed without creating a new +instance of the class. When set to true, this option ignores classes +containing static initialization blocks. + +## Example + +Examples of **incorrect** code for the `{ "ignoreClassWithStaticInitBlock": true }` option + +```javascript +/*eslint no-unused-vars: ["error", { "ignoreClassWithStaticInitBlock": true }]*/ + +class Foo { + static myProperty = "some string"; + static mymethod() { + return "some string"; + } +} + +class Bar { + static { + let baz; // unused variable + } +} +``` + +Examples of **correct** code for the `{ "ignoreClassWithStaticInitBlock": true }` option + +```javascript +/*eslint no-unused-vars: ["error", { "ignoreClassWithStaticInitBlock": true }]*/ + +class Foo { + static { + let bar = "some string"; + + console.log(bar); + } +} +``` + +### ignoreRestSiblings + +type: `boolean` + +Using a Rest property it is possible to "omit" properties from an +object, but by default the sibling properties are marked as "unused". +With this option enabled the rest property's siblings are ignored. + +By default this option is `false`. + +## Example + +Examples of **correct** code when this option is set to `true`: + +```js +// 'foo' and 'bar' were ignored because they have a rest property sibling. +var { foo, ...coords } = data; + +var bar; +({ bar, ...coords } = data); +``` + +### ignoreUsingDeclarations + +type: `boolean` + +The `ignoreUsingDeclarations` option is a boolean (default: `false`). +When set to `true`, the rule will ignore variables declared with +`using` or `await using` declarations, even if they are unused. + +This is useful when working with resources that need to be disposed +via the explicit resource management proposal, where the primary +purpose is the disposal side effect rather than using the resource. + +## Example + +Examples of **correct** code for the `{ "ignoreUsingDeclarations": true }` option: + +```javascript +/*eslint no-unused-vars: ["error", { "ignoreUsingDeclarations": true }]*/ + +using resource = getResource(); +await using anotherResource = getAnotherResource(); +``` + +### reportUsedIgnorePattern + +type: `boolean` + +The `reportUsedIgnorePattern` option is a boolean (default: `false`). +Using this option will report variables that match any of the valid +ignore pattern options (`varsIgnorePattern`, `argsIgnorePattern`, +`caughtErrorsIgnorePattern`, or `destructuredArrayIgnorePattern`) if +they have been used. + +## Example + +Examples of **incorrect** code for the `{ "reportUsedIgnorePattern": true }` option: + +```javascript +/*eslint no-unused-vars: ["error", { "reportUsedIgnorePattern": true, "varsIgnorePattern": "[iI]gnored" }]*/ + +var firstVarIgnored = 1; +var secondVar = 2; +console.log(firstVarIgnored, secondVar); +``` + +Examples of **correct** code for the `{ "reportUsedIgnorePattern": true }` option: + +```javascript +/*eslint no-unused-vars: ["error", { "reportUsedIgnorePattern": true, "varsIgnorePattern": "[iI]gnored" }]*/ + +var firstVar = 1; +var secondVar = 2; +console.log(firstVar, secondVar); +``` + +### reportVarsOnlyUsedAsTypes + +type: `boolean` + +The `reportVarsOnlyUsedAsTypes` option is a boolean (default: `false`). + +If `true`, the rule will also report variables that are only used as types. + +## Examples + +Examples of **incorrect** code for the `{ "reportVarsOnlyUsedAsTypes": true }` option: + +```javascript +/* eslint no-unused-vars: ["error", { "reportVarsOnlyUsedAsTypes": true }] */ + +const myNumber: number = 4; +export type MyNumber = typeof myNumber +``` + +Examples of **correct** code for the `{ "reportVarsOnlyUsedAsTypes": true }` option: + +```javascript +export type MyNumber = number; +``` + +Note: even with `{ "reportVarsOnlyUsedAsTypes": false }`, cases where the value is +only used a type within itself will still be reported: + +```javascript +function foo(): typeof foo {} +``` + +### vars + +Controls how usage of a variable in the global scope is checked. + +This option has two settings: + +1. `all` checks all variables for usage, including those in the global + scope. This is the default setting. +2. `local` checks only that locally-declared variables are used but will + allow global variables to be unused. + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/no-useless-escape.md b/src/docs/guide/usage/linter/rules/eslint/no-useless-escape.md index 9db9a3daa44..4818d28eaa7 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-useless-escape.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-useless-escape.md @@ -18,10 +18,14 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin ### What it does -Disallow unnecessary escape characters +Disallow unnecessary escape characters. ### Why is this bad? +Escaping characters unnecessarily has no effect on the behavior of strings or regexes, +and can make code harder to read and understand by adding unnecessary complexity. +This applies to string literals, template literals, and regular expressions. + ### Examples Examples of **incorrect** code for this rule: @@ -64,6 +68,18 @@ Examples of **correct** code for this rule: /[a-z-]/; ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### allowRegexCharacters + +type: `string[]` + +default: `[]` + +An array of characters that are allowed to be escaped unnecessarily in regexes. + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/no-warning-comments.md b/src/docs/guide/usage/linter/rules/eslint/no-warning-comments.md new file mode 100644 index 00000000000..5e31ce8b3e5 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-warning-comments.md @@ -0,0 +1,99 @@ + + + + +# eslint/no-warning-comments + +
+
+ +### What it does + +Disallows warning comments such as TODO, FIXME, XXX in code. + +### Why is this bad? + +Developers often add comments like TODO or FIXME to mark incomplete work or areas +that need attention. While useful during development, these comments can indicate +unfinished code that shouldn't be shipped to production. This rule helps catch +such comments before they make it into production code. + +### Examples + +Examples of **incorrect** code for this rule: + +```javascript +// TODO: implement this feature +function doSomething() {} + +// FIXME: this is broken +const x = 1; + +/* XXX: hack */ +let y = 2; +``` + +Examples of **correct** code for this rule: + +```javascript +// This is a regular comment +function doSomething() {} + +// Note: This explains something +const x = 1; +``` + +### Options + +This rule has an options object with the following defaults: + +```json +{ + "terms": ["todo", "fixme", "xxx"], + "location": "start", + "decoration": [] +} +``` + +#### `terms` + +An array of terms to match. The matching is case-insensitive. + +#### `location` + +Where to check for the terms: + +- `"start"` (default): Terms must appear at the start of the comment (after any decoration) +- `"anywhere"`: Terms can appear anywhere in the comment + +#### `decoration` + +An array of characters to ignore at the start of comments when `location` is `"start"`. +Useful for ignoring common comment decorations like `*` in JSDoc-style comments. + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny no-warning-comments +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "no-warning-comments": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/eslint/use-isnan.md b/src/docs/guide/usage/linter/rules/eslint/use-isnan.md index c4e284bc5ee..c54137daebb 100644 --- a/src/docs/guide/usage/linter/rules/eslint/use-isnan.md +++ b/src/docs/guide/usage/linter/rules/eslint/use-isnan.md @@ -46,6 +46,26 @@ foo <= NaN; foo > NaN; ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### enforceForIndexOf + +type: `boolean` + +default: `false` + +Whether to disallow NaN as arguments of `indexOf` and `lastIndexOf` + +### enforceForSwitchCase + +type: `boolean` + +default: `true` + +Whether to disallow NaN in switch cases and discriminants + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/valid-typeof.md b/src/docs/guide/usage/linter/rules/eslint/valid-typeof.md index a9a1fd01fad..d1fa22f0e07 100644 --- a/src/docs/guide/usage/linter/rules/eslint/valid-typeof.md +++ b/src/docs/guide/usage/linter/rules/eslint/valid-typeof.md @@ -47,17 +47,21 @@ typeof foo === baz; typeof bar === typeof qux; ``` -### Options +## Configuration -#### requireStringLiterals +This rule accepts a configuration object with the following properties: -`{ type: boolean, default: false }` +### requireStringLiterals + +type: `boolean` + +default: `false` The `requireStringLiterals` option when set to `true`, allows the comparison of `typeof` expressions with only string literals or other `typeof` expressions, and disallows comparisons to any other value. Default is `false`. -With `requireStringLiterals` set to `true` the following are examples of incorrect code: +With `requireStringLiterals` set to `true`, the following are examples of **incorrect** code: ```js typeof foo === undefined; @@ -68,7 +72,7 @@ typeof baz === anotherVariable; typeof foo == 5; ``` -With `requireStringLiterals` set to `true` the following are examples of correct code: +With `requireStringLiterals` set to `true`, the following are examples of **correct** code: ```js typeof foo === "undefined"; diff --git a/src/docs/guide/usage/linter/rules/import/namespace.md b/src/docs/guide/usage/linter/rules/import/namespace.md index e8855368cb9..7ed0ea81d90 100644 --- a/src/docs/guide/usage/linter/rules/import/namespace.md +++ b/src/docs/guide/usage/linter/rules/import/namespace.md @@ -63,6 +63,18 @@ const method = "bar"; foo[method](); // Valid: method refers to an exported function ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### allowComputed + +type: `boolean` + +default: `false` + +Whether to allow computed references to an imported namespace. + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/jest/max-nested-describe.md b/src/docs/guide/usage/linter/rules/jest/max-nested-describe.md index d5779fa5590..3b3380e5e90 100644 --- a/src/docs/guide/usage/linter/rules/jest/max-nested-describe.md +++ b/src/docs/guide/usage/linter/rules/jest/max-nested-describe.md @@ -23,7 +23,7 @@ Nesting `describe()` blocks too deeply can make the test suite hard to read and The following patterns are considered warnings (with the default option of `{ "max": 5 }`): -/// /// Examples of **incorrect** code for this rule: +Examples of **incorrect** code for this rule: ```javascript describe("foo", () => { @@ -96,6 +96,18 @@ describe("foo", function() { }); ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### max + +type: `integer` + +default: `5` + +Maximum allowed depth of nested describe calls. + ## How to use To **enable** this rule in the CLI or using the config file, you can use: diff --git a/src/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.md b/src/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.md index 4e9cb05200b..5bc8d1fb6f1 100644 --- a/src/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.md +++ b/src/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.md @@ -8,6 +8,9 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin # oxc/bad-bitwise-operator
+ +🚧 An auto-fix is still under development. +
### What it does diff --git a/src/docs/guide/usage/linter/rules/react/forbid-dom-props.md b/src/docs/guide/usage/linter/rules/react/forbid-dom-props.md new file mode 100644 index 00000000000..9a7ac4be9b1 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/react/forbid-dom-props.md @@ -0,0 +1,75 @@ + + + + +# react/forbid-dom-props + +
+
+ +### What it does + +This rule prevents passing of props to elements. This rule only applies to DOM Nodes (e.g.
) and not Components (e.g. ). The list of forbidden props can be customized with the forbid option. + +### Why is this bad? + +This rule checks all JSX elements and verifies that no forbidden props are used on DOM Nodes. This rule is off by default. + +### Examples + +Examples of **incorrect** code for this rule: + +```jsx +// [1, { "forbid": ["id"] }] +
+ +// [1, { "forbid": ["style"] }] +
+``` + +Examples of **correct** code for this rule: + +```jsx +// [1, { "forbid": ["id"] }] + + +// [1, { "forbid": ["id"] }] + +``` + +### Options + +#### forbid + +An array of strings, with the names of props that are forbidden. The default value of this option []. +Each array element can either be a string with the property name or object specifying the property name, an optional custom message, and a DOM nodes disallowed list (e.g.
) + +`{"propName": "someProp", "disallowedFor": ["DOMNode", "AnotherDOMNode"], "message": "Avoid using someProp" }` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny react/forbid-dom-props --react-plugin +``` + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["react"], + "rules": { + "react/forbid-dom-props": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/typescript/await-thenable.md b/src/docs/guide/usage/linter/rules/typescript/await-thenable.md index 8b2d132bbe7..2e5cc079374 100644 --- a/src/docs/guide/usage/linter/rules/typescript/await-thenable.md +++ b/src/docs/guide/usage/linter/rules/typescript/await-thenable.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-array-delete.md b/src/docs/guide/usage/linter/rules/typescript/no-array-delete.md index a2556ab2818..7032c5a9a6b 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-array-delete.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-array-delete.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-base-to-string.md b/src/docs/guide/usage/linter/rules/typescript/no-base-to-string.md index a2b2a8936d8..fb6c64cb010 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-base-to-string.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-base-to-string.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-duplicate-type-constituents.md b/src/docs/guide/usage/linter/rules/typescript/no-duplicate-type-constituents.md index 61a1f3bf6ac..ef7ca3b3296 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-duplicate-type-constituents.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-duplicate-type-constituents.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-floating-promises.md b/src/docs/guide/usage/linter/rules/typescript/no-floating-promises.md index a42e581a125..b93d601fdac 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-floating-promises.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-floating-promises.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-for-in-array.md b/src/docs/guide/usage/linter/rules/typescript/no-for-in-array.md index 141703ffd11..64f97806f0d 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-for-in-array.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-for-in-array.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-implied-eval.md b/src/docs/guide/usage/linter/rules/typescript/no-implied-eval.md index 08ef08b9f01..7582a48fa62 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-implied-eval.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-implied-eval.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-meaningless-void-operator.md b/src/docs/guide/usage/linter/rules/typescript/no-meaningless-void-operator.md index 8786c001940..d0d8154dc14 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-meaningless-void-operator.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-meaningless-void-operator.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-misused-spread.md b/src/docs/guide/usage/linter/rules/typescript/no-misused-spread.md index d989def5789..5559ba26dac 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-misused-spread.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-misused-spread.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-redundant-type-constituents.md b/src/docs/guide/usage/linter/rules/typescript/no-redundant-type-constituents.md index ccea3021057..ecab8108aaa 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-redundant-type-constituents.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-redundant-type-constituents.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/no-unsafe-unary-minus.md b/src/docs/guide/usage/linter/rules/typescript/no-unsafe-unary-minus.md index 5299d0d8ebd..0d5ef454e1d 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-unsafe-unary-minus.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-unsafe-unary-minus.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/require-array-sort-compare.md b/src/docs/guide/usage/linter/rules/typescript/require-array-sort-compare.md index 3c8314d66c6..fc8d7dc92bb 100644 --- a/src/docs/guide/usage/linter/rules/typescript/require-array-sort-compare.md +++ b/src/docs/guide/usage/linter/rules/typescript/require-array-sort-compare.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/restrict-template-expressions.md b/src/docs/guide/usage/linter/rules/typescript/restrict-template-expressions.md index 07e41d5fb32..8b891ae7a10 100644 --- a/src/docs/guide/usage/linter/rules/typescript/restrict-template-expressions.md +++ b/src/docs/guide/usage/linter/rules/typescript/restrict-template-expressions.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/typescript/unbound-method.md b/src/docs/guide/usage/linter/rules/typescript/unbound-method.md index 30cb1ca91b8..060cf4810e0 100644 --- a/src/docs/guide/usage/linter/rules/typescript/unbound-method.md +++ b/src/docs/guide/usage/linter/rules/typescript/unbound-method.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
- This rule is turned on by default. + This rule is turned on by default when type-aware linting is enabled. 💭 This rule requires type information. diff --git a/src/docs/guide/usage/linter/rules/version.data.js b/src/docs/guide/usage/linter/rules/version.data.js index c43a2b0a5d7..75527747475 100644 --- a/src/docs/guide/usage/linter/rules/version.data.js +++ b/src/docs/guide/usage/linter/rules/version.data.js @@ -1,5 +1,5 @@ export default { load() { - return "6440cde67502bdc72020a1b8992b5445b7b490f3"; + return "dd1fdd44304b82e5df2aecef0787a7c6f2c6de84"; }, };