diff --git a/.vitepress/data/rules.json b/.vitepress/data/rules.json index 37296d3c9f9..0c4b89946c5 100644 --- a/.vitepress/data/rules.json +++ b/.vitepress/data/rules.json @@ -13,7 +13,7 @@ "value": "array-callback-return", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/array-callback-return.html" }, @@ -319,7 +319,7 @@ "value": "no-case-declarations", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-case-declarations.html" }, @@ -517,7 +517,7 @@ "value": "no-empty-function", "category": "restriction", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-empty-function.html" }, @@ -760,7 +760,7 @@ "value": "no-misleading-character-class", "category": "correctness", "type_aware": false, - "fix": "none", + "fix": "pending", "default": true, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.html" }, @@ -886,7 +886,7 @@ "value": "no-promise-executor-return", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.html" }, @@ -904,7 +904,7 @@ "value": "no-prototype-builtins", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.html" }, @@ -949,7 +949,7 @@ "value": "no-return-assign", "category": "style", "type_aware": false, - "fix": "pending", + "fix": "none", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-return-assign.html" }, @@ -998,6 +998,15 @@ "default": true, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-setter-return.html" }, + { + "scope": "eslint", + "value": "no-shadow", + "category": "suspicious", + "type_aware": false, + "fix": "none", + "default": false, + "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-shadow.html" + }, { "scope": "eslint", "value": "no-shadow-restricted-names", @@ -1088,6 +1097,15 @@ "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unexpected-multiline.html" }, + { + "scope": "eslint", + "value": "no-unmodified-loop-condition", + "category": "suspicious", + "type_aware": false, + "fix": "none", + "default": false, + "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unmodified-loop-condition.html" + }, { "scope": "eslint", "value": "no-unneeded-ternary", @@ -1894,7 +1912,7 @@ "value": "no-done-callback", "category": "style", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jest/no-done-callback.html" }, @@ -2083,7 +2101,7 @@ "value": "prefer-equality-matcher", "category": "style", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jest/prefer-equality-matcher.html" }, @@ -2254,7 +2272,7 @@ "value": "valid-expect", "category": "correctness", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jest/valid-expect.html" }, @@ -2281,7 +2299,7 @@ "value": "check-property-names", "category": "correctness", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/check-property-names.html" }, @@ -2290,7 +2308,7 @@ "value": "check-tag-names", "category": "correctness", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/check-tag-names.html" }, @@ -2299,7 +2317,7 @@ "value": "empty-tags", "category": "restriction", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/empty-tags.html" }, @@ -2317,7 +2335,7 @@ "value": "no-defaults", "category": "correctness", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/no-defaults.html" }, @@ -2326,7 +2344,7 @@ "value": "require-param", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/require-param.html" }, @@ -2335,7 +2353,7 @@ "value": "require-param-description", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/require-param-description.html" }, @@ -2353,7 +2371,7 @@ "value": "require-param-type", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/require-param-type.html" }, @@ -2362,7 +2380,7 @@ "value": "require-property", "category": "correctness", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/require-property.html" }, @@ -2398,7 +2416,7 @@ "value": "require-returns", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/require-returns.html" }, @@ -2657,7 +2675,7 @@ { "scope": "jsx_a11y", "value": "no-static-element-interactions", - "category": "nursery", + "category": "correctness", "type_aware": false, "fix": "none", "default": false, @@ -3455,6 +3473,15 @@ "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/react/jsx-no-comment-textnodes.html" }, + { + "scope": "react", + "value": "jsx-no-constructed-context-values", + "category": "perf", + "type_aware": false, + "fix": "none", + "default": false, + "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/react/jsx-no-constructed-context-values.html" + }, { "scope": "react", "value": "jsx-no-duplicate-props", @@ -3478,7 +3505,7 @@ "value": "jsx-no-target-blank", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/react/jsx-no-target-blank.html" }, @@ -3667,7 +3694,7 @@ "value": "no-unescaped-entities", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/react/no-unescaped-entities.html" }, @@ -4018,7 +4045,7 @@ "value": "no-empty-interface", "category": "style", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-empty-interface.html" }, @@ -4027,7 +4054,7 @@ "value": "no-empty-object-type", "category": "restriction", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-empty-object-type.html" }, @@ -4045,7 +4072,7 @@ "value": "no-extra-non-null-assertion", "category": "correctness", "type_aware": false, - "fix": "none", + "fix": "pending", "default": true, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-extra-non-null-assertion.html" }, @@ -4171,7 +4198,7 @@ "value": "no-non-null-asserted-nullish-coalescing", "category": "restriction", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-non-null-asserted-nullish-coalescing.html" }, @@ -4189,7 +4216,7 @@ "value": "no-non-null-assertion", "category": "restriction", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-non-null-assertion.html" }, @@ -4234,10 +4261,19 @@ "value": "no-unnecessary-boolean-literal-compare", "category": "suspicious", "type_aware": true, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-unnecessary-boolean-literal-compare.html" }, + { + "scope": "typescript", + "value": "no-unnecessary-condition", + "category": "nursery", + "type_aware": true, + "fix": "none", + "default": false, + "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-unnecessary-condition.html" + }, { "scope": "typescript", "value": "no-unnecessary-parameter-property-assignment", @@ -4279,7 +4315,7 @@ "value": "no-unnecessary-type-constraint", "category": "suspicious", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-constraint.html" }, @@ -4373,6 +4409,15 @@ "default": true, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-unsafe-unary-minus.html" }, + { + "scope": "typescript", + "value": "no-use-before-define", + "category": "restriction", + "type_aware": false, + "fix": "none", + "default": false, + "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-use-before-define.html" + }, { "scope": "typescript", "value": "no-useless-empty-export", @@ -4418,6 +4463,15 @@ "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/only-throw-error.html" }, + { + "scope": "typescript", + "value": "parameter-properties", + "category": "style", + "type_aware": false, + "fix": "none", + "default": false, + "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/parameter-properties.html" + }, { "scope": "typescript", "value": "prefer-as-const", @@ -4603,7 +4657,7 @@ "value": "strict-boolean-expressions", "category": "pedantic", "type_aware": true, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/strict-boolean-expressions.html" }, @@ -4634,6 +4688,15 @@ "default": true, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/unbound-method.html" }, + { + "scope": "typescript", + "value": "unified-signatures", + "category": "style", + "type_aware": false, + "fix": "none", + "default": false, + "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/unified-signatures.html" + }, { "scope": "typescript", "value": "use-unknown-in-catch-callback-variable", @@ -4747,7 +4810,7 @@ "value": "new-for-builtins", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/new-for-builtins.html" }, @@ -4774,7 +4837,7 @@ "value": "no-anonymous-default-export", "category": "restriction", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.html" }, @@ -4846,7 +4909,7 @@ "value": "no-await-in-promise-methods", "category": "correctness", "type_aware": false, - "fix": "none", + "fix": "fixable_suggestion", "default": true, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.html" }, @@ -4909,7 +4972,7 @@ "value": "no-instanceof-builtins", "category": "suspicious", "type_aware": false, - "fix": "pending", + "fix": "conditional_suggestion", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-instanceof-builtins.html" }, @@ -4945,7 +5008,7 @@ "value": "no-lonely-if", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-lonely-if.html" }, @@ -4990,7 +5053,7 @@ "value": "no-new-buffer", "category": "pedantic", "type_aware": false, - "fix": "pending", + "fix": "fixable_suggestion", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-new-buffer.html" }, @@ -5107,7 +5170,7 @@ "value": "no-unreadable-array-destructuring", "category": "style", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.html" }, @@ -5368,7 +5431,7 @@ "value": "prefer-dom-node-remove", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.html" }, @@ -5404,7 +5467,7 @@ "value": "prefer-includes", "category": "style", "type_aware": false, - "fix": "pending", + "fix": "fixable_suggestion", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-includes.html" }, @@ -5647,7 +5710,7 @@ "value": "prefer-top-level-await", "category": "pedantic", "type_aware": false, - "fix": "none", + "fix": "pending", "default": false, "docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.html" }, diff --git a/src/docs/guide/usage/formatter/generated-config.md b/src/docs/guide/usage/formatter/generated-config.md index 4a469e27e69..a3994c2bfd5 100644 --- a/src/docs/guide/usage/formatter/generated-config.md +++ b/src/docs/guide/usage/formatter/generated-config.md @@ -76,6 +76,9 @@ Custom groups have a higher priority than any predefined group. If you want a predefined group to take precedence over a custom group, you must write a custom group definition that does the same as what the predefined group does, and put it first in the list. +If you specify multiple conditions like `elementNamePattern`, `selector`, and `modifiers`, +all conditions must be met for an import to match the custom group (AND logic). + - Default: `[]` #### experimentalSortImports.customGroups[n] @@ -98,6 +101,24 @@ default: `""` Name of the custom group, used in the `groups` option. +##### experimentalSortImports.customGroups[n].modifiers + +type: `string[]` + +Modifiers to match the import characteristics. +All specified modifiers must be present (AND logic). + +Possible values: `"side_effect"`, `"type"`, `"value"`, `"default"`, `"wildcard"`, `"named"` + +##### experimentalSortImports.customGroups[n].selector + +type: `string` + +Selector to match the import kind. + +Possible values: `"type"`, `"side_effect_style"`, `"side_effect"`, `"style"`, `"index"`, +`"sibling"`, `"parent"`, `"subpath"`, `"internal"`, `"builtin"`, `"external"`, `"import"` + ### experimentalSortImports.groups type: `array` @@ -119,8 +140,8 @@ You may enter modifiers in any order, but the selector must always come at the e The list of selectors is sorted from most to least important: - `type` — TypeScript type imports. -- `side-effect-style` — Side effect style imports. -- `side-effect` — Side effect imports. +- `side_effect_style` — Side effect style imports. +- `side_effect` — Side effect imports. - `style` — Style imports. - `index` — Main file from the current directory. - `sibling` — Modules from the same directory. @@ -133,16 +154,12 @@ The list of selectors is sorted from most to least important: The list of modifiers is sorted from most to least important: -- `side-effect` — Side effect imports. +- `side_effect` — Side effect imports. - `type` — TypeScript type imports. - `value` — Value imports. - `default` — Imports containing the default specifier. - `wildcard` — Imports containing the wildcard (`* as`) specifier. - `named` — Imports containing at least one named specifier. -- `multiline` — Imports on multiple lines. -- `singleline` — Imports on a single line. - -See also for details. - Default: See below @@ -162,10 +179,6 @@ See also for details. type: `array | string` -##### experimentalSortImports.groups[n][n] - -type: `string` - ### experimentalSortImports.ignoreCase type: `boolean` @@ -481,6 +494,9 @@ Custom groups have a higher priority than any predefined group. If you want a predefined group to take precedence over a custom group, you must write a custom group definition that does the same as what the predefined group does, and put it first in the list. +If you specify multiple conditions like `elementNamePattern`, `selector`, and `modifiers`, +all conditions must be met for an import to match the custom group (AND logic). + - Default: `[]` ####### overrides[n].options.experimentalSortImports.customGroups[n] @@ -503,6 +519,24 @@ default: `""` Name of the custom group, used in the `groups` option. +######## overrides[n].options.experimentalSortImports.customGroups[n].modifiers + +type: `string[]` + +Modifiers to match the import characteristics. +All specified modifiers must be present (AND logic). + +Possible values: `"side_effect"`, `"type"`, `"value"`, `"default"`, `"wildcard"`, `"named"` + +######## overrides[n].options.experimentalSortImports.customGroups[n].selector + +type: `string` + +Selector to match the import kind. + +Possible values: `"type"`, `"side_effect_style"`, `"side_effect"`, `"style"`, `"index"`, +`"sibling"`, `"parent"`, `"subpath"`, `"internal"`, `"builtin"`, `"external"`, `"import"` + ###### overrides[n].options.experimentalSortImports.groups type: `array` @@ -524,8 +558,8 @@ You may enter modifiers in any order, but the selector must always come at the e The list of selectors is sorted from most to least important: - `type` — TypeScript type imports. -- `side-effect-style` — Side effect style imports. -- `side-effect` — Side effect imports. +- `side_effect_style` — Side effect style imports. +- `side_effect` — Side effect imports. - `style` — Style imports. - `index` — Main file from the current directory. - `sibling` — Modules from the same directory. @@ -538,16 +572,12 @@ The list of selectors is sorted from most to least important: The list of modifiers is sorted from most to least important: -- `side-effect` — Side effect imports. +- `side_effect` — Side effect imports. - `type` — TypeScript type imports. - `value` — Value imports. - `default` — Imports containing the default specifier. - `wildcard` — Imports containing the wildcard (`* as`) specifier. - `named` — Imports containing at least one named specifier. -- `multiline` — Imports on multiple lines. -- `singleline` — Imports on a single line. - -See also for details. - Default: See below @@ -567,10 +597,6 @@ See also for details. type: `array | string` -######## overrides[n].options.experimentalSortImports.groups[n][n] - -type: `string` - ###### overrides[n].options.experimentalSortImports.ignoreCase type: `boolean` diff --git a/src/docs/guide/usage/linter/generated-cli.md b/src/docs/guide/usage/linter/generated-cli.md index 620b5990faa..8fd77594762 100644 --- a/src/docs/guide/usage/linter/generated-cli.md +++ b/src/docs/guide/usage/linter/generated-cli.md @@ -11,7 +11,8 @@ search: false - **`-c`**, **`--config`**=_`<./.oxlintrc.json>`_ — Oxlint configuration file -* only `.json` extension is supported +* `.json` config files are supported in all runtimes +* JavaScript/TypeScript config files are experimental and require running via Node.js * you can use comments in configuration files. * tries to be compatible with ESLint v8's format diff --git a/src/docs/guide/usage/linter/rules/eslint/array-callback-return.md b/src/docs/guide/usage/linter/rules/eslint/array-callback-return.md index 630a4b48624..ad9e679af02 100644 --- a/src/docs/guide/usage/linter/rules/eslint/array-callback-return.md +++ b/src/docs/guide/usage/linter/rules/eslint/array-callback-return.md @@ -3,7 +3,7 @@ title: "eslint/array-callback-return" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/eslint/no-case-declarations.md b/src/docs/guide/usage/linter/rules/eslint/no-case-declarations.md index f07fee23037..272da70a8d5 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-case-declarations.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-case-declarations.md @@ -3,7 +3,7 @@ title: "eslint/no-case-declarations" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- 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 16b7f50c999..ceb93824754 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 @@ -3,7 +3,7 @@ title: "eslint/no-empty-function" category: "Restriction" default: false type_aware: false -fix: "none" +fix: "pending" --- @@ -17,47 +17,13 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin ### What it does -Disallows the usages of empty functions +Disallows the usage of empty functions. ### Why is this bad? 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. -### Options - -#### 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 -{ - "no-empty-function": ["error", { "allow": ["functions"] }] -} -``` - -`allow` accepts the following values: - -- `"functions"` -- `"arrowFunctions"` -- `"generatorFunctions"` -- `"methods"` -- `"generatorMethods"` -- `"getters"` -- `"setters"` -- `"constructors"` -- `"privateConstructors"` -- `"protectedConstructors"` -- `"asyncFunctions"` -- `"asyncMethods"` -- `"decoratedFunctions"` -- `"overrideMethods"` - ### Examples Examples of **incorrect** code for this rule: @@ -97,6 +63,166 @@ class Foo { } ``` +## Configuration + +This rule accepts a configuration object with the following properties: + +### allow + +type: `array` + +Types of functions that are allowed to be empty. + +By default, no function kinds are allowed to be empty, but this option can be used to +permit specific kinds of functions. + +Example: + +```json +{ + "no-empty-function": ["error", { "allow": ["constructors"] }] +} +``` + +#### allow[n] + +type: `"functions" | "arrowFunctions" | "generatorFunctions" | "methods" | "generatorMethods" | "getters" | "setters" | "constructors" | "asyncFunctions" | "asyncMethods" | "privateConstructors" | "protectedConstructors" | "decoratedFunctions" | "overrideMethods"` + +Kinds of functions that can be allowed to be empty. + +##### `"functions"` + +Allow empty regular functions. + +```js +function foo() {} +``` + +##### `"arrowFunctions"` + +Allow empty arrow functions. + +```js +const foo = () => {}; +``` + +##### `"generatorFunctions"` + +Allow empty generator functions. + +```js +function* foo() {} +``` + +##### `"methods"` + +Allow empty methods. + +```js +class Foo { + bar() {} +} +``` + +##### `"generatorMethods"` + +Allow empty generator methods. + +```js +class Foo { + *bar() {} +} +``` + +##### `"getters"` + +Allow empty getters. + +```js +class Foo { + get bar() {} +} +``` + +##### `"setters"` + +Allow empty setters. + +```js +class Foo { + set bar(value) {} +} +``` + +##### `"constructors"` + +Allow empty constructors. + +```js +class Foo { + constructor() {} +} +``` + +##### `"asyncFunctions"` + +Allow empty async functions. + +```js +async function foo() {} +``` + +##### `"asyncMethods"` + +Allow empty async methods. + +```js +class Foo { + async bar() {} +} +``` + +##### `"privateConstructors"` + +Allow empty private constructors. + +```ts +class Foo { + private constructor() {} +} +``` + +##### `"protectedConstructors"` + +Allow empty protected constructors. + +```ts +class Foo { + protected constructor() {} +} +``` + +##### `"decoratedFunctions"` + +Allow empty decorated functions. + +```js +class Foo { + @decorator() + bar() {} +} +``` + +##### `"overrideMethods"` + +Allow empty override methods. + +```ts +class Foo extends Base { + override bar() {} +} +``` + ## How to use To **enable** this rule using the config file or in the CLI, you can use: diff --git a/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md b/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md index 2362757d6d0..f63072918cf 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md @@ -3,7 +3,7 @@ title: "eslint/no-misleading-character-class" category: "Correctness" default: true type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.md b/src/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.md index 067b689318d..19187a24702 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.md @@ -3,7 +3,7 @@ title: "eslint/no-promise-executor-return" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.md b/src/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.md index a6e8f4316b8..88c718b8012 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.md @@ -3,7 +3,7 @@ title: "eslint/no-prototype-builtins" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/eslint/no-return-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-return-assign.md index 5814297ca6b..2290b5b7616 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-return-assign.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-return-assign.md @@ -3,7 +3,7 @@ title: "eslint/no-return-assign" category: "Style" default: false type_aware: false -fix: "pending" +fix: "none" --- 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 35a50497520..fb98f31d927 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 @@ -18,11 +18,11 @@ 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`. +`eval`, `globalThis` and `arguments`. ### Why is this bad? -Value properties of the Global Object `NaN`, `Infinity`, `undefined` as well as the strict +Value properties of the Global Object `NaN`, `Infinity`, `undefined`, `globalThis` as well as the strict mode restricted identifiers `eval` and `arguments` are considered to be restricted names in JavaScript. Defining them to mean something else can have unintended consequences and confuse others reading the code. For example, there’s nothing preventing you from @@ -48,6 +48,8 @@ var undefined = 5; try { } catch (eval) {} + +const globalThis = "foo"; ``` ```javascript @@ -81,7 +83,7 @@ This rule accepts a configuration object with the following properties: type: `boolean` -default: `false` +default: `true` If true, also report shadowing of `globalThis`. diff --git a/src/docs/guide/usage/linter/rules/eslint/no-shadow.md b/src/docs/guide/usage/linter/rules/eslint/no-shadow.md new file mode 100644 index 00000000000..64f2e75d5be --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-shadow.md @@ -0,0 +1,144 @@ +--- +title: "eslint/no-shadow" +category: "Suspicious" +default: false +type_aware: false +fix: "none" +--- + + + + + + + +### What it does + +Disallows variable declarations from shadowing variables declared in the outer scope. + +### Why is this bad? + +Shadowing is the process by which a local variable shares the same name as a variable +in its containing scope. This can cause confusion, as it may be unclear which variable +is being referenced, and can lead to bugs that are difficult to diagnose. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +var x = 1; +function foo() { + var x = 2; // x shadows the outer x +} +``` + +Examples of **correct** code for this rule: + +```js +var x = 1; +function foo() { + var y = 2; // different name, no shadowing +} +``` + +## Configuration + +This rule accepts a configuration object with the following properties: + +### allow + +type: `string[]` + +default: `[]` + +List of variable names that are allowed to shadow. + +### builtinGlobals + +type: `boolean` + +default: `false` + +Whether to report shadowing of built-in global variables. + +### hoist + +type: `"all" | "functions" | "functions-and-types" | "never" | "types"` + +default: `"functions-and-types"` + +Controls how hoisting is handled when checking for shadowing. + +#### `"all"` + +Report shadowing even before the outer variable is declared (due to hoisting). + +#### `"functions"` + +Only report shadowing for function declarations that are hoisted. + +#### `"functions-and-types"` + +Report shadowing for both function and type declarations that are hoisted. + +#### `"never"` + +Never report shadowing before the outer variable is declared. + +#### `"types"` + +Only report shadowing for type declarations that are hoisted. + +### ignoreFunctionTypeParameterNameValueShadow + +type: `boolean` + +default: `true` + +If `true`, ignore when a function type parameter shadows a value. +Example: `const T = 1; function foo() {}` + +### ignoreOnInitialization + +type: `boolean` + +default: `false` + +Whether to ignore the variable initializers when the shadowed variable is presumably still uninitialized. + +### ignoreTypeValueShadow + +type: `boolean` + +default: `true` + +If `true`, ignore when a type and a value have the same name. +This is common in TypeScript: `type Foo = ...; const Foo = ...;` + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "no-shadow": "error" + } +} +``` + +```bash [CLI] +oxlint --deny no-shadow +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unmodified-loop-condition.md b/src/docs/guide/usage/linter/rules/eslint/no-unmodified-loop-condition.md new file mode 100644 index 00000000000..8d9cd7ff437 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-unmodified-loop-condition.md @@ -0,0 +1,69 @@ +--- +title: "eslint/no-unmodified-loop-condition" +category: "Suspicious" +default: false +type_aware: false +fix: "none" +--- + + + + + + + +### What it does + +Disallow references in loop conditions that are never modified within the loop. + +### Why is this bad? + +A loop condition that depends on values that never change within the loop body +can cause infinite loops or logic bugs. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +let done = false; +while (!done) { + work(); +} +``` + +Examples of **correct** code for this rule: + +```js +let done = false; +while (!done) { + done = checkDone(); +} +``` + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "no-unmodified-loop-condition": "error" + } +} +``` + +```bash [CLI] +oxlint --deny no-unmodified-loop-condition +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.md b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.md index 75407108172..cc288163d2c 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.md @@ -33,23 +33,20 @@ as `(!a) in b` instead of `!(a in b)`, which is not the intended logic. Examples of **incorrect** code for this rule: + ```javascript -if ((!key) in object) { -} +if (!key in object) {} -if ((!obj) instanceof Ctor) { -} +if (!obj instanceof Ctor) {} ``` Examples of **correct** code for this rule: - ```javascript -if (!(key in object)) { -} +if (!(key in object)) {} -if (!(obj instanceof Ctor)) { -} +if (!(obj instanceof Ctor)) {} ``` + ## Configuration diff --git a/src/docs/guide/usage/linter/rules/eslint/require-await.md b/src/docs/guide/usage/linter/rules/eslint/require-await.md index 4c5b65fccac..ce3da30c7f7 100644 --- a/src/docs/guide/usage/linter/rules/eslint/require-await.md +++ b/src/docs/guide/usage/linter/rules/eslint/require-await.md @@ -19,6 +19,12 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin Disallow async functions which have no `await` expression. +::: warning NOTE +This rule is inferior to the accuracy of the type-aware +`typescript/require-await` rule. If using type-aware +rules, always prefer that rule over this one. +::: + ### Why is this bad? Asynchronous functions in JavaScript behave differently than other @@ -39,14 +45,14 @@ async function fetchData(processDataItem) { } ``` -Asynchronous functions that don’t use await might not need to be +Asynchronous functions that don’t use `await` might not need to be asynchronous functions and could be the unintentional result of refactoring. Note: this rule ignores async generator functions. This is because generators yield rather than return a value and async generators might yield all the values of another async generator without ever actually -needing to use await. +needing to use `await`. ### Examples diff --git a/src/docs/guide/usage/linter/rules/jest/no-done-callback.md b/src/docs/guide/usage/linter/rules/jest/no-done-callback.md index 33ce460b256..b5a5758f4bb 100644 --- a/src/docs/guide/usage/linter/rules/jest/no-done-callback.md +++ b/src/docs/guide/usage/linter/rules/jest/no-done-callback.md @@ -3,7 +3,7 @@ title: "jest/no-done-callback" category: "Style" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jest/prefer-equality-matcher.md b/src/docs/guide/usage/linter/rules/jest/prefer-equality-matcher.md index f5479663395..f781d46780f 100644 --- a/src/docs/guide/usage/linter/rules/jest/prefer-equality-matcher.md +++ b/src/docs/guide/usage/linter/rules/jest/prefer-equality-matcher.md @@ -3,7 +3,7 @@ title: "jest/prefer-equality-matcher" category: "Style" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jest/valid-expect.md b/src/docs/guide/usage/linter/rules/jest/valid-expect.md index f863a0f8064..b14c69d1284 100644 --- a/src/docs/guide/usage/linter/rules/jest/valid-expect.md +++ b/src/docs/guide/usage/linter/rules/jest/valid-expect.md @@ -3,7 +3,7 @@ title: "jest/valid-expect" category: "Correctness" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md b/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md index 65acdb0ed48..8747edd5ae5 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md @@ -3,7 +3,7 @@ title: "jsdoc/check-property-names" category: "Correctness" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md b/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md index ede5caa5c3b..8748a3015ad 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md @@ -3,7 +3,7 @@ title: "jsdoc/check-tag-names" category: "Correctness" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md b/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md index 0fee058ea6c..14ec04f87b7 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md @@ -3,7 +3,7 @@ title: "jsdoc/empty-tags" category: "Restriction" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md b/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md index 3bb76c3a586..8b6586e584b 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md @@ -3,7 +3,7 @@ title: "jsdoc/no-defaults" category: "Correctness" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md index ce7cd4ba763..872a9e052d0 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md @@ -3,7 +3,7 @@ title: "jsdoc/require-param-description" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md index e6ed06004d6..10667b7813f 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md @@ -3,7 +3,7 @@ title: "jsdoc/require-param-type" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param.md index b2e464afdc9..a269ce0b088 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-param.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param.md @@ -3,7 +3,7 @@ title: "jsdoc/require-param" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property.md index 1ee73d6b1c9..a88e0503d10 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-property.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property.md @@ -3,7 +3,7 @@ title: "jsdoc/require-property" category: "Correctness" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md b/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md index f8b1dca6b44..78067243804 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md @@ -3,7 +3,7 @@ title: "jsdoc/require-returns" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/no-static-element-interactions.md b/src/docs/guide/usage/linter/rules/jsx_a11y/no-static-element-interactions.md index 1e89d2323a2..292cef38169 100644 --- a/src/docs/guide/usage/linter/rules/jsx_a11y/no-static-element-interactions.md +++ b/src/docs/guide/usage/linter/rules/jsx_a11y/no-static-element-interactions.md @@ -1,6 +1,6 @@ --- title: "jsx-a11y/no-static-element-interactions" -category: "Nursery" +category: "Correctness" default: false type_aware: false fix: "none" 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 index 1d44ab503be..9cc23b2183f 100644 --- a/src/docs/guide/usage/linter/rules/react/forbid-dom-props.md +++ b/src/docs/guide/usage/linter/rules/react/forbid-dom-props.md @@ -45,14 +45,33 @@ Examples of **correct** code for this rule: ``` -### Options +## Configuration -#### forbid +Configuration for the `forbid-dom-props` rule. -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.
) +This rule accepts a configuration object with the following properties: -`{"propName": "someProp", "disallowedFor": ["DOMNode", "AnotherDOMNode"], "message": "Avoid using someProp" }` +### forbid + +type: `array` + +An array of prop names or objects that are forbidden on DOM elements. + +Each array element can be a string with the property name, or an object +with `propName`, an optional `disallowedFor` array of DOM node names, +and an optional custom `message`. + +Examples: + +- `["error", { "forbid": ["id", "style"] }]` +- `["error", { "forbid": [{ "propName": "className", "message": "Use class instead" }] }]` +- `["error", { "forbid": [{ "propName": "style", "disallowedFor": ["div", "span"] }] }]` + +#### forbid[n] + +type: `string` + +A forbidden prop, either as a plain prop name string or with options. ## How to use diff --git a/src/docs/guide/usage/linter/rules/react/jsx-no-constructed-context-values.md b/src/docs/guide/usage/linter/rules/react/jsx-no-constructed-context-values.md new file mode 100644 index 00000000000..afb3ecd2d4e --- /dev/null +++ b/src/docs/guide/usage/linter/rules/react/jsx-no-constructed-context-values.md @@ -0,0 +1,84 @@ +--- +title: "react/jsx-no-constructed-context-values" +category: "Perf" +default: false +type_aware: false +fix: "none" +--- + + + + + + + +### What it does + +Disallows JSX context provider values from taking values that will cause needless rerenders. + +### Why is this bad? + +React Context and all its child nodes and Consumers are rerendered whenever the value prop +changes. Because each JavaScript object carries its own identity, things like object +expressions (`{foo: 'bar'}`) or function expressions get a new identity on every render. +This makes the context think it has gotten a new object and can cause needless rerenders +and unintended consequences. + +This can be a large performance hit because not only will it cause the context providers +and consumers to rerender with all the elements in its subtree, the processing for the +tree scan React does to render the provider and find consumers is also wasted. + +### Examples + +Examples of **incorrect** code for this rule: + +```jsx +return ...; +``` + +```jsx +function Component() { + function foo() {} + return ; +} +``` + +Examples of **correct** code for this rule: + +```jsx +const foo = useMemo(() => ({ foo: "bar" }), []); +return ...; +``` + +```jsx +const MyContext = createContext(); +const Component = () => ; +``` + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["react"], + "rules": { + "react/jsx-no-constructed-context-values": "error" + } +} +``` + +```bash [CLI] +oxlint --deny react/jsx-no-constructed-context-values --react-plugin +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/react/jsx-no-target-blank.md b/src/docs/guide/usage/linter/rules/react/jsx-no-target-blank.md index 879ddf69f7b..01cfa7fb497 100644 --- a/src/docs/guide/usage/linter/rules/react/jsx-no-target-blank.md +++ b/src/docs/guide/usage/linter/rules/react/jsx-no-target-blank.md @@ -3,7 +3,7 @@ title: "react/jsx-no-target-blank" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/react/no-unescaped-entities.md b/src/docs/guide/usage/linter/rules/react/no-unescaped-entities.md index 2f3d0b3f230..1bd965b2845 100644 --- a/src/docs/guide/usage/linter/rules/react/no-unescaped-entities.md +++ b/src/docs/guide/usage/linter/rules/react/no-unescaped-entities.md @@ -3,7 +3,7 @@ title: "react/no-unescaped-entities" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/typescript/no-empty-interface.md b/src/docs/guide/usage/linter/rules/typescript/no-empty-interface.md index ebee48ba5b5..bd88403b7c2 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-empty-interface.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-empty-interface.md @@ -3,7 +3,7 @@ title: "typescript/no-empty-interface" category: "Style" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/typescript/no-empty-object-type.md b/src/docs/guide/usage/linter/rules/typescript/no-empty-object-type.md index 807cbad850e..63d9e9d5ec7 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-empty-object-type.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-empty-object-type.md @@ -3,7 +3,7 @@ title: "typescript/no-empty-object-type" category: "Restriction" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/typescript/no-extra-non-null-assertion.md b/src/docs/guide/usage/linter/rules/typescript/no-extra-non-null-assertion.md index 025e66d6439..17604fbf972 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-extra-non-null-assertion.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-extra-non-null-assertion.md @@ -3,7 +3,7 @@ title: "typescript/no-extra-non-null-assertion" category: "Correctness" default: true type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/typescript/no-non-null-asserted-nullish-coalescing.md b/src/docs/guide/usage/linter/rules/typescript/no-non-null-asserted-nullish-coalescing.md index cd2770c0029..e8a5e5028d7 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-non-null-asserted-nullish-coalescing.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-non-null-asserted-nullish-coalescing.md @@ -3,7 +3,7 @@ title: "typescript/no-non-null-asserted-nullish-coalescing" category: "Restriction" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/typescript/no-non-null-assertion.md b/src/docs/guide/usage/linter/rules/typescript/no-non-null-assertion.md index 063a3d083b5..bb96e63599c 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-non-null-assertion.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-non-null-assertion.md @@ -3,7 +3,7 @@ title: "typescript/no-non-null-assertion" category: "Restriction" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-boolean-literal-compare.md b/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-boolean-literal-compare.md index 11b183d36cf..359d13eba8a 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-boolean-literal-compare.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-boolean-literal-compare.md @@ -3,7 +3,7 @@ title: "typescript/no-unnecessary-boolean-literal-compare" category: "Suspicious" default: false type_aware: true -fix: "none" +fix: "pending" --- @@ -92,15 +92,6 @@ default: `true` Whether to allow comparing nullable boolean expressions to `true`. When false, `x === true` where x is `boolean | null` will be flagged. -### allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing - -type: `boolean` - -default: `false` - -Whether to allow this rule to run without `strictNullChecks` enabled. -This is not recommended as the rule may produce incorrect results. - ## How to use To **enable** this rule using the config file or in the CLI, you can use: diff --git a/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-condition.md b/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-condition.md new file mode 100644 index 00000000000..7a7f57f4e46 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-condition.md @@ -0,0 +1,115 @@ +--- +title: "typescript/no-unnecessary-condition" +category: "Nursery" +default: false +type_aware: true +fix: "none" +--- + + + + + + + +### What it does + +Disallow conditions that are always truthy, always falsy, or always nullish +based on TypeScript's type information. + +### Why is this bad? + +Conditions with no possible runtime variation make code harder to read and can +hide logic errors. They often leave dead branches and suggest that the declared +types do not match the intended behavior. + +### Examples + +Examples of **incorrect** code for this rule: + +```ts +declare const value: null; +if (value) { + doWork(); +} + +const items: string[] = []; +if (items) { + doWork(); +} + +declare const status: "ready"; +if (!status) { + reportError(); +} +``` + +Examples of **correct** code for this rule: + +```ts +declare const maybeUser: User | undefined; +if (maybeUser) { + doWork(maybeUser); +} + +const items: string[] = []; +if (items.length > 0) { + doWork(); +} + +declare const status: "ready" | ""; +if (!status) { + reportError(); +} +``` + +## Configuration + +This rule accepts a configuration object with the following properties: + +### allowConstantLoopConditions + +type: `boolean | "never" | "always" | "only-allowed-literals"` + +Represents the different ways `allowConstantLoopConditions` can be specified in JSON. +Can be: + +- `true` or `false` +- A string enum (`"never"`, `"always"`, `"only-allowed-literals"`) + +### checkTypePredicates + +type: `boolean` + +default: `false` + +Whether to check type predicate functions. + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "typescript/no-unnecessary-condition": "error" + } +} +``` + +```bash [CLI] +oxlint --type-aware --deny typescript/no-unnecessary-condition +``` + +::: + +## References + +- Rule Source +- Rule Source (tsgolint) diff --git a/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-constraint.md b/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-constraint.md index 70d456caed4..cbb6dd49fc1 100644 --- a/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-constraint.md +++ b/src/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-constraint.md @@ -3,7 +3,7 @@ title: "typescript/no-unnecessary-type-constraint" category: "Suspicious" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/typescript/no-use-before-define.md b/src/docs/guide/usage/linter/rules/typescript/no-use-before-define.md new file mode 100644 index 00000000000..9f7561f94e1 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/typescript/no-use-before-define.md @@ -0,0 +1,125 @@ +--- +title: "typescript/no-use-before-define" +category: "Restriction" +default: false +type_aware: false +fix: "none" +--- + + + + + + + +### What it does + +Disallows using variables before they are defined. + +### Why is this bad? + +Referencing identifiers before their declarations can hide bugs and +make code order-dependent and difficult to reason about. + +### Examples + +Examples of **incorrect** code for this rule: + +```ts +new A(); +var A = class {}; +``` + +Examples of **correct** code for this rule: + +```ts +var A = class {}; +new A(); +``` + +## Configuration + +This rule accepts a configuration object with the following properties: + +### allowNamedExports + +type: `boolean` + +default: `false` + +Allow named exports that appear before declaration. + +### classes + +type: `boolean` + +default: `true` + +Check class declarations. + +### enums + +type: `boolean` + +default: `true` + +Check enum declarations. + +### functions + +type: `boolean` + +default: `true` + +Check function declarations. + +### ignoreTypeReferences + +type: `boolean` + +default: `true` + +Ignore usages that are type-only references. + +### typedefs + +type: `boolean` + +default: `true` + +Check type aliases, interfaces, and type parameters. + +### variables + +type: `boolean` + +default: `true` + +Check variable declarations. + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "typescript/no-use-before-define": "error" + } +} +``` + +```bash [CLI] +oxlint --deny typescript/no-use-before-define +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/typescript/parameter-properties.md b/src/docs/guide/usage/linter/rules/typescript/parameter-properties.md new file mode 100644 index 00000000000..9574e73e226 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/typescript/parameter-properties.md @@ -0,0 +1,117 @@ +--- +title: "typescript/parameter-properties" +category: "Style" +default: false +type_aware: false +fix: "none" +--- + + + + + + + +### What it does + +Requires or disallows parameter properties in class constructors. + +### Why is this bad? + +Mixing parameter properties and class property declarations can make +class style inconsistent and harder to maintain. + +### Examples + +#### `{ "prefer": "class-property" }` (default) + +Examples of **incorrect** code for this rule: + +```ts +class Foo { + constructor(private name: string) {} +} +``` + +Examples of **correct** code for this rule: + +```ts +class Foo { + name: string; + constructor(name: string) { + this.name = name; + } +} +``` + +#### `{ "prefer": "parameter-property" }` + +Examples of **incorrect** code for this rule: + +```ts +class Foo { + name: string; + constructor(name: string) { + this.name = name; + } +} +``` + +Examples of **correct** code for this rule: + +```ts +class Foo { + constructor(private name: string) {} +} +``` + +## Configuration + +This rule accepts a configuration object with the following properties: + +### allow + +type: `array` + +default: `[]` + +Modifiers that are allowed to be used with parameter properties or class properties, depending on the `prefer` option. + +#### allow[n] + +type: `"private" | "private readonly" | "protected" | "protected readonly" | "public" | "public readonly" | "readonly"` + +### prefer + +type: `"class-property" | "parameter-property"` + +default: `"class-property"` + +Whether to prefer parameter properties or class properties. + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "typescript/parameter-properties": "error" + } +} +``` + +```bash [CLI] +oxlint --deny typescript/parameter-properties +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/typescript/prefer-nullish-coalescing.md b/src/docs/guide/usage/linter/rules/typescript/prefer-nullish-coalescing.md index 59cfe56f864..fa37c48ee30 100644 --- a/src/docs/guide/usage/linter/rules/typescript/prefer-nullish-coalescing.md +++ b/src/docs/guide/usage/linter/rules/typescript/prefer-nullish-coalescing.md @@ -73,18 +73,6 @@ const bool = Boolean(x || y); This rule accepts a configuration object with the following properties: -### allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing - -type: `boolean` - -default: `false` - -Unless this is set to `true`, the rule will error on every file whose -`tsconfig.json` does _not_ have the `strictNullChecks` compiler option -(or `strict`) set to `true`. - -It is _not_ recommended to enable this config option. - ### ignoreBooleanCoercion type: `boolean` diff --git a/src/docs/guide/usage/linter/rules/typescript/strict-boolean-expressions.md b/src/docs/guide/usage/linter/rules/typescript/strict-boolean-expressions.md index 5796963a62a..dec04244b8c 100644 --- a/src/docs/guide/usage/linter/rules/typescript/strict-boolean-expressions.md +++ b/src/docs/guide/usage/linter/rules/typescript/strict-boolean-expressions.md @@ -3,7 +3,7 @@ title: "typescript/strict-boolean-expressions" category: "Pedantic" default: false type_aware: true -fix: "none" +fix: "pending" --- @@ -150,15 +150,6 @@ default: `true` Whether to allow number types in boolean contexts (checks for non-zero numbers). -### allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing - -type: `boolean` - -default: `false` - -Whether to allow this rule to run without `strictNullChecks` enabled. -This is not recommended as the rule may produce incorrect results. - ### allowString type: `boolean` diff --git a/src/docs/guide/usage/linter/rules/typescript/unified-signatures.md b/src/docs/guide/usage/linter/rules/typescript/unified-signatures.md new file mode 100644 index 00000000000..70d57be5f76 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/typescript/unified-signatures.md @@ -0,0 +1,88 @@ +--- +title: "typescript/unified-signatures" +category: "Style" +default: false +type_aware: false +fix: "none" +--- + + + + + + + +### What it does + +Disallow overload signatures that can be unified into one. + +### Why is this bad? + +Duplicate overload signatures that only differ by a single type, or by an optional/rest +parameter, are harder to maintain and read than a single unified signature. + +### Examples + +Examples of **incorrect** code for this rule: + +```ts +function f(a: number): void; +function f(a: string): void; +``` + +Examples of **correct** code for this rule: + +```ts +function f(a: number | string): void; +``` + +## Configuration + +This rule accepts a configuration object with the following properties: + +### ignoreDifferentlyNamedParameters + +type: `boolean` + +default: `false` + +Whether to ignore parameter name differences when comparing signatures. If `false`, signatures +will not be considered unifiable if they have parameters in the same position with different +names, even if the parameter types are the same. + +### ignoreOverloadsWithDifferentJSDoc + +type: `boolean` + +default: `false` + +Whether to ignore JSDoc differences when comparing signatures. If `false`, signatures will not +be considered unifiable if the closest leading block comments for the signatures are different, +even if the signatures themselves are identical. + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "typescript/unified-signatures": "error" + } +} +``` + +```bash [CLI] +oxlint --deny typescript/unified-signatures +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/unicorn/new-for-builtins.md b/src/docs/guide/usage/linter/rules/unicorn/new-for-builtins.md index 2ca9c093058..4572d7c96e1 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/new-for-builtins.md +++ b/src/docs/guide/usage/linter/rules/unicorn/new-for-builtins.md @@ -3,7 +3,7 @@ title: "unicorn/new-for-builtins" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.md b/src/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.md index 2e4ca7d0c30..5e6331c931f 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.md +++ b/src/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.md @@ -3,7 +3,7 @@ title: "unicorn/no-anonymous-default-export" category: "Restriction" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md b/src/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md index 08aab711a67..957a3d32f31 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md +++ b/src/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md @@ -3,7 +3,7 @@ title: "unicorn/no-await-in-promise-methods" category: "Correctness" default: true type_aware: false -fix: "none" +fix: "fixable_suggestion" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-instanceof-builtins.md b/src/docs/guide/usage/linter/rules/unicorn/no-instanceof-builtins.md index df776b6496a..cd1dcd41f08 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/no-instanceof-builtins.md +++ b/src/docs/guide/usage/linter/rules/unicorn/no-instanceof-builtins.md @@ -3,7 +3,7 @@ title: "unicorn/no-instanceof-builtins" category: "Suspicious" default: false type_aware: false -fix: "pending" +fix: "conditional_suggestion" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-lonely-if.md b/src/docs/guide/usage/linter/rules/unicorn/no-lonely-if.md index 41d3262da12..06999c8f5b5 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/no-lonely-if.md +++ b/src/docs/guide/usage/linter/rules/unicorn/no-lonely-if.md @@ -3,7 +3,7 @@ title: "unicorn/no-lonely-if" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-new-buffer.md b/src/docs/guide/usage/linter/rules/unicorn/no-new-buffer.md index f968a29252b..87e2240bc6a 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/no-new-buffer.md +++ b/src/docs/guide/usage/linter/rules/unicorn/no-new-buffer.md @@ -3,7 +3,7 @@ title: "unicorn/no-new-buffer" category: "Pedantic" default: false type_aware: false -fix: "pending" +fix: "fixable_suggestion" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.md b/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.md index 912b52b6f5d..ccbb322925b 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.md +++ b/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.md @@ -3,7 +3,7 @@ title: "unicorn/no-unreadable-array-destructuring" category: "Style" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/number-literal-case.md b/src/docs/guide/usage/linter/rules/unicorn/number-literal-case.md index ee98808419b..07618ad8735 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/number-literal-case.md +++ b/src/docs/guide/usage/linter/rules/unicorn/number-literal-case.md @@ -21,36 +21,38 @@ This rule enforces proper case for numeric literals. ### Why is this bad? -When both an identifier and a number literal are in lower case, it can be hard to differentiate between them. +When both an identifier and a numeric literal are in +lower case, it can be hard to differentiate between them. ### Examples Examples of **incorrect** code for this rule: + ```javascript +const foo = 0XFF; const foo = 0xff; -const foo = 0xff; -const foo = 0xff; -const foo = 0xffn; +const foo = 0Xff; +const foo = 0Xffn; -const foo = 0b10; -const foo = 0b10n; +const foo = 0B10; +const foo = 0B10n; -const foo = 0o76; -const foo = 0o76n; +const foo = 0O76; +const foo = 0O76n; -const foo = 2e-5; +const foo = 2E-5; ``` Examples of **correct** code for this rule: - ```javascript -const foo = 0xff; +const foo = 0xFF; const foo = 0b10; const foo = 0o76; -const foo = 0xffn; -const foo = 2e5; +const foo = 0xFFn; +const foo = 2e+5; ``` + ## How to use diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.md index fed247eb475..a63b57e40f4 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.md +++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.md @@ -3,7 +3,7 @@ title: "unicorn/prefer-dom-node-remove" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-includes.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-includes.md index f5ac0a5e659..6078c5c0631 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/prefer-includes.md +++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-includes.md @@ -3,7 +3,7 @@ title: "unicorn/prefer-includes" category: "Style" default: false type_aware: false -fix: "pending" +fix: "fixable_suggestion" --- diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.md index 7363828824a..7a2a3c98d58 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.md +++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.md @@ -3,7 +3,7 @@ title: "unicorn/prefer-top-level-await" category: "Pedantic" default: false type_aware: false -fix: "none" +fix: "pending" --- diff --git a/src/docs/guide/usage/linter/rules/version.data.js b/src/docs/guide/usage/linter/rules/version.data.js index 4f395a66a3f..97256790f0e 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 "70355d99056a60e015618795f755bf7124391013"; + return "7673818e81e030dce4f5f70f023b8756a38049ba"; }, }; diff --git a/src/docs/guide/usage/rule-count.data.js b/src/docs/guide/usage/rule-count.data.js index 860545fb7fc..b37df5fe472 100644 --- a/src/docs/guide/usage/rule-count.data.js +++ b/src/docs/guide/usage/rule-count.data.js @@ -1,5 +1,5 @@ export default { load() { - return 670; + return 677; }, };