Skip to content

Commit

Permalink
Release 0.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
oxc-bot authored and github-actions[bot] committed Sep 12, 2024
1 parent a15d4a1 commit e0ced82
Show file tree
Hide file tree
Showing 164 changed files with 1,630 additions and 497 deletions.
2 changes: 2 additions & 0 deletions src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Arguments:
Enable the React performance plugin and detect rendering performance problems
- **` --promise-plugin`** —
Enable the promise plugin and detect promise usage problems
- **` --node-plugin`** —
Enable the node plugin and detect node usage problems

## Fix Problems

Expand Down
5 changes: 3 additions & 2 deletions src/docs/guide/usage/linter/generated-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).

Usage: `oxlint -c oxlintrc.json`
Usage: `oxlint -c oxlintrc.json --import-plugin`

::: danger NOTE

Expand All @@ -24,7 +24,8 @@ Example
},
"settings": {},
"rules": {
"eqeqeq": "warn"
"eqeqeq": "warn",
"import/no-cycle": "error"
}
}
```
Expand Down
74 changes: 41 additions & 33 deletions src/docs/guide/usage/linter/generated-rules.md

Large diffs are not rendered by default.

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

# eslint/no-alert <Badge type="info" text="Restriction" />

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

### What it does

Disallow the use of alert, confirm, and prompt

### Why is this bad?

JavaScript’s alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation.
Furthermore, alert is often used while debugging code, which should be removed before deployment to production.

### Examples

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

```js
alert("here!");

confirm("Are you sure?");

prompt("What's your name?", "John Doe");
```

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

```js
customAlert("Something happened!");

customConfirm("Are you sure?");

customPrompt("Who are you?");

function foo() {
var alert = myCustomLib.customAlert;
alert();
}
```

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_alert.rs)
4 changes: 2 additions & 2 deletions src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Instead, they are being run in series, which can lead to poorer performance.

### Example

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

```javascript
async function bad() {
Expand All @@ -26,7 +26,7 @@ async function bad() {
}
```

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

```javascript
async function good() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ Forbidding this pattern prevents mistakes resulting from unfamiliarity with the

### Example

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

```rust
class C {
constructor() { return 42; }
}
```

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

```rust
class C {
Expand Down
40 changes: 40 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# eslint/no-invalid-regexp <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>
</div>

### What it does

Disallow invalid regular expression strings in RegExp constructors.

### Why is this bad?

An invalid pattern in a regular expression literal is a SyntaxError when the code is parsed,
but an invalid string in RegExp constructors throws a SyntaxError only when the code is executed.

### Examples

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

```js
RegExp("[");
RegExp(".", "z");
new RegExp("\\");
```

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

```js
RegExp(".");
new RegExp();
this.RegExp("[");
```

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_invalid_regexp.rs)
137 changes: 137 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# eslint/no-magic-numbers <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

The no-magic-numbers rule aims to make code more readable and refactoring easier by ensuring that special numbers are declared as constants to make their meaning explicit.
The current implementation does not support BigInt numbers inside array indexes.

### Why is this bad?

‘Magic numbers’ are numbers that occur multiple times in code without an explicit meaning. They should preferably be replaced by named constants.

### Examples

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

```javascript
var dutyFreePrice = 100;
var finalPrice = dutyFreePrice + dutyFreePrice * 0.25;
```

Examples of **correct** code for this rule with option "ignore":

```javascript
/*typescript no-magic-numbers: ["error", { "ignore": [1] }]*/
var data = ["foo", "bar", "baz"];
var dataLast = data.length && data[data.length - 1];
```

Examples of **correct** code for this rule with option "ignoreArrayIndexes":

```javascript
/*typescript no-magic-numbers: ["error", { "ignoreArrayIndexes": true }]*/
var item = data[2];
data[100] = a;
f(data[0]);
a = data[-0]; // same as data[0], -0 will be coerced to "0"
a = data[0xab];
a = data[5.6e1];
a = data[4294967294]; // max array index
```

Examples of **correct** code for this rule with option "ignoreDefaultValues":

```javascript
/*typescript no-magic-numbers: ["error", { "ignoreDefaultValues": true }]*/
const { tax = 0.25 } = accountancy;
function mapParallel(concurrency = 3) {
/***/
}
```

Examples of **correct** code for this rule with option "ignoreClassFieldInitialValues":

```javascript
/*typescript no-magic-numbers: ["error", { "ignoreClassFieldInitialValues": true }]*/
class C {
foo = 2;
bar = -3;
#baz = 4;
static qux = 5;
}
```

Examples of **incorrect** code for this rule with option "enforceConst":

```javascript
/*typescript no-magic-numbers: ["error", { "enforceConst": true }]*/
var TAX = 0.25;
```

Examples of **incorrect** code for this rule with option "detectObjects":

```javascript
/*typescript no-magic-numbers: ["error", { "detectObjects": true }]*/
var magic = {
tax: 0.25,
};
```

Examples of **correct** code for this rule with option "detectObjects":

```javascript
/*typescript no-magic-numbers: ["error", { "detectObjects": true }]*/
var TAX = 0.25;

var magic = {
tax: TAX,
};
```

Examples of **correct** code for this rule with option "ignoreEnums":

```typescript
/*typescript no-magic-numbers: ["error", { "ignoreEnums": true }]*/
enum foo {
SECOND = 1000,
}
```

Examples of **correct** code for this rule with option "ignoreNumericLiteralTypes":

```typescript
/*typescript no-magic-numbers: ["error", { "ignoreNumericLiteralTypes": true }]*/
type SmallPrimes = 2 | 3 | 5 | 7 | 11;
```

Examples of **correct** code for this rule with option "ignoreReadonlyClassProperties":

```typescript
/*typescript no-magic-numbers: ["error", { "ignoreReadonlyClassProperties": true }]*/
class Foo {
readonly A = 1;
readonly B = 2;
public static readonly C = 1;
static readonly D = 1;
}
```

Examples of **correct** code for this rule with option "ignoreTypeIndexes":

```typescript
/*typescript no-magic-numbers: ["error", { "ignoreTypeIndexes": true }]*/
type Foo = Bar[0];
type Baz = Parameters<Foo>[2];
```

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_magic_numbers.rs)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<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> An auto-fix is still under development.
</Alert>
</div>

### What it does
Expand Down
8 changes: 6 additions & 2 deletions src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Calling them as functions will usually result in a TypeError being thrown.

### Example

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

```javascript
// Bad
let math = Math();
let newMath = new Math();

Expand All @@ -35,8 +36,11 @@ let newIntl = new Intl();

let reflect = Reflect();
let newReflect = new Reflect();
```

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

```javascript
let area = (r) => 2 * Math.PI * r * r;
let object = JSON.parse("{}");
let first = Atomics.load(sharedArray, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ Disallow unused private class members

Private class members that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such class members take up space in the code and can lead to confusion by readers.

### Example
### Examples

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

```javascript
/// bad
class A {
#unusedMember = 5;
}
Expand All @@ -46,14 +47,18 @@ class E {
get #unusedAccessor() {}
set #unusedAccessor(value) {}
}
```

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

/// Good
```javascript
class A {
#usedMember = 42;
method() {
return this.#usedMember;
}
}

class B {
#usedMethod() {
return 42;
Expand All @@ -62,6 +67,7 @@ class B {
return this.#usedMethod();
}
}

class C {
get #usedAccessor() {}
set #usedAccessor(value) {}
Expand Down
8 changes: 6 additions & 2 deletions src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ It is unnecessary to rename a variable to the same name.

### Example

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

```javascript
// Bad
import { foo as foo } from "foo";
const { bar: bar } = obj;
export { baz as baz };
```

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

```javascript
import { foo } from "foo";
const { bar: renamed } = obj;
export { baz };
Expand Down
Loading

0 comments on commit e0ced82

Please sign in to comment.