Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions src/docs/guide/usage/linter/generated-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down Expand Up @@ -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.

Expand All @@ -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 | | ⚠️🛠️️ |
Expand Down Expand Up @@ -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 | | |
Expand Down
8 changes: 4 additions & 4 deletions src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🚧</span> An auto-fix is planned for this rule, but not implemented at this time.
<span class="emoji">🛠️</span> An auto-fix is available for this rule.
</Alert>
</div>

Expand All @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function foo() {

This rule accepts a configuration object with the following properties:

### iifes
### IIFEs

type: `boolean`

Expand Down
89 changes: 89 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/no-useless-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!-- This file is auto-generated by tasks/website_linter/src/rules/doc_page.rs. Do not edit it manually. -->

<script setup>
import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/eslint/no_useless_return.rs`;
</script>

# eslint/no-useless-return <Badge type="info" text="Pedantic" />

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🚧</span> An auto-fix is planned for this rule, but not implemented at this time.
</Alert>
</div>

### 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

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
23 changes: 9 additions & 14 deletions src/docs/guide/usage/linter/rules/jest/expect-expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -52,32 +52,23 @@ default: `[]`

An array of function names that should also be treated as test blocks.

### assertFunctionNamesJest
### assertFunctionNames

type: `string[]`

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"],
Expand All @@ -87,6 +78,10 @@ oxlint --deny jest/expect-expect --jest-plugin
}
```

```bash [CLI]
oxlint --deny jest/expect-expect --jest-plugin
```

:::

## References
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/jest/no-alias-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/jest/no-focused-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/jest/no-test-prefixes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/jest/valid-expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
24 changes: 12 additions & 12 deletions src/docs/guide/usage/linter/rules/jsx_a11y/img-redundant-alt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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
Expand Down
13 changes: 4 additions & 9 deletions src/docs/guide/usage/linter/rules/react/jsx-fragments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -58,7 +52,8 @@ Examples of **correct** code for this rule:
</React.Fragment>;
```

`element` mode:
### `"element"`

This mode enforces the standard form for React fragments.

Examples of **incorrect** code for this rule:
Expand Down
Loading