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
3 changes: 0 additions & 3 deletions src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ Arguments:
- **`--no-ignore`** —
Disables excluding of files from .eslintignore files, **`--ignore-path`** flags and **`--ignore-pattern`** flags

> [!NOTE]
> `.gitignore` is only respected inside a Git repository.

## Handle Warnings

- **`--quiet`** —
Expand Down
31 changes: 17 additions & 14 deletions src/docs/guide/usage/linter/generated-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The progress of all rule implementations is tracked [here](https://github.com/oxc-project/oxc/issues/481).

- Total number of rules: 582
- Total number of rules: 585
- Rules turned on by default: 102

**Legend for 'Fixable?' column:**
Expand Down Expand Up @@ -311,7 +311,7 @@ Lints which prevent the use of language and library features. Must not be enable
| [prefer-number-properties](/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.html) | unicorn | | ⚠️🛠️️ |
| [no-multiple-slot-args](/docs/guide/usage/linter/rules/vue/no-multiple-slot-args.html) | vue | | 🚧 |

## Suspicious (42):
## Suspicious (43):

code that is most likely wrong or useless.

Expand Down Expand Up @@ -359,6 +359,7 @@ code that is most likely wrong or useless.
| [no-instanceof-builtins](/docs/guide/usage/linter/rules/unicorn/no-instanceof-builtins.html) | unicorn | | 🚧 |
| [prefer-add-event-listener](/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.html) | unicorn | | 🚧 |
| [require-post-message-target-origin](/docs/guide/usage/linter/rules/unicorn/require-post-message-target-origin.html) | unicorn | | 💡 |
| [no-required-prop-with-default](/docs/guide/usage/linter/rules/vue/no-required-prop-with-default.html) | vue | | 🚧 |

## Pedantic (97):

Expand Down Expand Up @@ -464,7 +465,7 @@ Lints which are rather strict or have occasional false positives.
| [prefer-type-error](/docs/guide/usage/linter/rules/unicorn/prefer-type-error.html) | unicorn | | 🛠️ |
| [require-number-to-fixed-digits-argument](/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.html) | unicorn | | 🛠️ |

## Style (158):
## Style (159):

Code that should be written in a more idiomatic way.

Expand Down Expand Up @@ -628,18 +629,20 @@ Code that should be written in a more idiomatic way.
| [prefer-to-be-truthy](/docs/guide/usage/linter/rules/vitest/prefer-to-be-truthy.html) | vitest | | 🛠️ |
| [define-emits-declaration](/docs/guide/usage/linter/rules/vue/define-emits-declaration.html) | vue | | 🚧 |
| [define-props-declaration](/docs/guide/usage/linter/rules/vue/define-props-declaration.html) | vue | | |
| [require-typed-ref](/docs/guide/usage/linter/rules/vue/require-typed-ref.html) | vue | | |

## Nursery (8):
## Nursery (9):

New lints that are still under development.

| Rule name | Source | Default | Fixable? |
| ---------------------------------------------------------------------------------------- | ------- | ------- | -------- |
| [getter-return](/docs/guide/usage/linter/rules/eslint/getter-return.html) | eslint | | |
| [no-undef](/docs/guide/usage/linter/rules/eslint/no-undef.html) | eslint | | |
| [no-unreachable](/docs/guide/usage/linter/rules/eslint/no-unreachable.html) | eslint | | |
| [export](/docs/guide/usage/linter/rules/import/export.html) | import | | |
| [named](/docs/guide/usage/linter/rules/import/named.html) | import | | |
| [no-map-spread](/docs/guide/usage/linter/rules/oxc/no-map-spread.html) | oxc | | 🛠️💡 |
| [no-return-in-finally](/docs/guide/usage/linter/rules/promise/no-return-in-finally.html) | promise | | |
| [require-render-return](/docs/guide/usage/linter/rules/react/require-render-return.html) | react | | |
| Rule name | Source | Default | Fixable? |
| --------------------------------------------------------------------------------------------------------- | ------- | ------- | -------- |
| [getter-return](/docs/guide/usage/linter/rules/eslint/getter-return.html) | eslint | | |
| [no-misleading-character-class](/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.html) | eslint | | |
| [no-undef](/docs/guide/usage/linter/rules/eslint/no-undef.html) | eslint | | |
| [no-unreachable](/docs/guide/usage/linter/rules/eslint/no-unreachable.html) | eslint | | |
| [export](/docs/guide/usage/linter/rules/import/export.html) | import | | |
| [named](/docs/guide/usage/linter/rules/import/named.html) | import | | |
| [no-map-spread](/docs/guide/usage/linter/rules/oxc/no-map-spread.html) | oxc | | 🛠️💡 |
| [no-return-in-finally](/docs/guide/usage/linter/rules/promise/no-return-in-finally.html) | promise | | |
| [require-render-return](/docs/guide/usage/linter/rules/react/require-render-return.html) | react | | |
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!-- This file is auto-generated by tasks/website/src/linter/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_misleading_character_class.rs`;
</script>

# eslint/no-misleading-character-class <Badge type="info" text="Nursery" />

<div class="rule-meta">
</div>

### What it does

This rule reports regular expressions which include multiple code point characters in character class syntax. This includes:

- Characters with combining marks (e.g., `Á` where `A` is followed by a combining acute accent)
- Characters with emoji modifiers (e.g., `👶🏻`)
- Pairs of regional indicator symbols (e.g., `🇯🇵`)
- Characters joined by zero-width joiner (ZWJ) (e.g., `👨‍👩‍👦`)
- Surrogate pairs without the Unicode flag (e.g., `/^[👍]$/`)

### Why is this bad?

Unicode includes characters which are made by multiple code points.
RegExp character class syntax (`/[abc]/`) cannot handle characters
which are made by multiple code points as a character;
those characters will be dissolved to each code point.
For example, `❇️` is made by `❇` (`U+2747`) and VARIATION SELECTOR-16 (`U+FE0F`).
If this character is in a RegExp character class,
it will match either `❇` (`U+2747`) or VARIATION SELECTOR-16 (`U+FE0F`) rather than `❇️`.

This can lead to regular expressions that do not match what the author intended,
especially for emoji, regional indicators, and characters with combining marks.

#### Examples

Examples of **incorrect** code for this rule:

```javascript
/^[Á]$/u;
/^[❇️]$/u;
/^[👶🏻]$/u;
/^[🇯🇵]$/u;
/^[👨‍👩‍👦]$/u;
/^[👍]$/;
new RegExp("[🎵]");
```

Examples of **correct** code for this rule:

```javascript
/^[abc]$/;
/^[👍]$/u;
/[\u00B7\u0300-\u036F]/u;
new RegExp("^[\u{1F1EF}\u{1F1F5}]", "u");
```

#### Options

This rule has an object option:

- `allowEscape`: When set to `true`, the rule allows any grouping of code points
inside a character class as long as they are written using escape sequences.

Examples of **incorrect** code for this rule with `{ "allowEscape": true }`:

```javascript
/[\uD83D]/; // backslash can be omitted
new RegExp("[\ud83d" + "\udc4d]");
```

Examples of **correct** code for this rule with `{ "allowEscape": true }`:

```javascript
/[\ud83d\udc4d]/;
/[\u00B7\u0300-\u036F]/u;
/[👨\u200d👩]/u;
new RegExp("[\x41\u0301]");
new RegExp(`[\u{1F1EF}\u{1F1F5}]`, "u");
new RegExp("[\\u{1F1EF}\\u{1F1F5}]", "u");
```

## How to use

To **enable** this rule in the CLI or using the config file, you can use:

::: code-group

```bash [CLI]
oxlint --deny no-misleading-character-class
```

```json [Config (.oxlintrc.json)]
{
"rules": {
"no-misleading-character-class": "error"
}
}
```

:::

## References

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/version.data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
load() {
return "a2c91cd5104af39a6b644e77879d3117c72b0ea6";
return "cc0019fb0af60ea2566e4aca87656d0a9f573c1c";
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!-- This file is auto-generated by tasks/website/src/linter/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/vue/no_required_prop_with_default.rs`;
</script>

# vue/no-required-prop-with-default <Badge type="info" text="Suspicious" />

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🚧</span> An auto-fix is still under development.
</Alert>
</div>

### What it does

Enforce props with default values to be optional.

### Why is this bad?

If a prop is declared with a default value, whether it is required or not,
we can always skip it in actual use. In that situation, the default value would be applied.
So, a required prop with a default value is essentially the same as an optional prop.

### Examples

Examples of **incorrect** code for this rule:

```vue
<script setup lang="ts">
const props = withDefaults(
defineProps<{
name: string | number;
age?: number;
}>(),
{
name: "Foo",
},
);
</script>
```

Examples of **correct** code for this rule:

```vue
<script setup lang="ts">
const props = withDefaults(
defineProps<{
name?: string | number;
age?: number;
}>(),
{
name: "Foo",
},
);
</script>
```

## How to use

To **enable** this rule in the CLI or using the config file, you can use:

::: code-group

```bash [CLI]
oxlint --deny vue/no-required-prop-with-default --vue-plugin
```

```json [Config (.oxlintrc.json)]
{
"plugins": ["vue"],
"rules": {
"vue/no-required-prop-with-default": "error"
}
}
```

:::

## References

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
62 changes: 62 additions & 0 deletions src/docs/guide/usage/linter/rules/vue/require-typed-ref.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!-- This file is auto-generated by tasks/website/src/linter/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/vue/require_typed_ref.rs`;
</script>

# vue/require-typed-ref <Badge type="info" text="Style" />

<div class="rule-meta">
</div>

### What it does

Require `ref` and `shallowRef` functions to be strongly typed.

### Why is this bad?

With TypeScript it is easy to prevent usage of `any` by using `noImplicitAny`.
Unfortunately this rule is easily bypassed with Vue `ref()` function.
Calling `ref()` function without a generic parameter or an initial value leads to ref having `Ref<any>` type.

### Examples

Examples of **incorrect** code for this rule:

```typescript
const count = ref();
const name = shallowRef();
```

Examples of **correct** code for this rule:

```typescript
const count = ref<number>();
const a = ref(0);
```

## How to use

To **enable** this rule in the CLI or using the config file, you can use:

::: code-group

```bash [CLI]
oxlint --deny vue/require-typed-ref --vue-plugin
```

```json [Config (.oxlintrc.json)]
{
"plugins": ["vue"],
"rules": {
"vue/require-typed-ref": "error"
}
}
```

:::

## References

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>