Skip to content

Release 0.9.0 #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2024
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: 1 addition & 1 deletion oxc
Submodule oxc updated from aa7718 to 8109ed
4 changes: 0 additions & 4 deletions src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<!-- textlint-disable -->

## Usage

**`oxlint`** \[**`-c`**=_`<./oxlintrc.json>`_\] \[_`PATH`_\]...
Expand Down Expand Up @@ -123,5 +121,3 @@ Arguments:
Prints help information
- **`-V`**, **`--version`** &mdash;
Prints version information

<!-- textlint-enable -->
36 changes: 17 additions & 19 deletions src/docs/guide/usage/linter/generated-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

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

- Total number of rules: 411
- Rules turned on by default: 92
- Total number of rules: 413
- Rules turned on by default: 93

<!-- textlint-disable terminology -->

## Correctness (164):
## Correctness (165):

Code that is outright wrong or useless.
| Rule name | Source | Default | Fixable? |
Expand Down Expand Up @@ -50,6 +48,7 @@ Code that is outright wrong or useless.
| [no-unsafe-negation](/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.html) | eslint | ✅ | 🛠️ |
| [no-unused-labels](/docs/guide/usage/linter/rules/eslint/no-unused-labels.html) | eslint | ✅ | 🛠️ |
| [no-unused-private-class-members](/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.html) | eslint | ✅ | |
| [no-unused-vars](/docs/guide/usage/linter/rules/eslint/no-unused-vars.html) | eslint | ✅ | ⚠️💡 |
| [no-useless-catch](/docs/guide/usage/linter/rules/eslint/no-useless-catch.html) | eslint | ✅ | |
| [no-useless-escape](/docs/guide/usage/linter/rules/eslint/no-useless-escape.html) | eslint | ✅ | 🛠️ |
| [no-useless-rename](/docs/guide/usage/linter/rules/eslint/no-useless-rename.html) | eslint | ✅ | |
Expand Down Expand Up @@ -99,7 +98,7 @@ Code that is outright wrong or useless.
| [no-aria-hidden-on-focusable](/docs/guide/usage/linter/rules/jsx_a11y/no-aria-hidden-on-focusable.html) | jsx_a11y | | 🛠️ |
| [no-autofocus](/docs/guide/usage/linter/rules/jsx_a11y/no-autofocus.html) | jsx_a11y | | 🛠️ |
| [no-distracting-elements](/docs/guide/usage/linter/rules/jsx_a11y/no-distracting-elements.html) | jsx_a11y | | |
| [no-redundant-roles](/docs/guide/usage/linter/rules/jsx_a11y/no-redundant-roles.html) | jsx_a11y | | 🚧 |
| [no-redundant-roles](/docs/guide/usage/linter/rules/jsx_a11y/no-redundant-roles.html) | jsx_a11y | | 🛠️ |
| [prefer-tag-over-role](/docs/guide/usage/linter/rules/jsx_a11y/prefer-tag-over-role.html) | jsx_a11y | | |
| [role-has-required-aria-props](/docs/guide/usage/linter/rules/jsx_a11y/role-has-required-aria-props.html) | jsx_a11y | | |
| [role-supports-aria-props](/docs/guide/usage/linter/rules/jsx_a11y/role-supports-aria-props.html) | jsx_a11y | | |
Expand Down Expand Up @@ -144,7 +143,7 @@ Code that is outright wrong or useless.
| [jsx-no-duplicate-props](/docs/guide/usage/linter/rules/react/jsx-no-duplicate-props.html) | react | ✅ | |
| [jsx-no-target-blank](/docs/guide/usage/linter/rules/react/jsx-no-target-blank.html) | react | ✅ | |
| [jsx-no-undef](/docs/guide/usage/linter/rules/react/jsx-no-undef.html) | react | ✅ | |
| [jsx-props-no-spread-multi](/docs/guide/usage/linter/rules/react/jsx-props-no-spread-multi.html) | react | ✅ | 🚧 |
| [jsx-props-no-spread-multi](/docs/guide/usage/linter/rules/react/jsx-props-no-spread-multi.html) | react | ✅ | 🛠️ |
| [no-children-prop](/docs/guide/usage/linter/rules/react/no-children-prop.html) | react | ✅ | |
| [no-direct-mutation-state](/docs/guide/usage/linter/rules/react/no-direct-mutation-state.html) | react | ✅ | |
| [no-find-dom-node](/docs/guide/usage/linter/rules/react/no-find-dom-node.html) | react | ✅ | |
Expand Down Expand Up @@ -172,7 +171,7 @@ Code that is outright wrong or useless.
| [no-useless-fallback-in-spread](/docs/guide/usage/linter/rules/unicorn/no-useless-fallback-in-spread.html) | unicorn | ✅ | 🛠️ |
| [no-useless-length-check](/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.html) | unicorn | ✅ | |
| [no-useless-spread](/docs/guide/usage/linter/rules/unicorn/no-useless-spread.html) | unicorn | ✅ | 🛠️ |
| [prefer-set-size](/docs/guide/usage/linter/rules/unicorn/prefer-set-size.html) | unicorn | ✅ | 🚧 |
| [prefer-set-size](/docs/guide/usage/linter/rules/unicorn/prefer-set-size.html) | unicorn | ✅ | 🛠️ |
| [prefer-string-starts-ends-with](/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.html) | unicorn | ✅ | 🛠️ |
| [no-conditional-tests](/docs/guide/usage/linter/rules/vitest/no-conditional-tests.html) | vitest | | |
| [require-local-test-context-for-concurrent-snapshots](/docs/guide/usage/linter/rules/vitest/require-local-test-context-for-concurrent-snapshots.html) | vitest | | |
Expand Down Expand Up @@ -326,8 +325,8 @@ Lints which are rather strict or have occasional false positives.
| [no-useless-promise-resolve-reject](/docs/guide/usage/linter/rules/unicorn/no-useless-promise-resolve-reject.html) | unicorn | | 🛠️ |
| [no-useless-switch-case](/docs/guide/usage/linter/rules/unicorn/no-useless-switch-case.html) | unicorn | | |
| [no-useless-undefined](/docs/guide/usage/linter/rules/unicorn/no-useless-undefined.html) | unicorn | | 🛠️ |
| [prefer-array-flat](/docs/guide/usage/linter/rules/unicorn/prefer-array-flat.html) | unicorn | | 🚧 |
| [prefer-array-some](/docs/guide/usage/linter/rules/unicorn/prefer-array-some.html) | unicorn | | 🚧 |
| [prefer-array-flat](/docs/guide/usage/linter/rules/unicorn/prefer-array-flat.html) | unicorn | | 🛠️ |
| [prefer-array-some](/docs/guide/usage/linter/rules/unicorn/prefer-array-some.html) | unicorn | | 🛠️ |
| [prefer-blob-reading-methods](/docs/guide/usage/linter/rules/unicorn/prefer-blob-reading-methods.html) | unicorn | | |
| [prefer-code-point](/docs/guide/usage/linter/rules/unicorn/prefer-code-point.html) | unicorn | | 🛠️ |
| [prefer-date-now](/docs/guide/usage/linter/rules/unicorn/prefer-date-now.html) | unicorn | | 🚧 |
Expand All @@ -339,13 +338,13 @@ Lints which are rather strict or have occasional false positives.
| [prefer-native-coercion-functions](/docs/guide/usage/linter/rules/unicorn/prefer-native-coercion-functions.html) | unicorn | | 🚧 |
| [prefer-prototype-methods](/docs/guide/usage/linter/rules/unicorn/prefer-prototype-methods.html) | unicorn | | 🛠️ |
| [prefer-query-selector](/docs/guide/usage/linter/rules/unicorn/prefer-query-selector.html) | unicorn | | 🛠️ |
| [prefer-regexp-test](/docs/guide/usage/linter/rules/unicorn/prefer-regexp-test.html) | unicorn | | 🚧 |
| [prefer-regexp-test](/docs/guide/usage/linter/rules/unicorn/prefer-regexp-test.html) | unicorn | | 🛠️ |
| [prefer-string-replace-all](/docs/guide/usage/linter/rules/unicorn/prefer-string-replace-all.html) | unicorn | | 🛠️ |
| [prefer-string-slice](/docs/guide/usage/linter/rules/unicorn/prefer-string-slice.html) | unicorn | | 🚧 |
| [prefer-string-slice](/docs/guide/usage/linter/rules/unicorn/prefer-string-slice.html) | unicorn | | 🛠️ |
| [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 (92):
## Style (94):

Code that should be written in a more idiomatic way.
| Rule name | Source | Default | Fixable? |
Expand Down Expand Up @@ -435,15 +434,17 @@ Code that should be written in a more idiomatic way.
| [prefer-reflect-apply](/docs/guide/usage/linter/rules/unicorn/prefer-reflect-apply.html) | unicorn | | |
| [prefer-spread](/docs/guide/usage/linter/rules/unicorn/prefer-spread.html) | unicorn | | 🛠️ |
| [prefer-string-trim-start-end](/docs/guide/usage/linter/rules/unicorn/prefer-string-trim-start-end.html) | unicorn | | 🛠️ |
| [require-array-join-separator](/docs/guide/usage/linter/rules/unicorn/require-array-join-separator.html) | unicorn | | 🚧 |
| [prefer-structured-clone](/docs/guide/usage/linter/rules/unicorn/prefer-structured-clone.html) | unicorn | | 🚧 |
| [require-array-join-separator](/docs/guide/usage/linter/rules/unicorn/require-array-join-separator.html) | unicorn | | 🛠️ |
| [switch-case-braces](/docs/guide/usage/linter/rules/unicorn/switch-case-braces.html) | unicorn | | 🛠️ |
| [text-encoding-identifier-case](/docs/guide/usage/linter/rules/unicorn/text-encoding-identifier-case.html) | unicorn | | 🚧 |
| [text-encoding-identifier-case](/docs/guide/usage/linter/rules/unicorn/text-encoding-identifier-case.html) | unicorn | | 🛠️ |
| [throw-new-error](/docs/guide/usage/linter/rules/unicorn/throw-new-error.html) | unicorn | | 🚧 |
| [no-import-node-test](/docs/guide/usage/linter/rules/vitest/no-import-node-test.html) | vitest | | 🛠️ |
| [prefer-each](/docs/guide/usage/linter/rules/vitest/prefer-each.html) | vitest | | |
| [prefer-to-be-falsy](/docs/guide/usage/linter/rules/vitest/prefer-to-be-falsy.html) | vitest | | 🛠️ |
| [prefer-to-be-truthy](/docs/guide/usage/linter/rules/vitest/prefer-to-be-truthy.html) | vitest | | 🛠️ |

## Nursery (11):
## Nursery (10):

New lints that are still under development.
| Rule name | Source | Default | Fixable? |
Expand All @@ -452,12 +453,9 @@ New lints that are still under development.
| [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 | | |
| [no-unused-vars](/docs/guide/usage/linter/rules/eslint/no-unused-vars.html) | eslint | | ⚠️💡 |
| [export](/docs/guide/usage/linter/rules/import/export.html) | import | | |
| [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 | | |
| [rules-of-hooks](/docs/guide/usage/linter/rules/react/rules-of-hooks.html) | react | | |
| [no-side-effects-in-initialization](/docs/guide/usage/linter/rules/tree_shaking/no-side-effects-in-initialization.html) | tree_shaking | | |
| [consistent-type-imports](/docs/guide/usage/linter/rules/typescript/consistent-type-imports.html) | typescript | | 🛠️ |

<!-- textlint-enable -->
9 changes: 6 additions & 3 deletions src/docs/guide/usage/linter/rules/eslint/func-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ the name of the function expression in the stack trace.

This rule has a string option:

- `"always"` requires a function expression to have a name under all circumstances.
- `"as-needed"` requires a function expression to have a name only when one will not be automatically inferred by the runtime.
- `"never"` requires a function expression to not have a name under any circumstances.
- `"always"` requires a function expression to have a name under all
circumstances.
- `"as-needed"` requires a function expression to have a name only when
one will not be automatically inferred by the runtime.
- `"never"` requires a function expression to not have a name under any
circumstances.

### Example

Expand Down
8 changes: 6 additions & 2 deletions src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# eslint/no-unused-vars <Badge type="info" text="Nursery" />
# eslint/no-unused-vars <Badge type="info" text="Correctness" />

<div class="rule-meta">
<Alert class="default-on" type="success">
<span class="emoji">✅</span> This rule is turned on by default.
</Alert>
<Alert class="fix" type="info">
<span class="emoji">⚠️💡</span> A dangerous suggestion is available for this rule.
</Alert>
Expand Down Expand Up @@ -33,7 +36,8 @@ true:
- It is called (`foo()`) or constructed (`new foo()`)
- It is read (`var bar = foo`)
- It is passed into a function or constructor as an argument (`doSomething(foo)`)
- It is read inside of a function that is passed to another function (`doSomething(function() { foo(); })`)
- It is read inside of a function that is passed to another function
(`doSomething(function() { foo(); })`)
- It is exported (`export const foo = 42`)
- It is used as an operand to TypeScript's `typeof` operator (`const bar:
typeof foo = 4`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
When working with promises, there are two primary ways you can test the resolved
value:

1. use the `resolve` modifier on `expect` (`await expect(...).resolves.<matcher>` style)
2. `await` the promise and assert against its result (`expect(await ...).<matcher>` style)
1. use the `resolve` modifier on `expect`
(`await expect(...).resolves.<matcher>` style)
2. `await` the promise and assert against its result
(`expect(await ...).<matcher>` style)

While the second style is arguably less dependent on `jest`, if the promise
rejects it will be treated as a general error, resulting in less predictable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ All these anchor implementations indicate that the element is only used to execu

There are **many reasons** why an anchor should not have a logic and have a correct `href` attribute:

- it can disrupt the correct flow of the user navigation e.g. a user that wants to open the link in another tab, but the default "click" behaviour is prevented
- it can disrupt the correct flow of the user navigation e.g. a user that wants to open the link
in another tab, but the default "click" behaviour is prevented
- it can source of invalid links, and crawlers can't navigate the website, risking to penalise SEO ranking

### Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ that option for checking on both JSX props and children.
The fix also deals with template literals, strings with quotes, and
strings with escapes characters.

- If the rule is set to get rid of unnecessary curly braces and the template literal inside a JSX expression has no expression, it will throw a warning and be fixed with double quotes. For example:
- If the rule is set to get rid of unnecessary curly braces and the
template literal inside a JSX expression has no expression, it will
throw a warning and be fixed with double quotes. For example:

```jsx
<App prop={`Hello world`}>{`Hello world`}</App>
Expand All @@ -175,7 +177,10 @@ strings with escapes characters.
<App prop="Hello world">Hello world</App>
```

- If the rule is set to enforce curly braces and the strings have quotes, it will be fixed with double quotes for JSX children and the normal way for JSX attributes. Also, double quotes will be escaped in the fix.
- If the rule is set to enforce curly braces and the strings have
quotes, it will be fixed with double quotes for JSX children and the
normal way for JSX attributes. Also, double quotes will be escaped in
the fix.

For example:

Expand All @@ -189,7 +194,12 @@ strings with escapes characters.
<App prop={'Hello "foo" world'}>{"Hello 'foo' \"bar\" world"}</App>
```

- If the rule is set to get rid of unnecessary curly braces(JSX expression) and there are characters that need to be escaped in its JSX form, such as quote characters, [forbidden JSX text characters](https://facebook.github.io/jsx/), escaped characters and anything that looks like HTML entity names, the code will not be warned because the fix may make the code less readable.
- If the rule is set to get rid of unnecessary curly braces(JSX
expression) and there are characters that need to be escaped in its JSX
form, such as quote characters, [forbidden JSX text
characters](https://facebook.github.io/jsx/), escaped characters and
anything that looks like HTML entity names, the code will not be warned
because the fix may make the code less readable.

Examples of **correct** code for this rule, even when configured with `"never"`:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="emoji">✅</span> This rule is turned on by default.
</Alert>
<Alert class="fix" type="info">
<span class="emoji">🚧</span> An auto-fix is still under development.
<span class="emoji">🛠️</span> An auto-fix is available for this rule.
</Alert>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/unicorn/no-null.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🛠️</span> An auto-fix is available for this rule.
<span class="emoji">🛠️</span> An auto-fix is available for this rule for some violations.
</Alert>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🚧</span> An auto-fix is still under development.
<span class="emoji">🛠️</span> An auto-fix is available for this rule for some violations.
</Alert>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="emoji">✅</span> This rule is turned on by default.
</Alert>
<Alert class="fix" type="info">
<span class="emoji">🚧</span> An auto-fix is still under development.
<span class="emoji">🛠️</span> An auto-fix is available for this rule.
</Alert>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# unicorn/prefer-structured-clone <Badge type="info" text="Style" />

<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

Prefer using structuredClone to create a deep clone.

### Why is this bad?

structuredClone is the modern way to create a deep clone of a value.

### Examples

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

```js
const clone = JSON.parse(JSON.stringify(foo));

const clone = _.cloneDeep(foo);
```

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

```js
const clone = structuredClone(foo);
```

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/unicorn/prefer_structured_clone.rs)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🚧</span> An auto-fix is still under development.
<span class="emoji">🛠️</span> An auto-fix is available for this rule for some violations.
</Alert>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

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

# vitest/prefer-each <Badge type="info" text="Style" />

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

### What it does

This rule enforces using `each` rather than manual loops.

### Examples

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

```js
for (const item of items) {
describe(item, () => {
expect(item).toBe("foo");
});
}
```

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

```js
describe.each(items)("item", (item) => {
expect(item).toBe("foo");
});
```

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/vitest/prefer_each.rs)