From 50287fc7b25d19d08af8302ed450353ec3a2ba43 Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Mon, 8 Dec 2025 09:19:07 +0000 Subject: [PATCH 1/2] Release 1.32.0 --- .../guide/usage/formatter/generated-cli.md | 45 ++++--- .../guide/usage/formatter/generated-config.md | 67 ++++++++++- src/docs/guide/usage/linter/generated-cli.md | 2 - .../guide/usage/linter/generated-rules.md | 7 +- .../linter/rules/eslint/arrow-body-style.md | 8 +- .../rules/eslint/max-lines-per-function.md | 2 +- .../linter/rules/eslint/no-useless-return.md | 89 ++++++++++++++ .../linter/rules/jest/consistent-test-it.md | 2 +- .../usage/linter/rules/jest/expect-expect.md | 23 ++-- .../linter/rules/jest/no-alias-methods.md | 2 +- .../rules/jest/no-commented-out-tests.md | 2 +- .../linter/rules/jest/no-disabled-tests.md | 2 +- .../linter/rules/jest/no-focused-tests.md | 2 +- .../linter/rules/jest/no-identical-title.md | 2 +- .../linter/rules/jest/no-test-prefixes.md | 2 +- .../rules/jest/prefer-hooks-in-order.md | 2 +- .../rules/jest/valid-describe-callback.md | 2 +- .../usage/linter/rules/jest/valid-expect.md | 2 +- .../rules/jsx_a11y/img-redundant-alt.md | 24 ++-- .../usage/linter/rules/react/jsx-fragments.md | 13 +-- .../linter/rules/typescript/ban-ts-comment.md | 22 ++++ .../linter/rules/unicorn/filename-case.md | 110 +++++++++++++----- .../guide/usage/linter/rules/version.data.js | 2 +- 23 files changed, 327 insertions(+), 107 deletions(-) create mode 100644 src/docs/guide/usage/linter/rules/eslint/no-useless-return.md diff --git a/src/docs/guide/usage/formatter/generated-cli.md b/src/docs/guide/usage/formatter/generated-cli.md index 511d2f6cf2..b5c2fa75f6 100644 --- a/src/docs/guide/usage/formatter/generated-cli.md +++ b/src/docs/guide/usage/formatter/generated-cli.md @@ -2,46 +2,53 @@ search: false --- -## Usage -**`oxfmt`** \[**`-c`**=_`PATH`_\] \[_`PATH`_\]... +## Usage + **`oxfmt`** \[**`-c`**=_`PATH`_\] \[_`PATH`_\]... ## Output Options - -- **`--check`** — +- **` --check`** — Check mode - check if files are formatted, also show statistics -- **`--list-different`** — +- **` --list-different`** — List mode - list files that would be changed -## Basic Options -- **`-c`**, **`--config`**=_`PATH`_ — + +## Basic Options +- **`-c`**, **`--config`**=_`PATH`_ — Path to the configuration file -## Ignore Options -- **`--ignore-path`**=_`PATH`_ — + +## Ignore Options +- **` --ignore-path`**=_`PATH`_ — Path to ignore file(s). Can be specified multiple times. If not specified, .gitignore and .prettierignore in the current directory are used. -- **`--with-node-modules`** — +- **` --with-node-modules`** — Format code in node_modules directory (skipped by default) -## Misc Options -- **`--lsp`** — + +## Misc Options +- **` --lsp`** — Start language server protocol (LSP) server -- **`--no-error-on-unmatched-pattern`** — +- **` --no-error-on-unmatched-pattern`** — Do not exit with error when pattern is unmatched -- **`--threads`**=_`INT`_ — +- **` --threads`**=_`INT`_ — Number of threads to use. Set to 1 for using only 1 CPU core. -## Available positional items: -- _`PATH`_ — + +## Available positional items: +- _`PATH`_ — Single file, single path or list of paths. If not provided, current working directory is used. Glob is supported only for exclude patterns like `'!**/fixtures/*.js'`. -## Available options: -- **`-h`**, **`--help`** — + +## Available options: +- **`-h`**, **`--help`** — Prints help information -- **`-V`**, **`--version`** — +- **`-V`**, **`--version`** — Prints version information + + + diff --git a/src/docs/guide/usage/formatter/generated-config.md b/src/docs/guide/usage/formatter/generated-config.md index 093b1cdf5e..6a8c29e456 100644 --- a/src/docs/guide/usage/formatter/generated-config.md +++ b/src/docs/guide/usage/formatter/generated-config.md @@ -3,159 +3,224 @@ search: false --- # Configuration options for the formatter. - Most options are the same as Prettier's options. See also + ## arrowParens type: `string | null` + Include parentheses around a sole arrow function parameter. (Default: "always") + ## bracketSameLine type: `boolean | null` + Put the > of a multi-line JSX element at the end of the last line instead of being alone on the next line. (Default: false) + ## bracketSpacing type: `boolean | null` + Print spaces between brackets in object literals. (Default: true) + ## embeddedLanguageFormatting type: `string | null` + Control whether formats quoted code embedded in the file. (Default: "auto") + ## endOfLine type: `string | null` + Which end of line characters to apply. (Default: "lf") + ## experimentalSortImports type: `object | null` + Experimental: Sort import statements. Disabled by default. + ### experimentalSortImports.groups type: `array | null` + Custom groups configuration for organizing imports. Each array element represents a group, and multiple group names in the same array are treated as one. Accepts both `string` and `string[]` as group elements. + #### experimentalSortImports.groups[n] type: `string[]` + + + + ### experimentalSortImports.ignoreCase type: `boolean` default: `true` + + + ### experimentalSortImports.internalPattern type: `string[]` + + + + ### experimentalSortImports.newlinesBetween type: `boolean` default: `true` + + + ### experimentalSortImports.order type: `string | null` + + + + ### experimentalSortImports.partitionByComment type: `boolean` default: `false` + + + ### experimentalSortImports.partitionByNewline type: `boolean` default: `false` + + + ### experimentalSortImports.sortSideEffects type: `boolean` default: `false` + + + ## ignorePatterns type: `string[]` + Ignore files matching these glob patterns. Current working directory is used as the root. + ## jsxSingleQuote type: `boolean | null` + Use single quotes instead of double quotes in JSX. (Default: false) + ## objectWrap type: `string | null` + How to wrap object literals when they could fit on one line or span multiple lines. (Default: "preserve") NOTE: In addition to Prettier's "preserve" and "collapse", we also support "always". + ## printWidth type: `integer | null` + The line length that the printer will wrap on. (Default: 100) + ## quoteProps type: `string | null` + Change when properties in objects are quoted. (Default: "as-needed") + ## semi type: `boolean | null` + Print semicolons at the ends of statements. (Default: true) + ## singleAttributePerLine type: `boolean | null` + Put each attribute on a new line in JSX. (Default: false) + ## singleQuote type: `boolean | null` + Use single quotes instead of double quotes. (Default: false) + ## tabWidth type: `integer | null` + Number of spaces per indentation level. (Default: 2) + ## trailingComma type: `string | null` + Print trailing commas wherever possible. (Default: "all") + ## useTabs type: `boolean | null` + Use tabs for indentation or spaces. (Default: false) + + + diff --git a/src/docs/guide/usage/linter/generated-cli.md b/src/docs/guide/usage/linter/generated-cli.md index 3226b80fc2..a4f8f5565c 100644 --- a/src/docs/guide/usage/linter/generated-cli.md +++ b/src/docs/guide/usage/linter/generated-cli.md @@ -75,8 +75,6 @@ Arguments: Enable the promise plugin and detect promise usage problems - **`--node-plugin`** — Enable the node plugin and detect node usage problems -- **`--regex-plugin`** — - Enable the regex plugin and detect regex usage problems - **`--vue-plugin`** — Enable the vue plugin and detect vue usage problems diff --git a/src/docs/guide/usage/linter/generated-rules.md b/src/docs/guide/usage/linter/generated-rules.md index a845c29f22..030a42cd40 100644 --- a/src/docs/guide/usage/linter/generated-rules.md +++ b/src/docs/guide/usage/linter/generated-rules.md @@ -6,7 +6,7 @@ search: false The progress of all rule implementations is tracked [here](https://github.com/oxc-project/oxc/issues/481). -- Total number of rules: 618 +- Total number of rules: 619 - Rules turned on by default: 103 **Legend for 'Fixable?' column:** @@ -378,7 +378,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 (106): +## Pedantic (107): Lints which are rather strict or have occasional false positives. @@ -405,6 +405,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-useless-return](/docs/guide/usage/linter/rules/eslint/no-useless-return.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 | | ⚠️🛠️️ | @@ -497,7 +498,7 @@ Code that should be written in a more idiomatic way. | Rule name | Source | Default | Fixable? | | ------------------------------------------------------------------------------------------------------------------------ | ---------- | ------- | -------- | -| [arrow-body-style](/docs/guide/usage/linter/rules/eslint/arrow-body-style.html) | eslint | | 🚧 | +| [arrow-body-style](/docs/guide/usage/linter/rules/eslint/arrow-body-style.html) | eslint | | 🛠️ | | [curly](/docs/guide/usage/linter/rules/eslint/curly.html) | eslint | | 🛠️ | | [default-case-last](/docs/guide/usage/linter/rules/eslint/default-case-last.html) | eslint | | | | [default-param-last](/docs/guide/usage/linter/rules/eslint/default-param-last.html) | eslint | | | diff --git a/src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md b/src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md index 1cc64f9cd1..3458b9900b 100644 --- a/src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md +++ b/src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
-🚧 An auto-fix is planned for this rule, but not implemented at this time. +🛠️ An auto-fix is available for this rule.
@@ -32,13 +32,13 @@ First option: - Type: `string` - Enum: `"always"`, `"as-needed"`, `"never"` -- Default: `"never"` +- Default: `"as-needed"` Possible values: -- `never` enforces no braces where they can be omitted (default) +- `never` enforces no braces around the function body (constrains arrow functions to the role of returning an expression) - `always` enforces braces around the function body -- `as-needed` enforces no braces around the function body (constrains arrow functions to the role of returning an expression) +- `as-needed` enforces no braces where they can be omitted (default) Second option: diff --git a/src/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md b/src/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md index d50fd93403..887361e8e4 100644 --- a/src/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md +++ b/src/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md @@ -61,7 +61,7 @@ function foo() { This rule accepts a configuration object with the following properties: -### iifes +### IIFEs type: `boolean` diff --git a/src/docs/guide/usage/linter/rules/eslint/no-useless-return.md b/src/docs/guide/usage/linter/rules/eslint/no-useless-return.md new file mode 100644 index 0000000000..1ca10361bd --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-useless-return.md @@ -0,0 +1,89 @@ + + + + +# eslint/no-useless-return + +
+ +🚧 An auto-fix is planned for this rule, but not implemented at this time. + +
+ +### What it does + +Disallows redundant return statements. + +### Why is this bad? + +A `return;` statement with nothing after it is redundant, and has no effect +on the runtime behavior of a function. This can be confusing, so it's better +to disallow these redundant statements. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +function foo() { + return; +} + +function bar() { + doSomething(); + return; +} + +function baz() { + if (condition) { + doSomething(); + return; + } +} +``` + +Examples of **correct** code for this rule: + +```js +function foo() { + return 5; +} + +function bar() { + if (condition) { + return; + } + doSomething(); +} + +function baz() { + return doSomething(); +} +``` + +## 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-useless-return": "error" + } +} +``` + +```bash [CLI] +oxlint --deny no-useless-return +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/jest/consistent-test-it.md b/src/docs/guide/usage/linter/rules/jest/consistent-test-it.md index 1bccb28dea..b2f5b1b583 100644 --- a/src/docs/guide/usage/linter/rules/jest/consistent-test-it.md +++ b/src/docs/guide/usage/linter/rules/jest/consistent-test-it.md @@ -58,7 +58,7 @@ describe("foo", function() { ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/consistent-test-it.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jest/expect-expect.md b/src/docs/guide/usage/linter/rules/jest/expect-expect.md index a976fe604e..d6dff0a545 100644 --- a/src/docs/guide/usage/linter/rules/jest/expect-expect.md +++ b/src/docs/guide/usage/linter/rules/jest/expect-expect.md @@ -30,7 +30,7 @@ test("should assert something", () => {}); ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/expect-expect.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { @@ -52,7 +52,7 @@ default: `[]` An array of function names that should also be treated as test blocks. -### assertFunctionNamesJest +### assertFunctionNames type: `string[]` @@ -60,24 +60,15 @@ default: `["expect"]` A list of function names that should be treated as assertion functions. -### assertFunctionNamesVitest - -type: `string[]` - -default: `["expect", "expectTypeOf", "assert", "assertType"]` - -A list of function names that should be treated as assertion functions for Vitest. +NOTE: The default value is `["expect"]` for Jest and +`["expect", "expectTypeOf", "assert", "assertType"]` for Vitest. ## How to use -To **enable** this rule in the CLI or using the config file, you can use: +To **enable** this rule using the config file or in the CLI, you can use: ::: code-group -```bash [CLI] -oxlint --deny jest/expect-expect --jest-plugin -``` - ```json [Config (.oxlintrc.json)] { "plugins": ["jest"], @@ -87,6 +78,10 @@ oxlint --deny jest/expect-expect --jest-plugin } ``` +```bash [CLI] +oxlint --deny jest/expect-expect --jest-plugin +``` + ::: ## References diff --git a/src/docs/guide/usage/linter/rules/jest/no-alias-methods.md b/src/docs/guide/usage/linter/rules/jest/no-alias-methods.md index df7cc7369c..6acbf52129 100644 --- a/src/docs/guide/usage/linter/rules/jest/no-alias-methods.md +++ b/src/docs/guide/usage/linter/rules/jest/no-alias-methods.md @@ -57,7 +57,7 @@ expect(a).toThrow(); ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/no-alias-methods.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jest/no-commented-out-tests.md b/src/docs/guide/usage/linter/rules/jest/no-commented-out-tests.md index d1ec9509ae..41114205cc 100644 --- a/src/docs/guide/usage/linter/rules/jest/no-commented-out-tests.md +++ b/src/docs/guide/usage/linter/rules/jest/no-commented-out-tests.md @@ -35,7 +35,7 @@ Examples of **incorrect** code for this rule: ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/no-commented-out-tests.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jest/no-disabled-tests.md b/src/docs/guide/usage/linter/rules/jest/no-disabled-tests.md index 22060d27bd..6c9f481a4a 100644 --- a/src/docs/guide/usage/linter/rules/jest/no-disabled-tests.md +++ b/src/docs/guide/usage/linter/rules/jest/no-disabled-tests.md @@ -45,7 +45,7 @@ it("foo", () => { ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/no-disabled-tests.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jest/no-focused-tests.md b/src/docs/guide/usage/linter/rules/jest/no-focused-tests.md index fe35c1ebcb..6ecc8a05a2 100644 --- a/src/docs/guide/usage/linter/rules/jest/no-focused-tests.md +++ b/src/docs/guide/usage/linter/rules/jest/no-focused-tests.md @@ -45,7 +45,7 @@ table ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/no-focused-tests.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jest/no-identical-title.md b/src/docs/guide/usage/linter/rules/jest/no-identical-title.md index e071dd4b40..53ed7b4bff 100644 --- a/src/docs/guide/usage/linter/rules/jest/no-identical-title.md +++ b/src/docs/guide/usage/linter/rules/jest/no-identical-title.md @@ -36,7 +36,7 @@ describe("baz", () => { ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/no-identical-title.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jest/no-test-prefixes.md b/src/docs/guide/usage/linter/rules/jest/no-test-prefixes.md index cf0e337416..b34b89a094 100644 --- a/src/docs/guide/usage/linter/rules/jest/no-test-prefixes.md +++ b/src/docs/guide/usage/linter/rules/jest/no-test-prefixes.md @@ -40,7 +40,7 @@ xdescribe("foo"); // invalid ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/no-test-prefixes.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jest/prefer-hooks-in-order.md b/src/docs/guide/usage/linter/rules/jest/prefer-hooks-in-order.md index 016923b49b..125ab2ed53 100644 --- a/src/docs/guide/usage/linter/rules/jest/prefer-hooks-in-order.md +++ b/src/docs/guide/usage/linter/rules/jest/prefer-hooks-in-order.md @@ -116,7 +116,7 @@ describe("foo", () => { ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/prefer-hooks-in-order.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jest/valid-describe-callback.md b/src/docs/guide/usage/linter/rules/jest/valid-describe-callback.md index 9115acf765..ec2905e350 100644 --- a/src/docs/guide/usage/linter/rules/jest/valid-describe-callback.md +++ b/src/docs/guide/usage/linter/rules/jest/valid-describe-callback.md @@ -48,7 +48,7 @@ describe("myFunction", () => ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/valid-describe-callback.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { 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 2886aa7ffc..dc7933de3e 100644 --- a/src/docs/guide/usage/linter/rules/jest/valid-expect.md +++ b/src/docs/guide/usage/linter/rules/jest/valid-expect.md @@ -40,7 +40,7 @@ expect(Promise.resolve("Hi!")).resolves.toBe("Hi!"); ``` This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/valid-expect.md), -to use it, add the following configuration to your `.eslintrc.json`: +to use it, add the following configuration to your `.oxlintrc.json`: ```json { diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/img-redundant-alt.md b/src/docs/guide/usage/linter/rules/jsx_a11y/img-redundant-alt.md index e191576c38..206777a4c9 100644 --- a/src/docs/guide/usage/linter/rules/jsx_a11y/img-redundant-alt.md +++ b/src/docs/guide/usage/linter/rules/jsx_a11y/img-redundant-alt.md @@ -44,33 +44,29 @@ Examples of **correct** code for this rule: This rule accepts a configuration object with the following properties: -### redundantWords +### components type: `string[]` -default: `["image", "photo", "picture"]` +default: `["img"]` -Words considered redundant in alt text that should trigger a warning. +JSX element types to validate (component names) where the rule applies. +For example, `["img", "Image"]`. -### typesToValidate +### words type: `string[]` -default: `["img"]` +default: `["image", "photo", "picture"]` -JSX element types to validate (component names) where the rule applies. -For example, `["img", "Image"]`. +Words considered redundant in alt text that should trigger a warning. ## How to use -To **enable** this rule in the CLI or using the config file, you can use: +To **enable** this rule using the config file or in the CLI, you can use: ::: code-group -```bash [CLI] -oxlint --deny jsx-a11y/img-redundant-alt --jsx-a11y-plugin -``` - ```json [Config (.oxlintrc.json)] { "plugins": ["jsx-a11y"], @@ -80,6 +76,10 @@ oxlint --deny jsx-a11y/img-redundant-alt --jsx-a11y-plugin } ``` +```bash [CLI] +oxlint --deny jsx-a11y/img-redundant-alt --jsx-a11y-plugin +``` + ::: ## References diff --git a/src/docs/guide/usage/linter/rules/react/jsx-fragments.md b/src/docs/guide/usage/linter/rules/react/jsx-fragments.md index 4eb34e0af3..34b3f9b650 100644 --- a/src/docs/guide/usage/linter/rules/react/jsx-fragments.md +++ b/src/docs/guide/usage/linter/rules/react/jsx-fragments.md @@ -23,15 +23,9 @@ Makes code using fragments more consistent one way or the other. ## Configuration -This rule accepts a configuration object with the following properties: +This rule accepts one of the following string values: -### mode - -type: `"syntax" | "element"` - -default: `"syntax"` - -`syntax` mode: +### `"syntax"` This is the default mode. It will enforce the shorthand syntax for React fragments, with one exception. Keys or attributes are not supported by the shorthand syntax, so the rule will not warn on standard-form fragments that use those. @@ -58,7 +52,8 @@ Examples of **correct** code for this rule: ; ``` -`element` mode: +### `"element"` + This mode enforces the standard form for React fragments. Examples of **incorrect** code for this rule: diff --git a/src/docs/guide/usage/linter/rules/typescript/ban-ts-comment.md b/src/docs/guide/usage/linter/rules/typescript/ban-ts-comment.md index 68351c8be0..25c9dd8768 100644 --- a/src/docs/guide/usage/linter/rules/typescript/ban-ts-comment.md +++ b/src/docs/guide/usage/linter/rules/typescript/ban-ts-comment.md @@ -35,6 +35,28 @@ if (false) { ## Configuration +This rule allows you to specify how different TypeScript directive comments +should be handled. + +For each directive (`@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`), you can choose one of the following options: + +- `true`: Disallow the directive entirely, preventing its use in the entire codebase. +- `false`: Allow the directive without any restrictions. +- `"allow-with-description"`: Allow the directive only if it is followed by a description explaining its use. The description must meet the minimum length specified by `minimumDescriptionLength`. +- `{ "descriptionFormat": "" }`: Allow the directive only if the description matches the specified regex pattern. + +For example: + +```json +{ + "ts-expect-error": "allow-with-description", + "ts-ignore": true, + "ts-nocheck": { "descriptionFormat": "^: TS\\d+ because .+$" }, + "ts-check": false, + "minimumDescriptionLength": 3 +} +``` + This rule accepts a configuration object with the following properties: ### minimumDescriptionLength diff --git a/src/docs/guide/usage/linter/rules/unicorn/filename-case.md b/src/docs/guide/usage/linter/rules/unicorn/filename-case.md index 4ca1c7961a..071dd064b3 100644 --- a/src/docs/guide/usage/linter/rules/unicorn/filename-case.md +++ b/src/docs/guide/usage/linter/rules/unicorn/filename-case.md @@ -15,6 +15,9 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin Enforces a consistent case style for filenames to improve project organization and maintainability. By default, `kebab-case` is enforced, but other styles can be configured. +Files named `index.js`, `index.ts`, etc. are exempt from this rule as they cannot reliably be +renamed to other casings (mainly just a problem with PascalCase). + ### Why is this bad? Inconsistent file naming conventions make it harder to locate files, navigate projects, and enforce @@ -49,74 +52,115 @@ Examples of **correct** filenames for each case: - `SomeFileName.Test.js` - `SomeFileName.TestUtils.js` -### Options +## Configuration + +This rule accepts a configuration object with the following properties: + +### case -#### case +type: `"kebabCase" | "camelCase" | "snakeCase" | "pascalCase"` -`{ type: 'kebabCase' | 'camelCase' | 'snakeCase' | 'pascalCase' }` +default: `"kebabCase"` + +The case style to enforce for filenames. You can set the `case` option like this: ```json "unicorn/filename-case": [ - "error", - { - "case": "kebabCase" - } +"error", +{ +"case": "kebabCase" +} ] ``` -#### cases +### cases + +type: `object` + +default: `{"kebabCase":true, "camelCase":false, "snakeCase":false, "pascalCase":false}` -`{ type: { [key in 'kebabCase' | 'camelCase' | 'snakeCase' | 'pascalCase']?: boolean } }` +The case style(s) to allow/enforce for filenames. `true` means the case style is allowed, `false` means it is banned. You can set the `cases` option like this: ```json "unicorn/filename-case": [ - "error", - { - "cases": { - "camelCase": true, - "pascalCase": true - } - } +"error", +{ +"cases": { +"camelCase": true, +"pascalCase": true +} +} ] ``` -#### ignore +#### cases.camelCase + +type: `boolean` + +default: `false` + +Whether camel case is allowed, e.g. `someFileName.js`. + +#### cases.kebabCase + +type: `boolean` + +default: `true` + +Whether kebab case is allowed, e.g. `some-file-name.js`. + +#### cases.pascalCase -`{ type: string }` +type: `boolean` -Specifies a regular expression pattern for filenames that should be ignored by this rule. +default: `false` + +Whether pascal case is allowed, e.g. `SomeFileName.js`. + +#### cases.snakeCase + +type: `boolean` + +default: `false` + +Whether snake case is allowed, e.g. `some_file_name.js`. + +### ignore + +type: `string | null` + +A regular expression pattern for filenames to ignore. You can set the `ignore` option like this: ```json "unicorn/filename-case": [ - "error", - { - "ignore": "^foo.*$" - } +"error", +{ +"ignore": "^foo.*$" +} ] ``` -#### multipleFileExtensions +### multipleFileExtensions + +type: `boolean` -`{ type: boolean, default: true }` +default: `true` -Whether to treat additional, `.`-separated parts of a filename as parts of the extension rather than parts of the filename. +Whether to treat additional, `.`-separated parts of a filename as +parts of the extension rather than parts of the filename. ## How to use -To **enable** this rule in the CLI or using the config file, you can use: +To **enable** this rule using the config file or in the CLI, you can use: ::: code-group -```bash [CLI] -oxlint --deny unicorn/filename-case -``` - ```json [Config (.oxlintrc.json)] { "rules": { @@ -125,6 +169,10 @@ oxlint --deny unicorn/filename-case } ``` +```bash [CLI] +oxlint --deny unicorn/filename-case +``` + ::: ## References diff --git a/src/docs/guide/usage/linter/rules/version.data.js b/src/docs/guide/usage/linter/rules/version.data.js index 776ccaf815..804c9348c0 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 "75ac90cf3fa19ecf4248bebca5016ab610aaa079"; + return "267fadc5b19537fa7c66412e0000337a4d2d1835"; }, }; From 474872e18ce88b0b02b008d4cd4957bd1734f397 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Mon, 8 Dec 2025 12:30:26 +0000 Subject: [PATCH 2/2] fmt --- .../guide/usage/formatter/generated-cli.md | 45 ++++++------- .../guide/usage/formatter/generated-config.md | 67 +------------------ 2 files changed, 20 insertions(+), 92 deletions(-) diff --git a/src/docs/guide/usage/formatter/generated-cli.md b/src/docs/guide/usage/formatter/generated-cli.md index b5c2fa75f6..511d2f6cf2 100644 --- a/src/docs/guide/usage/formatter/generated-cli.md +++ b/src/docs/guide/usage/formatter/generated-cli.md @@ -2,53 +2,46 @@ search: false --- - ## Usage - **`oxfmt`** \[**`-c`**=_`PATH`_\] \[_`PATH`_\]... + +**`oxfmt`** \[**`-c`**=_`PATH`_\] \[_`PATH`_\]... ## Output Options -- **` --check`** — + +- **`--check`** — Check mode - check if files are formatted, also show statistics -- **` --list-different`** — +- **`--list-different`** — List mode - list files that would be changed - - ## Basic Options -- **`-c`**, **`--config`**=_`PATH`_ — - Path to the configuration file - +- **`-c`**, **`--config`**=_`PATH`_ — + Path to the configuration file ## Ignore Options -- **` --ignore-path`**=_`PATH`_ — + +- **`--ignore-path`**=_`PATH`_ — Path to ignore file(s). Can be specified multiple times. If not specified, .gitignore and .prettierignore in the current directory are used. -- **` --with-node-modules`** — +- **`--with-node-modules`** — Format code in node_modules directory (skipped by default) - - ## Misc Options -- **` --lsp`** — + +- **`--lsp`** — Start language server protocol (LSP) server -- **` --no-error-on-unmatched-pattern`** — +- **`--no-error-on-unmatched-pattern`** — Do not exit with error when pattern is unmatched -- **` --threads`**=_`INT`_ — +- **`--threads`**=_`INT`_ — Number of threads to use. Set to 1 for using only 1 CPU core. - - ## Available positional items: -- _`PATH`_ — - Single file, single path or list of paths. If not provided, current working directory is used. Glob is supported only for exclude patterns like `'!**/fixtures/*.js'`. - +- _`PATH`_ — + Single file, single path or list of paths. If not provided, current working directory is used. Glob is supported only for exclude patterns like `'!**/fixtures/*.js'`. ## Available options: -- **`-h`**, **`--help`** — + +- **`-h`**, **`--help`** — Prints help information -- **`-V`**, **`--version`** — +- **`-V`**, **`--version`** — Prints version information - - - diff --git a/src/docs/guide/usage/formatter/generated-config.md b/src/docs/guide/usage/formatter/generated-config.md index 6a8c29e456..093b1cdf5e 100644 --- a/src/docs/guide/usage/formatter/generated-config.md +++ b/src/docs/guide/usage/formatter/generated-config.md @@ -3,224 +3,159 @@ search: false --- # Configuration options for the formatter. + Most options are the same as Prettier's options. See also - ## arrowParens type: `string | null` - Include parentheses around a sole arrow function parameter. (Default: "always") - ## bracketSameLine type: `boolean | null` - Put the > of a multi-line JSX element at the end of the last line instead of being alone on the next line. (Default: false) - ## bracketSpacing type: `boolean | null` - Print spaces between brackets in object literals. (Default: true) - ## embeddedLanguageFormatting type: `string | null` - Control whether formats quoted code embedded in the file. (Default: "auto") - ## endOfLine type: `string | null` - Which end of line characters to apply. (Default: "lf") - ## experimentalSortImports type: `object | null` - Experimental: Sort import statements. Disabled by default. - ### experimentalSortImports.groups type: `array | null` - Custom groups configuration for organizing imports. Each array element represents a group, and multiple group names in the same array are treated as one. Accepts both `string` and `string[]` as group elements. - #### experimentalSortImports.groups[n] type: `string[]` - - - - ### experimentalSortImports.ignoreCase type: `boolean` default: `true` - - - ### experimentalSortImports.internalPattern type: `string[]` - - - - ### experimentalSortImports.newlinesBetween type: `boolean` default: `true` - - - ### experimentalSortImports.order type: `string | null` - - - - ### experimentalSortImports.partitionByComment type: `boolean` default: `false` - - - ### experimentalSortImports.partitionByNewline type: `boolean` default: `false` - - - ### experimentalSortImports.sortSideEffects type: `boolean` default: `false` - - - ## ignorePatterns type: `string[]` - Ignore files matching these glob patterns. Current working directory is used as the root. - ## jsxSingleQuote type: `boolean | null` - Use single quotes instead of double quotes in JSX. (Default: false) - ## objectWrap type: `string | null` - How to wrap object literals when they could fit on one line or span multiple lines. (Default: "preserve") NOTE: In addition to Prettier's "preserve" and "collapse", we also support "always". - ## printWidth type: `integer | null` - The line length that the printer will wrap on. (Default: 100) - ## quoteProps type: `string | null` - Change when properties in objects are quoted. (Default: "as-needed") - ## semi type: `boolean | null` - Print semicolons at the ends of statements. (Default: true) - ## singleAttributePerLine type: `boolean | null` - Put each attribute on a new line in JSX. (Default: false) - ## singleQuote type: `boolean | null` - Use single quotes instead of double quotes. (Default: false) - ## tabWidth type: `integer | null` - Number of spaces per indentation level. (Default: 2) - ## trailingComma type: `string | null` - Print trailing commas wherever possible. (Default: "all") - ## useTabs type: `boolean | null` - Use tabs for indentation or spaces. (Default: false) - - -