+
+### 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)
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md b/src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md
index f68c8f15152..7696f07d874 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md
@@ -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() {
@@ -26,7 +26,7 @@ async function bad() {
}
```
-Good:
+Examples of **correct** code for this rule:
```javascript
async function good() {
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-constructor-return.md b/src/docs/guide/usage/linter/rules/eslint/no-constructor-return.md
index cb9df0af434..ee3d16fc6e9 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-constructor-return.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-constructor-return.md
@@ -16,7 +16,7 @@ Forbidding this pattern prevents mistakes resulting from unfamiliarity with the
### Example
-Bad:
+Examples of **incorrect** code for this rule:
```rust
class C {
@@ -24,7 +24,7 @@ class C {
}
```
-Good:
+Examples of **correct** code for this rule:
```rust
class C {
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md b/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md
new file mode 100644
index 00000000000..f74008748a9
--- /dev/null
+++ b/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md
@@ -0,0 +1,40 @@
+
+
+# eslint/no-invalid-regexp
+
+
+
+✅ This rule is turned on by default.
+
+
+
+### 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)
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md b/src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md
new file mode 100644
index 00000000000..c705a4322b6
--- /dev/null
+++ b/src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md
@@ -0,0 +1,137 @@
+
+
+# eslint/no-magic-numbers
+
+
+
+🚧 An auto-fix is still under development.
+
+
+
+### 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[2];
+```
+
+## References
+
+- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_magic_numbers.rs)
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.md b/src/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.md
index 3f1e34c798d..44a085f7ee2 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.md
@@ -6,6 +6,9 @@
✅ This rule is turned on by default.
+
+🚧 An auto-fix is still under development.
+
### What it does
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md b/src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md
index b7a99ae2ca1..5a572aaae81 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md
@@ -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();
@@ -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);
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.md b/src/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.md
index a1c4bb9a458..94a5399ab31 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.md
@@ -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;
}
@@ -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;
@@ -62,6 +67,7 @@ class B {
return this.#usedMethod();
}
}
+
class C {
get #usedAccessor() {}
set #usedAccessor(value) {}
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md b/src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md
index f8893f971dd..7ea550c0a85 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md
@@ -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 };
diff --git a/src/docs/guide/usage/linter/rules/eslint/sort-keys.md b/src/docs/guide/usage/linter/rules/eslint/sort-keys.md
new file mode 100644
index 00000000000..ed2211dce75
--- /dev/null
+++ b/src/docs/guide/usage/linter/rules/eslint/sort-keys.md
@@ -0,0 +1,42 @@
+
+
+# eslint/sort-keys
+
+
+
+🚧 An auto-fix is still under development.
+
+
+
+### What it does
+
+When declaring multiple properties, sorting property names alphabetically makes it easier
+to find and/or diff necessary properties at a later time.
+
+### Why is this bad?
+
+Unsorted property keys can make the code harder to read and maintain.
+
+### Examples
+
+Examples of **incorrect** code for this rule:
+
+```js
+let myObj = {
+ c: 1,
+ a: 2,
+};
+```
+
+Examples of **correct** code for this rule:
+
+```js
+let myObj = {
+ a: 2,
+ c: 1,
+};
+```
+
+## References
+
+- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/sort_keys.rs)
diff --git a/src/docs/guide/usage/linter/rules/eslint/sort-vars.md b/src/docs/guide/usage/linter/rules/eslint/sort-vars.md
new file mode 100644
index 00000000000..01f3824c13e
--- /dev/null
+++ b/src/docs/guide/usage/linter/rules/eslint/sort-vars.md
@@ -0,0 +1,38 @@
+
+
+# eslint/sort-vars
+
+
+
+🚧 An auto-fix is still under development.
+
+
+
+### What it does
+
+When declaring multiple variables within the same block, sorting variable names make it
+easier to find necessary variable easier at a later time.
+
+### Why is this bad?
+
+Unsorted variable declarations can make the code harder to read and maintain.
+
+### Examples
+
+Examples of **incorrect** code for this rule:
+
+```js
+var b, a;
+var a, B, c;
+```
+
+Examples of **correct** code for this rule:
+
+```js
+var a, b, c, d;
+var B, a, c;
+```
+
+## References
+
+- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/sort_vars.rs)
diff --git a/src/docs/guide/usage/linter/rules/import/no-amd.md b/src/docs/guide/usage/linter/rules/import/no-amd.md
index 17826f982c2..97dd64919c6 100644
--- a/src/docs/guide/usage/linter/rules/import/no-amd.md
+++ b/src/docs/guide/usage/linter/rules/import/no-amd.md
@@ -9,12 +9,19 @@
Forbid AMD `require` and `define` calls.
-### Example
+### Why is this bad?
+
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// fail
require([a, b], function () {});
-// pass
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
require("../name");
require(`../name`);
```
diff --git a/src/docs/guide/usage/linter/rules/import/no-default-export.md b/src/docs/guide/usage/linter/rules/import/no-default-export.md
index 6ae3882a450..52414cd6abb 100644
--- a/src/docs/guide/usage/linter/rules/import/no-default-export.md
+++ b/src/docs/guide/usage/linter/rules/import/no-default-export.md
@@ -11,21 +11,20 @@ Forbid a module to have a default exports. This help your editor to provide bett
### Examples
+Examples of **incorrect** code for this rule:
+
```javascript
-// bad1.js
+export default 'bar';
-// There is a default export.
-export const foo = "foo";
-const bar = "bar";
-export default "bar";
+const foo = 'foo';
+export { foo as default }
```
-```javascript
-// bad2.js
+Examples of **correct** code for this rule:
-// There is a default export.
-const foo = "foo";
-export { foo as default };
+```javascript
+export const foo = "foo";
+export const bar = "bar";
```
## References
diff --git a/src/docs/guide/usage/linter/rules/import/no-dynamic-require.md b/src/docs/guide/usage/linter/rules/import/no-dynamic-require.md
new file mode 100644
index 00000000000..15c99e2738f
--- /dev/null
+++ b/src/docs/guide/usage/linter/rules/import/no-dynamic-require.md
@@ -0,0 +1,35 @@
+
+
+# import/no-dynamic-require
+
+
+
+
+### What it does
+
+Forbid imports which use an expression for the module argument.
+
+### Why is this bad?
+
+Import statements which use an expression resolved at runtime makes it to find where the
+import comes from and some static code analysis tools might not be able to resolve them.
+
+### Examples
+
+Examples of **incorrect** code for this rule:
+
+```javascript
+require(name);
+require(`../${name}`);
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
+require("../name");
+require(`../name`);
+```
+
+## References
+
+- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/import/no_dynamic_require.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/check-access.md b/src/docs/guide/usage/linter/rules/jsdoc/check-access.md
index f4fe1523c01..b696125d4d1 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/check-access.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/check-access.md
@@ -20,20 +20,24 @@ Also reports:
It is important to have a consistent way of specifying access levels.
-### Example
+### Examples
-```javascript
-// Passing
-/** @access private */
-
-/** @private */
+Examples of **incorrect** code for this rule:
-// Failing
+```javascript
/** @access private @public */
/** @access invalidlevel */
```
+Examples of **correct** code for this rule:
+
+```javascript
+/** @access private */
+
+/** @private */
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/check_access.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md b/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md
index cf496a70e60..b7cad91f237 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md
@@ -13,29 +13,34 @@ Ensures that property names in JSDoc are not duplicated on the same block and th
`@property` tags with the same name can be confusing and may indicate a mistake.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
/**
* @typedef {object} state
* @property {number} foo
+ * @property {string} foo
*/
+
/**
* @typedef {object} state
- * @property {object} foo
* @property {number} foo.bar
*/
+```
-// Failing
+Examples of **correct** code for this rule:
+
+```javascript
/**
* @typedef {object} state
* @property {number} foo
- * @property {string} foo
*/
/**
* @typedef {object} state
+ * @property {object} foo
* @property {number} foo.bar
*/
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md b/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md
index f383dfaef20..a04f3fbd103 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md
@@ -14,13 +14,11 @@ Additionally checks for tag names that are redundant when using a type checker s
Using invalid tags can lead to confusion and make the documentation harder to read.
-### Example
+### Examples
-```javascript
-// Passing
-/** @param */
+Examples of **incorrect** code for this rule:
-// Failing
+```javascript
/** @Param */
/** @foo */
@@ -30,6 +28,12 @@ Using invalid tags can lead to confusion and make the documentation harder to re
*/
```
+Examples of **correct** code for this rule:
+
+```javascript
+/** @param */
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md b/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md
index 90bd9f18add..a25db3cf525 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md
@@ -32,20 +32,24 @@ Expects the following tags to be empty of any content:
The void tags should be empty.
-### Example
+### Examples
-```javascript
-// Passing
-/** @async */
-
-/** @private */
+Examples of **incorrect** code for this rule:
-// Failing
+```javascript
/** @async foo */
/** @private bar */
```
+Examples of **correct** code for this rule:
+
+```javascript
+/** @async */
+
+/** @private */
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/empty_tags.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/implements-on-classes.md b/src/docs/guide/usage/linter/rules/jsdoc/implements-on-classes.md
index 9a2f492695d..43354ad03ca 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/implements-on-classes.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/implements-on-classes.md
@@ -14,10 +14,20 @@ Reports an issue with any non-constructor function using `@implements`.
Constructor functions should be
whether marked with `@class`, `@constructs`, or being an ES6 class constructor.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
+
+```javascript
+/**
+ * @implements {SomeClass}
+ */
+function quux() {}
+```
+
+Examples of **correct** code for this rule:
```javascript
-// Passing
class Foo {
/**
* @implements {SomeClass}
@@ -29,12 +39,6 @@ class Foo {
* @class
*/
function quux() {}
-
-// Failing
-/**
- * @implements {SomeClass}
- */
-function quux() {}
```
## References
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md b/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md
index 634798b2574..16ef181be35 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md
@@ -15,17 +15,22 @@ It also optionally reports the presence of the square-bracketed optional argumen
The rule is intended to prevent the indication of defaults on tags
where this would be redundant with ES6 default parameters.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
-/** @param {number} foo */
+/** @param {number} [foo="7"] */
function quux(foo) {}
-/** @param foo */
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
+/** @param {number} foo */
function quux(foo) {}
-// Failing
-/** @param {number} [foo="7"] */
+/** @param foo */
function quux(foo) {}
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md
index af0e3084ddd..11017726526 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md
@@ -13,15 +13,19 @@ Requires that each `@param` tag has a description value.
The description of a param should be documented.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
-/** @param foo Foo. */
+/** @param foo */
function quux(foo) {}
+```
-// Failing
-/** @param foo */
+Examples of **correct** code for this rule:
+
+```javascript
+/** @param foo Foo. */
function quux(foo) {}
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param-name.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param-name.md
index bc8ba5eaf80..2b7b3ee0dcb 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-param-name.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param-name.md
@@ -13,15 +13,19 @@ Requires that all `@param` tags have names.
The name of a param should be documented.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
-/** @param {SomeType} foo */
+/** @param {SomeType} */
function quux(foo) {}
+```
-// Failing
-/** @param {SomeType} */
+Examples of **correct** code for this rule:
+
+```javascript
+/** @param {SomeType} foo */
function quux(foo) {}
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md
index 39e0c99679a..1c235f685d6 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md
@@ -13,15 +13,19 @@ Requires that each `@param` tag has a type value (within curly brackets).
The type of a parameter should be documented.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
-/** @param {SomeType} foo */
+/** @param foo */
function quux(foo) {}
+```
-// Failing
-/** @param foo */
+Examples of **correct** code for this rule:
+
+```javascript
+/** @param {SomeType} foo */
function quux(foo) {}
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param.md
index 5b0008d5713..9ebb828bff8 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-param.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param.md
@@ -13,16 +13,20 @@ Requires that all function parameters are documented with JSDoc `@param` tags.
The rule is aimed at enforcing code quality and maintainability by requiring that all function parameters are documented.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
/** @param foo */
-function quux(foo) {}
+function quux(foo, bar) {}
+```
-// Failing
+Examples of **correct** code for this rule:
+
+```javascript
/** @param foo */
-function quux(foo, bar) {}
+function quux(foo) {}
```
## References
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property-description.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property-description.md
index cbc6725bcaf..83d71a5927a 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-property-description.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property-description.md
@@ -13,19 +13,23 @@ Requires that all `@property` tags have descriptions.
The description of a property should be documented.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
/**
* @typedef {SomeType} SomeTypedef
- * @property {number} foo Foo.
+ * @property {number} foo
*/
+```
-// Failing
+Examples of **correct** code for this rule:
+
+```javascript
/**
* @typedef {SomeType} SomeTypedef
- * @property {number} foo
+ * @property {number} foo Foo.
*/
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property-name.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property-name.md
index a38a3da0fcb..e32df50387c 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-property-name.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property-name.md
@@ -13,19 +13,23 @@ Requires that all `@property` tags have names.
The name of a property type should be documented.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
/**
* @typedef {SomeType} SomeTypedef
- * @property {number} foo
+ * @property {number}
*/
+```
-// Failing
+Examples of **correct** code for this rule:
+
+```javascript
/**
* @typedef {SomeType} SomeTypedef
- * @property {number}
+ * @property {number} foo
*/
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property-type.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property-type.md
index 403f0e51620..2fc820b5f1a 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-property-type.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property-type.md
@@ -13,19 +13,23 @@ Requires that each `@property` tag has a type value (within curly brackets).
The type of a property should be documented.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
/**
* @typedef {SomeType} SomeTypedef
- * @property {number} foo
+ * @property foo
*/
+```
-// Failing
+Examples of **correct** code for this rule:
+
+```javascript
/**
* @typedef {SomeType} SomeTypedef
- * @property foo
+ * @property {number} foo
*/
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property.md
index 5eced21203f..3212aa80306 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-property.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property.md
@@ -14,25 +14,31 @@ when their type is a plain `object`, `Object`, or `PlainObject`.
Object type should have properties defined.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
/**
* @typedef {Object} SomeTypedef
- * @property {SomeType} propName Prop description
*/
+
/**
- * @typedef {object} Foo
- * @property someProp
+ * @namespace {Object} SomeNamesoace
*/
+```
-// Failing
+Examples of **correct** code for this rule:
+
+```javascript
/**
* @typedef {Object} SomeTypedef
+ * @property {SomeType} propName Prop description
*/
+
/**
- * @namespace {Object} SomeNamesoace
+ * @typedef {object} Foo
+ * @property someProp
*/
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-returns-description.md b/src/docs/guide/usage/linter/rules/jsdoc/require-returns-description.md
index c35d0b08cc8..26447efcca1 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-returns-description.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-returns-description.md
@@ -14,15 +14,19 @@ The error will not be reported if the return value is `void `or `undefined` or i
A `@returns` tag should have a description value.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
-/** @returns Foo. */
+/** @returns */
function quux(foo) {}
+```
-// Failing
-/** @returns */
+Examples of **correct** code for this rule:
+
+```javascript
+/** @returns Foo. */
function quux(foo) {}
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-returns-type.md b/src/docs/guide/usage/linter/rules/jsdoc/require-returns-type.md
index f4b94f1a4a2..9abb5ba0435 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-returns-type.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-returns-type.md
@@ -13,15 +13,19 @@ Requires that `@returns` tag has a type value (in curly brackets).
A `@returns` tag should have a type value.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
-/** @returns {string} */
+/** @returns */
function quux(foo) {}
+```
-// Failing
-/** @returns */
+Examples of **correct** code for this rule:
+
+```javascript
+/** @returns {string} */
function quux(foo) {}
```
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md b/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md
index 839fa0fa3fc..a6b1a7050d7 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md
@@ -14,20 +14,16 @@ Will also report if multiple `@returns` tags are present.
The rule is intended to prevent the omission of `@returns` tag when necessary.
-### Example
+### Examples
-```javascript
-// Passing
-/** @returns Foo. */
-function quux() {
- return foo;
-}
+Examples of **incorrect** code for this rule:
-// Failing
+```javascript
/** Foo. */
function quux() {
return foo;
}
+
/**
* @returns Foo!
* @returns Foo?
@@ -37,6 +33,15 @@ function quux() {
}
```
+Examples of **correct** code for this rule:
+
+```javascript
+/** @returns Foo. */
+function quux() {
+ return foo;
+}
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/require_returns.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-yields.md b/src/docs/guide/usage/linter/rules/jsdoc/require-yields.md
index 5ed4920d22d..cbc9fe864b2 100644
--- a/src/docs/guide/usage/linter/rules/jsdoc/require-yields.md
+++ b/src/docs/guide/usage/linter/rules/jsdoc/require-yields.md
@@ -14,19 +14,15 @@ Will also report if multiple `@yields` tags are present.
The rule is intended to prevent the omission of `@yields` tags when they are necessary.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Passing
-/** * @yields Foo */
function* quux(foo) {
yield foo;
}
-// Failing
-function* quux(foo) {
- yield foo;
-}
/**
* @yields {undefined}
* @yields {void}
@@ -34,6 +30,15 @@ function* quux(foo) {
function* quux(foo) {}
```
+Examples of **correct** code for this rule:
+
+```javascript
+/** * @yields Foo */
+function* quux(foo) {
+ yield foo;
+}
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/require_yields.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/aria-unsupported-elements.md b/src/docs/guide/usage/linter/rules/jsx_a11y/aria-unsupported-elements.md
index cb002854348..f5da218273a 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/aria-unsupported-elements.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/aria-unsupported-elements.md
@@ -17,14 +17,18 @@ elements do not contain the `role` and/or `aria-*` props.
### Example
-```jsx
-// Good
-
+Examples of **incorrect** code for this rule:
-// Bad
+```jsx
```
+Examples of **correct** code for this rule:
+
+```jsx
+
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsx_a11y/aria_unsupported_elements.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/autocomplete-valid.md b/src/docs/guide/usage/linter/rules/jsx_a11y/autocomplete-valid.md
index 90a77c0966f..b2a31bed038 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/autocomplete-valid.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/autocomplete-valid.md
@@ -15,11 +15,15 @@ Incorrectly using the autocomplete attribute may decrease the accessibility of t
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/click-events-have-key-events.md b/src/docs/guide/usage/linter/rules/jsx_a11y/click-events-have-key-events.md
index a3974b75401..daff7b76a03 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/click-events-have-key-events.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/click-events-have-key-events.md
@@ -16,14 +16,18 @@ This does not apply for interactive or hidden elements.
### Example
-```jsx
-// Good
-
void 0} onKeyDown={() => void 0} />
+Examples of **incorrect** code for this rule:
-// Bad
+```jsx
void 0} />
```
+Examples of **correct** code for this rule:
+
+```jsx
+
void 0} onKeyDown={() => void 0} />
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content.md b/src/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content.md
index ffaed33864e..920dd44a97b 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content.md
@@ -20,11 +20,15 @@ from accessing information on the page's structure.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
Foo
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/html-has-lang.md b/src/docs/guide/usage/linter/rules/jsx_a11y/html-has-lang.md
index da7363d9e16..27dca79e55f 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/html-has-lang.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/html-has-lang.md
@@ -18,11 +18,15 @@ and access website in more than one language.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md b/src/docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md
index 1082c841219..282d40c1c80 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md
@@ -20,8 +20,9 @@ This rule checks for title property on iframe element.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
@@ -31,8 +32,11 @@ This rule checks for title property on iframe element.
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
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 3f2e67c0ed9..1840c745ece 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
@@ -23,13 +23,17 @@ This rule checks for alternative text on the following elements:
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
// Will pass because it is hidden.
// This is valid since photo is a variable name.
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/lang.md b/src/docs/guide/usage/linter/rules/jsx_a11y/lang.md
index a32115e2b15..d645dd1b2ed 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/lang.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/lang.md
@@ -16,20 +16,20 @@ the screen reader assumes the default language set by the user.
Language settings become an issue for users who speak multiple languages
and access website in more than one language.
-### Example
+### Examples
-// good
+Examples of **incorrect** code for this rule:
```jsx
-
-
+
+
```
-// bad
+Examples of **correct** code for this rule:
```jsx
-
-
+
+
```
### Resources
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/media-has-caption.md b/src/docs/guide/usage/linter/rules/jsx_a11y/media-has-caption.md
index 169105f2230..d9168a6fb34 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/media-has-caption.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/media-has-caption.md
@@ -17,16 +17,20 @@ Captions are also useful for users in noisy environments or where audio is not a
### Example
-```jsx
-// Good
-
-
+Examples of **incorrect** code for this rule:
-// Bad
+```jsx
```
+Examples of **correct** code for this rule:
+
+```jsx
+
+
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/mouse-events-have-key-events.md b/src/docs/guide/usage/linter/rules/jsx_a11y/mouse-events-have-key-events.md
index f0b199be57c..cbbe2a623b1 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/mouse-events-have-key-events.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/mouse-events-have-key-events.md
@@ -16,14 +16,18 @@ AT compatibility, and screenreader users.
### Example
-```jsx
-// Good
-
void 0} onFocus={() => void 0} />
+Examples of **incorrect** code for this rule:
-// Bad
+```jsx
void 0} />
```
+Examples of **correct** code for this rule:
+
+```jsx
+
void 0} onFocus={() => void 0} />
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsx_a11y/mouse_events_have_key_events.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/no-access-key.md b/src/docs/guide/usage/linter/rules/jsx_a11y/no-access-key.md
index 3716f3acc71..8d6e57b6e07 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/no-access-key.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/no-access-key.md
@@ -16,11 +16,15 @@ Inconsistencies between keyboard shortcuts and keyboard commands used by screenr
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/no-aria-hidden-on-focusable.md b/src/docs/guide/usage/linter/rules/jsx_a11y/no-aria-hidden-on-focusable.md
index c515ca81133..a2b6314f815 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/no-aria-hidden-on-focusable.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/no-aria-hidden-on-focusable.md
@@ -18,11 +18,15 @@ Enforces that `aria-hidden="true"` is not set on focusable elements.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/no-distracting-elements.md b/src/docs/guide/usage/linter/rules/jsx_a11y/no-distracting-elements.md
index 51a49bb401c..d09f34538f3 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/no-distracting-elements.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/no-distracting-elements.md
@@ -22,16 +22,20 @@ This rule checks for marquee and blink element.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/no-redundant-roles.md b/src/docs/guide/usage/linter/rules/jsx_a11y/no-redundant-roles.md
index 7fdb5c4ca00..1762cd0c114 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/no-redundant-roles.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/no-redundant-roles.md
@@ -19,11 +19,15 @@ Redundant roles can lead to confusion and verbosity in the codebase.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/prefer-tag-over-role.md b/src/docs/guide/usage/linter/rules/jsx_a11y/prefer-tag-over-role.md
index b5d64c0c66d..79795cad392 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/prefer-tag-over-role.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/prefer-tag-over-role.md
@@ -15,11 +15,15 @@ Using semantic HTML tags can improve accessibility and readability of the code.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/role-has-required-aria-props.md b/src/docs/guide/usage/linter/rules/jsx_a11y/role-has-required-aria-props.md
index 72ea193e436..6895fbedbd3 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/role-has-required-aria-props.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/role-has-required-aria-props.md
@@ -17,11 +17,15 @@ semantics for assistive technology.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/role-supports-aria-props.md b/src/docs/guide/usage/linter/rules/jsx_a11y/role-supports-aria-props.md
index d1faff2a0b2..a223c1df4ba 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/role-supports-aria-props.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/role-supports-aria-props.md
@@ -11,15 +11,9 @@ Enforce that elements with explicit or implicit roles defined contain only `aria
### Example
-```jsx
-// Good
-
-
Rainbow Trout
-
Brook Trout
-
Lake Trout
-
+Examples of **incorrect** code for this rule:
-// Bad
+```jsx
Rainbow Trout
Brook Trout
@@ -27,6 +21,16 @@ Enforce that elements with explicit or implicit roles defined contain only `aria
```
+Examples of **correct** code for this rule:
+
+```jsx
+
+
Rainbow Trout
+
Brook Trout
+
Lake Trout
+
+```
+
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsx_a11y/role_supports_aria_props.rs)
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/scope.md b/src/docs/guide/usage/linter/rules/jsx_a11y/scope.md
index 269e8ed60a4..a7d01a7e5ef 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/scope.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/scope.md
@@ -20,11 +20,15 @@ A screen reader operates under the assumption that a table has a header and that
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/tabindex-no-positive.md b/src/docs/guide/usage/linter/rules/jsx_a11y/tabindex-no-positive.md
index d699c8e62fe..d1deb7e65bb 100644
--- a/src/docs/guide/usage/linter/rules/jsx_a11y/tabindex-no-positive.md
+++ b/src/docs/guide/usage/linter/rules/jsx_a11y/tabindex-no-positive.md
@@ -21,11 +21,15 @@ disrupting the logical order of content.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
foo
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
foobar
```
diff --git a/src/docs/guide/usage/linter/rules/nextjs/no-typos.md b/src/docs/guide/usage/linter/rules/nextjs/no-typos.md
index bd2e59981eb..7152b84589c 100644
--- a/src/docs/guide/usage/linter/rules/nextjs/no-typos.md
+++ b/src/docs/guide/usage/linter/rules/nextjs/no-typos.md
@@ -3,6 +3,9 @@
# nextjs/no-typos
+
+🚧 An auto-fix is still under development.
+
### What it does
diff --git a/src/docs/guide/usage/linter/rules/node/no-exports-assign.md b/src/docs/guide/usage/linter/rules/node/no-exports-assign.md
new file mode 100644
index 00000000000..d28fb67c8a8
--- /dev/null
+++ b/src/docs/guide/usage/linter/rules/node/no-exports-assign.md
@@ -0,0 +1,41 @@
+
+
+# node/no-exports-assign
+
+
+
+🛠️ An auto-fix is available for this rule.
+
+
+
+### What it does
+
+This rule is aimed at disallowing `exports = {}`, but allows `module.exports = exports = {}` to avoid conflict with `n/exports-style` rule's `allowBatchAssign` option.
+
+### Why is this bad?
+
+Directly using `exports = {}` can lead to confusion and potential bugs because it reassigns the `exports` object, which may break module exports. It is more predictable and clearer to use `module.exports` directly or in conjunction with `exports`.
+
+### Examples
+
+Examples of **incorrect** code for this rule:
+
+```js
+exports = {};
+```
+
+Examples of **correct** code for this rule:
+
+```js
+module.exports.foo = 1;
+exports.bar = 2;
+module.exports = {};
+
+// allows `exports = {}` if along with `module.exports =`
+module.exports = exports = {};
+exports = module.exports = {};
+```
+
+## References
+
+- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/node/no_exports_assign.rs)
diff --git a/src/docs/guide/usage/linter/rules/oxc/approx-constant.md b/src/docs/guide/usage/linter/rules/oxc/approx-constant.md
index 5706547488e..a9068958d19 100644
--- a/src/docs/guide/usage/linter/rules/oxc/approx-constant.md
+++ b/src/docs/guide/usage/linter/rules/oxc/approx-constant.md
@@ -16,11 +16,15 @@ Approximate constants are not as accurate as the constants in the `Math` object.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
let log10e = 0.434294;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
let log10e = Math.LOG10E;
```
diff --git a/src/docs/guide/usage/linter/rules/oxc/bad-char-at-comparison.md b/src/docs/guide/usage/linter/rules/oxc/bad-char-at-comparison.md
index 41313ee2164..2f9af71ce67 100644
--- a/src/docs/guide/usage/linter/rules/oxc/bad-char-at-comparison.md
+++ b/src/docs/guide/usage/linter/rules/oxc/bad-char-at-comparison.md
@@ -16,14 +16,18 @@ This rule warns when the return value of the `charAt` method is used to compare
The `charAt` method returns a string of length 1. If the return value is compared with a string of length greater than 1, the comparison will always be false.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Bad: The return value of the `charAt` method is compared with a string of length greater than 1.
a.charAt(4) === "a2";
a.charAt(4) === "/n";
+```
-// Good: The return value of the `charAt` method is compared with a string of length 1.
+Examples of **correct** code for this rule:
+
+```javascript
a.charAt(4) === "a";
a.charAt(4) === "\n";
```
diff --git a/src/docs/guide/usage/linter/rules/oxc/bad-object-literal-comparison.md b/src/docs/guide/usage/linter/rules/oxc/bad-object-literal-comparison.md
index b6d0272569c..d2b366934fe 100644
--- a/src/docs/guide/usage/linter/rules/oxc/bad-object-literal-comparison.md
+++ b/src/docs/guide/usage/linter/rules/oxc/bad-object-literal-comparison.md
@@ -20,14 +20,18 @@ If you want to check if an object or array is empty, use `Object.entries()` or `
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
if (x === {}) {
}
if (arr !== []) {
}
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
if (typeof x === "object" && Object.keys(x).length === 0) {
}
if (Array.isArray(x) && x.length === 0) {
diff --git a/src/docs/guide/usage/linter/rules/oxc/bad-replace-all-arg.md b/src/docs/guide/usage/linter/rules/oxc/bad-replace-all-arg.md
index 0338319d27a..2365d4c1d2f 100644
--- a/src/docs/guide/usage/linter/rules/oxc/bad-replace-all-arg.md
+++ b/src/docs/guide/usage/linter/rules/oxc/bad-replace-all-arg.md
@@ -16,13 +16,17 @@ This rule warns when the `replaceAll` method is called with a regular expression
The `replaceAll` method replaces all occurrences of a string with another string. If the global flag (g) is not used in the regular expression, only the first occurrence of the string will be replaced.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Bad: The global flag (g) is missing in the regular expression.
withSpaces.replaceAll(/\s+/, ",");
+```
-// Good: The global flag (g) is used in the regular expression.
+Examples of **correct** code for this rule:
+
+```javascript
withSpaces.replaceAll(/\s+/g, ",");
```
diff --git a/src/docs/guide/usage/linter/rules/oxc/const-comparisons.md b/src/docs/guide/usage/linter/rules/oxc/const-comparisons.md
index 747a1fdb0d8..b92a93e7194 100644
--- a/src/docs/guide/usage/linter/rules/oxc/const-comparisons.md
+++ b/src/docs/guide/usage/linter/rules/oxc/const-comparisons.md
@@ -21,13 +21,17 @@ Only one of the comparisons has any effect on the result, the programmer probabl
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
status_code <= 400 && status_code > 500;
status_code < 200 && status_code <= 299;
status_code > 500 && status_code >= 500;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
status_code >= 400 && status_code < 500;
500 <= status_code && 600 > status_code;
500 <= status_code && status_code <= 600;
diff --git a/src/docs/guide/usage/linter/rules/oxc/double-comparisons.md b/src/docs/guide/usage/linter/rules/oxc/double-comparisons.md
index 738689734b3..7c5113f5e0f 100644
--- a/src/docs/guide/usage/linter/rules/oxc/double-comparisons.md
+++ b/src/docs/guide/usage/linter/rules/oxc/double-comparisons.md
@@ -21,12 +21,16 @@ Redundant comparisons can be confusing and make code harder to understand.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
x === y || x < y;
x < y || x === y;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
x <= y;
x >= y;
```
diff --git a/src/docs/guide/usage/linter/rules/oxc/erasing-op.md b/src/docs/guide/usage/linter/rules/oxc/erasing-op.md
index 967953ddd63..9f56b1afec6 100644
--- a/src/docs/guide/usage/linter/rules/oxc/erasing-op.md
+++ b/src/docs/guide/usage/linter/rules/oxc/erasing-op.md
@@ -6,6 +6,9 @@
✅ This rule is turned on by default.
+
+💡 A suggestion is available for this rule.
+
### What it does
@@ -23,7 +26,6 @@ The whole expression can be replaced by zero. This is most likely not the intend
Examples of **incorrect** code for this rule:
```javascript
-// Bad
let x = 1;
let y = x * 0;
```
diff --git a/src/docs/guide/usage/linter/rules/oxc/misrefactored-assign-op.md b/src/docs/guide/usage/linter/rules/oxc/misrefactored-assign-op.md
index 1b5399866ae..fb386a36909 100644
--- a/src/docs/guide/usage/linter/rules/oxc/misrefactored-assign-op.md
+++ b/src/docs/guide/usage/linter/rules/oxc/misrefactored-assign-op.md
@@ -3,6 +3,9 @@
# oxc/misrefactored-assign-op
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -17,12 +20,16 @@ Most likely these are bugs where one meant to write `a op= b`.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
a += a + b;
a -= a - b;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
a += b;
a -= b;
```
diff --git a/src/docs/guide/usage/linter/rules/oxc/no-accumulating-spread.md b/src/docs/guide/usage/linter/rules/oxc/no-accumulating-spread.md
index b9bc60f97f6..bdecfa8d9c8 100644
--- a/src/docs/guide/usage/linter/rules/oxc/no-accumulating-spread.md
+++ b/src/docs/guide/usage/linter/rules/oxc/no-accumulating-spread.md
@@ -19,9 +19,21 @@ When used on an accumulator, this can lead to `O(n^2)` memory complexity and
For a more in-depth explanation, see this [blog post](https://prateeksurana.me/blog/why-using-object-spread-with-reduce-bad-idea/)
by Prateek Surana.
-### Example
+### Examples
-Pass
+Examples of **incorrect** code for this rule:
+
+```javascript
+arr.reduce((acc, x) => ({ ...acc, [x]: fn(x) }), {});
+Object.keys(obj).reduce((acc, el) => ({ ...acc, [el]: fn(el) }), {});
+
+let foo = [];
+for (let i = 0; i < 10; i++) {
+ foo = [...foo, i];
+}
+```
+
+Examples of **correct** code for this rule:
```javascript
function fn(x) {
@@ -45,18 +57,6 @@ for (let i = 0; i < 10; i++) {
}
```
-Fail
-
-```javascript
-arr.reduce((acc, x) => ({ ...acc, [x]: fn(x) }), {});
-Object.keys(obj).reduce((acc, el) => ({ ...acc, [el]: fn(el) }), {});
-
-let foo = [];
-for (let i = 0; i < 10; i++) {
- foo = [...foo, i];
-}
-```
-
## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/oxc/no_accumulating_spread.rs)
diff --git a/src/docs/guide/usage/linter/rules/oxc/only-used-in-recursion.md b/src/docs/guide/usage/linter/rules/oxc/only-used-in-recursion.md
index 6bdd0a9f253..38c02453121 100644
--- a/src/docs/guide/usage/linter/rules/oxc/only-used-in-recursion.md
+++ b/src/docs/guide/usage/linter/rules/oxc/only-used-in-recursion.md
@@ -23,10 +23,11 @@ Supplying an argument that is only used in recursive calls is likely a mistake.
It increase cognitive complexity and may impact performance.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```ts
-// Bad - the argument `b` is only used in recursive calls
function f(a: number, b: number): number {
if (a == 0) {
return 1;
@@ -34,8 +35,11 @@ function f(a: number, b: number): number {
return f(a - 1, b + 1);
}
}
+```
-// Good - the argument `b` is omitted
+Examples of **correct** code for this rule:
+
+```ts
function f(a: number): number {
if (a == 0) {
return 1;
diff --git a/src/docs/guide/usage/linter/rules/react/button-has-type.md b/src/docs/guide/usage/linter/rules/react/button-has-type.md
index fb5b118530e..4232dc4df30 100644
--- a/src/docs/guide/usage/linter/rules/react/button-has-type.md
+++ b/src/docs/guide/usage/linter/rules/react/button-has-type.md
@@ -17,12 +17,16 @@ unexpected page reloads.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/react/checked-requires-onchange-or-readonly.md b/src/docs/guide/usage/linter/rules/react/checked-requires-onchange-or-readonly.md
index ab35a3f571e..a43aad90d47 100644
--- a/src/docs/guide/usage/linter/rules/react/checked-requires-onchange-or-readonly.md
+++ b/src/docs/guide/usage/linter/rules/react/checked-requires-onchange-or-readonly.md
@@ -12,8 +12,9 @@ It also warns when checked and defaultChecked properties are used together.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
@@ -21,8 +22,11 @@ It also warns when checked and defaultChecked properties are used together.
React.createElement('input', { checked: false });
React.createElement('input', { type: 'checkbox', checked: true });
React.createElement('input', { type: 'checkbox', checked: true, defaultChecked: true });
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
{}} />
diff --git a/src/docs/guide/usage/linter/rules/react/jsx-key.md b/src/docs/guide/usage/linter/rules/react/jsx-key.md
index c0e8313c0ec..cbf47741828 100644
--- a/src/docs/guide/usage/linter/rules/react/jsx-key.md
+++ b/src/docs/guide/usage/linter/rules/react/jsx-key.md
@@ -14,16 +14,17 @@ Enforce `key` prop for elements in array
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
[1, 2, 3].map((x) => );
-[1, 2, 3]
- ?.map((x) => )
+[1, 2, 3]?.map((x) => );
+```
- [
- // Good
- (1, 2, 3)
- ].map((x) => );
+Examples of **correct** code for this rule:
+
+```jsx
+[1, 2, 3].map((x) => );
[1, 2, 3]?.map((x) => );
```
diff --git a/src/docs/guide/usage/linter/rules/react/jsx-no-duplicate-props.md b/src/docs/guide/usage/linter/rules/react/jsx-no-duplicate-props.md
index f69af053d79..3ffe5e4defb 100644
--- a/src/docs/guide/usage/linter/rules/react/jsx-no-duplicate-props.md
+++ b/src/docs/guide/usage/linter/rules/react/jsx-no-duplicate-props.md
@@ -19,12 +19,16 @@ Creating JSX elements with duplicate props can cause unexpected behavior in your
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
;
;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
;
;
```
diff --git a/src/docs/guide/usage/linter/rules/react/jsx-no-useless-fragment.md b/src/docs/guide/usage/linter/rules/react/jsx-no-useless-fragment.md
index cc5356b8f37..f7dc3111353 100644
--- a/src/docs/guide/usage/linter/rules/react/jsx-no-useless-fragment.md
+++ b/src/docs/guide/usage/linter/rules/react/jsx-no-useless-fragment.md
@@ -15,12 +15,16 @@ Fragments are a useful tool when you need to group multiple children without add
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
<>foo>
<>foo>
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
<>foo >
foo
```
diff --git a/src/docs/guide/usage/linter/rules/react/jsx-props-no-spread-multi.md b/src/docs/guide/usage/linter/rules/react/jsx-props-no-spread-multi.md
index a696cc14b89..1b6f997c77d 100644
--- a/src/docs/guide/usage/linter/rules/react/jsx-props-no-spread-multi.md
+++ b/src/docs/guide/usage/linter/rules/react/jsx-props-no-spread-multi.md
@@ -22,11 +22,15 @@ Even when that is not the case this will lead to unnecessary computations being
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/react/no-children-prop.md b/src/docs/guide/usage/linter/rules/react/no-children-prop.md
index 10075292e33..9e0de05a735 100644
--- a/src/docs/guide/usage/linter/rules/react/no-children-prop.md
+++ b/src/docs/guide/usage/linter/rules/react/no-children-prop.md
@@ -18,16 +18,19 @@ When not using JSX, the children should be passed as additional arguments to `Re
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
} />
React.createElement("div", { children: 'Children' })
+```
-// Good
+Examples of **correct** code for this rule:
+```jsx
Children
Children
@@ -38,8 +41,6 @@ React.createElement("div", { children: 'Children' })
React.createElement("div", {}, 'Children')
React.createElement("div", 'Child 1', 'Child 2')
-
-
```
## References
diff --git a/src/docs/guide/usage/linter/rules/react/no-render-return-value.md b/src/docs/guide/usage/linter/rules/react/no-render-return-value.md
index 16b2f30ee38..f6f8b647876 100644
--- a/src/docs/guide/usage/linter/rules/react/no-render-return-value.md
+++ b/src/docs/guide/usage/linter/rules/react/no-render-return-value.md
@@ -14,14 +14,18 @@ This rule will warn you if you try to use the ReactDOM.render() return value.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
vaa inst =ReactDOM.render(, document.body);
function render() {
return ReactDOM.render(, document.body);
}
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
ReactDOM.render(, document.body);
```
diff --git a/src/docs/guide/usage/linter/rules/react/no-string-refs.md b/src/docs/guide/usage/linter/rules/react/no-string-refs.md
index 1394e27c1c9..6e6270286c5 100644
--- a/src/docs/guide/usage/linter/rules/react/no-string-refs.md
+++ b/src/docs/guide/usage/linter/rules/react/no-string-refs.md
@@ -14,8 +14,9 @@ This rule prevents using string literals in ref attributes.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
var Hello = createReactClass({
render: function () {
return
Hello, world.
;
@@ -31,8 +32,11 @@ var Hello = createReactClass({
return
Hello, world.
;
},
});
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
var Hello = createReactClass({
componentDidMount: function () {
var component = this.hello;
diff --git a/src/docs/guide/usage/linter/rules/react/no-unknown-property.md b/src/docs/guide/usage/linter/rules/react/no-unknown-property.md
index 3ecf6230825..8e92b7b3f72 100644
--- a/src/docs/guide/usage/linter/rules/react/no-unknown-property.md
+++ b/src/docs/guide/usage/linter/rules/react/no-unknown-property.md
@@ -3,6 +3,9 @@
# react/no-unknown-property
+
+🚧 An auto-fix is still under development.
+
### What it does
diff --git a/src/docs/guide/usage/linter/rules/react/react-in-jsx-scope.md b/src/docs/guide/usage/linter/rules/react/react-in-jsx-scope.md
index 3cb77f936f1..9a869b66532 100644
--- a/src/docs/guide/usage/linter/rules/react/react-in-jsx-scope.md
+++ b/src/docs/guide/usage/linter/rules/react/react-in-jsx-scope.md
@@ -16,11 +16,15 @@ the `React` variable must be in scope.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
var a = ;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
import React from "react";
var a = ;
```
diff --git a/src/docs/guide/usage/linter/rules/react/self-closing-comp.md b/src/docs/guide/usage/linter/rules/react/self-closing-comp.md
new file mode 100644
index 00000000000..3f0593c3a54
--- /dev/null
+++ b/src/docs/guide/usage/linter/rules/react/self-closing-comp.md
@@ -0,0 +1,39 @@
+
+
+# react/self-closing-comp
+
+
+
+🚧 An auto-fix is still under development.
+
+
+
+### What it does
+
+Detects components without children which can be self-closed to avoid unnecessary extra
+closing tags.
+
+A self closing component which contains whitespace is allowed except when it also contains
+a newline.
+
+### Examples
+
+Examples of **incorrect** code for this rule:
+
+```jsx
+const elem = ;
+const dom_elem = ;
+const welem = ;
+```
+
+Examples of **correct** code for this rule:
+
+```jsx
+const elem = ;
+const welem = ;
+const dom_elem = ;
+```
+
+## References
+
+- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/react/self_closing_comp.rs)
diff --git a/src/docs/guide/usage/linter/rules/react/void-dom-elements-no-children.md b/src/docs/guide/usage/linter/rules/react/void-dom-elements-no-children.md
index 60b46c7441b..293527a59c7 100644
--- a/src/docs/guide/usage/linter/rules/react/void-dom-elements-no-children.md
+++ b/src/docs/guide/usage/linter/rules/react/void-dom-elements-no-children.md
@@ -15,16 +15,20 @@ This rule checks that children are not passed to void DOM elements.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
Children
React.createElement('br', undefined, 'Children')
React.createElement('br', { children: 'Children' })
React.createElement('br', { dangerouslySetInnerHTML: { __html: 'HTML' } })
+```
-// Good
+Examples of **correct** code for this rule:
+
+```jsx
Children
diff --git a/src/docs/guide/usage/linter/rules/react_perf/jsx-no-jsx-as-prop.md b/src/docs/guide/usage/linter/rules/react_perf/jsx-no-jsx-as-prop.md
index c81035b6bfc..602d3def802 100644
--- a/src/docs/guide/usage/linter/rules/react_perf/jsx-no-jsx-as-prop.md
+++ b/src/docs/guide/usage/linter/rules/react_perf/jsx-no-jsx-as-prop.md
@@ -7,17 +7,30 @@
### What it does
-Prevent JSX that are local to the current method from being used as values of JSX props
+Prevent JSX elements that are local to the current method from being
+used as values of JSX props.
+
+### Why is this bad?
+
+Using locally defined JSX elements as values for props can lead to
+unintentional re-renders and performance issues. Every time the parent
+renders, a new instance of the JSX element is created, causing unnecessary
+re-renders of child components. This also leads to harder-to-maintain code
+as the component's props are not passed consistently.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
} />
} />
} />
+```
+
+Examples of **correct** code for this rule:
-// Good
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-array-as-prop.md b/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-array-as-prop.md
index a9fcbce8cbf..a8d8d708c53 100644
--- a/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-array-as-prop.md
+++ b/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-array-as-prop.md
@@ -7,20 +7,32 @@
### What it does
-Prevent Arrays that are local to the current method from being used as values of JSX props
+Prevent Arrays that are local to the current method from being used
+as values of JSX props.
+
+### Why is this bad?
+
+Using locally defined Arrays as values for props can lead to unintentional
+re-renders and performance issues. Every time the parent component renders,
+a new instance of the Array is created, causing unnecessary re-renders of
+child components. This also leads to harder-to-maintain code as the
+component's props are not passed consistently.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
-
+```
+
+Examples of **correct** code for this rule:
-// Good
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-function-as-prop.md b/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-function-as-prop.md
index c076e76b4fa..74cfc1cc682 100644
--- a/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-function-as-prop.md
+++ b/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-function-as-prop.md
@@ -7,16 +7,29 @@
### What it does
-Prevent Functions that are local to the current method from being used as values of JSX props
+Prevent Functions that are local to the current method from being used
+as values of JSX props.
+
+### Why is this bad?
+
+Using locally defined Functions as values for props can lead to unintentional
+re-renders and performance issues. Every time the parent component renders,
+a new instance of the Function is created, causing unnecessary re-renders
+of child components. This also leads to harder-to-maintain code as the
+component's props are not passed consistently.
### Example
+Examples of **incorrect** code for this rule:
+
```jsx
-// Bad
+```
+
+Examples of **correct** code for this rule:
-// Good
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-object-as-prop.md b/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-object-as-prop.md
index e865b990d48..40608ba840e 100644
--- a/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-object-as-prop.md
+++ b/src/docs/guide/usage/linter/rules/react_perf/jsx-no-new-object-as-prop.md
@@ -7,17 +7,33 @@
### What it does
-Prevent Objects that are local to the current method from being used as values of JSX props
+Prevent Objects that are local to the current method from being used
+as values of JSX props.
+
+### Why is this bad?
+
+Using locally defined Objects as values for props can lead to unintentional
+re-renders and performance issues. Every time the parent component renders,
+a new instance of the Object is created, causing unnecessary re-renders of
+child components. This also leads to harder-to-maintain code as the
+component's props are not passed consistently.
+
+### Examples
+
+Examples of **incorrect** code for this rule:
```jsx
-// Bad
+
+```
+
+Examples of **correct** code for this rule:
-// Good
+```jsx
```
diff --git a/src/docs/guide/usage/linter/rules/typescript/ban-types.md b/src/docs/guide/usage/linter/rules/typescript/ban-types.md
index 70b8c7ea8b5..163deffcb60 100644
--- a/src/docs/guide/usage/linter/rules/typescript/ban-types.md
+++ b/src/docs/guide/usage/linter/rules/typescript/ban-types.md
@@ -3,6 +3,9 @@
# typescript/ban-types
+
+🚧 An auto-fix is still under development.
+
### What it does
diff --git a/src/docs/guide/usage/linter/rules/typescript/consistent-indexed-object-style.md b/src/docs/guide/usage/linter/rules/typescript/consistent-indexed-object-style.md
index f3bddde2564..ac0f2b4f751 100644
--- a/src/docs/guide/usage/linter/rules/typescript/consistent-indexed-object-style.md
+++ b/src/docs/guide/usage/linter/rules/typescript/consistent-indexed-object-style.md
@@ -16,12 +16,11 @@ Require or disallow the `Record` type.
Inconsistent style for indexed object types can harm readability in a project.
-### Example
+### Examples
-With "record":
+Examples of **incorrect** code for this rule:
```ts
-// bad
interface Foo {
[key: string]: unknown;
}
@@ -30,10 +29,9 @@ type Foo = {
};
```
-With "index-signature":
+Examples of **correct** code for this rule:
```ts
-// bad
type Foo = Record;
```
diff --git a/src/docs/guide/usage/linter/rules/typescript/no-confusing-non-null-assertion.md b/src/docs/guide/usage/linter/rules/typescript/no-confusing-non-null-assertion.md
index 86858ab52d2..a0b2e4ac8eb 100644
--- a/src/docs/guide/usage/linter/rules/typescript/no-confusing-non-null-assertion.md
+++ b/src/docs/guide/usage/linter/rules/typescript/no-confusing-non-null-assertion.md
@@ -3,6 +3,9 @@
# typescript/no-confusing-non-null-assertion
+
+🚧 An auto-fix is still under development.
+
### What it does
diff --git a/src/docs/guide/usage/linter/rules/typescript/prefer-enum-initializers.md b/src/docs/guide/usage/linter/rules/typescript/prefer-enum-initializers.md
index 509afa82565..727b0101e45 100644
--- a/src/docs/guide/usage/linter/rules/typescript/prefer-enum-initializers.md
+++ b/src/docs/guide/usage/linter/rules/typescript/prefer-enum-initializers.md
@@ -3,6 +3,9 @@
# typescript/prefer-enum-initializers
+
+🚧 An auto-fix is still under development.
+
### What it does
diff --git a/src/docs/guide/usage/linter/rules/typescript/prefer-for-of.md b/src/docs/guide/usage/linter/rules/typescript/prefer-for-of.md
index 8c68f13616b..e487d8f34a3 100644
--- a/src/docs/guide/usage/linter/rules/typescript/prefer-for-of.md
+++ b/src/docs/guide/usage/linter/rules/typescript/prefer-for-of.md
@@ -3,6 +3,9 @@
# typescript/prefer-for-of
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -17,13 +20,17 @@ eliminate the need for an index variable and manual array access.
### Example
-```ts
-// Bad
+Examples of **incorrect** code for this rule:
+
+```typescript
for (let i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
+```
+
+Examples of **correct** code for this rule:
-// Good
+```typescript
for (const item of arr) {
console.log(item);
}
diff --git a/src/docs/guide/usage/linter/rules/unicorn/catch-error-name.md b/src/docs/guide/usage/linter/rules/unicorn/catch-error-name.md
index edbfe4bf157..702ce4a88b5 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/catch-error-name.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/catch-error-name.md
@@ -3,20 +3,29 @@
# unicorn/catch-error-name
+
+🚧 An auto-fix is still under development.
+
### What it does
This rule enforces naming conventions for catch statements.
-### Example
+### Why is this bad?
+
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// fail
try {
} catch (foo) {}
+```
-// pass
+Examples of **correct** code for this rule:
+
+```javascript
try {
} catch (error) {}
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/error-message.md b/src/docs/guide/usage/linter/rules/unicorn/error-message.md
index bda07e0f8db..4186631c5b2 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/error-message.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/error-message.md
@@ -9,14 +9,20 @@
This rule enforces a `message` value to be passed in when creating an instance of a built-in `Error` object, which leads to more readable and debuggable code.
-### Example
+### Why is this bad?
+
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Fail
throw Error();
throw new TypeError();
+```
-// Pass
+Examples of **correct** code for this rule:
+
+```javascript
throw new Error("Unexpected token");
throw new TypeError("Number expected");
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/escape-case.md b/src/docs/guide/usage/linter/rules/unicorn/escape-case.md
index a155b118d02..4a8d27509ff 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/escape-case.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/escape-case.md
@@ -12,15 +12,22 @@
Enforces defining escape sequence values with uppercase characters rather than lowercase ones. This promotes readability by making the escaped value more distinguishable from the identifier.
-### Example
+### Why is this bad?
+
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// fail
const foo = "\xa9";
const foo = "\ud834";
const foo = "\u{1d306}";
const foo = "ca";
-// pass
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
const foo = "\xA9";
const foo = "\uD834";
const foo = "\u{1D306}";
diff --git a/src/docs/guide/usage/linter/rules/unicorn/explicit-length-check.md b/src/docs/guide/usage/linter/rules/unicorn/explicit-length-check.md
index 6bde4f6dcb8..ea4cd000ea0 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/explicit-length-check.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/explicit-length-check.md
@@ -18,20 +18,27 @@ Enforces non-zero to be checked with: foo.length > 0
not-equal
Enforces non-zero to be checked with: foo.length !== 0
-### Example
+### Why is this bad?
+
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// fail
-const isEmpty = !foo.length;
const isEmpty = foo.length == 0;
const isEmpty = foo.length < 1;
const isEmpty = 0 === foo.length;
const isEmpty = 0 == foo.length;
const isEmpty = 1 > foo.length;
-// Negative style is disallowed too
+
+const isEmpty = !foo.length;
const isEmpty = !(foo.length > 0);
const isEmptySet = !foo.size;
-// pass
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
const isEmpty = foo.length === 0;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/new-for-builtins.md b/src/docs/guide/usage/linter/rules/unicorn/new-for-builtins.md
index a639f4bf57c..94ef5504952 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/new-for-builtins.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/new-for-builtins.md
@@ -17,14 +17,18 @@ These should not use `new` as that would create object wrappers for the primitiv
They work the same, but `new` should be preferred for consistency with other constructors.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
const foo = new String("hello world");
const bar = Array(1, 2, 3);
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
const foo = String("hello world");
const bar = new Array(1, 2, 3);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-abusive-eslint-disable.md b/src/docs/guide/usage/linter/rules/unicorn/no-abusive-eslint-disable.md
index 3c8e6a259d0..328b0434578 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-abusive-eslint-disable.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-abusive-eslint-disable.md
@@ -13,10 +13,11 @@ This rule disallows `eslint-disable` comments that do not specify any rules to d
When only one rule should be disabled but the `eslint-disable` comment does not specify any rules, other useful errors will also be silently ignored.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Fail
/* eslint-disable */
console.log(message);
@@ -24,8 +25,11 @@ console.log(message); // eslint-disable-line
// eslint-disable-next-line
console.log(message);
+```
-// Pass
+Examples of **correct** code for this rule:
+
+```javascript
/* eslint-disable no-console */
console.log(message);
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.md b/src/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.md
index 8ae70679246..5d339600af4 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.md
@@ -15,16 +15,20 @@ Naming default exports improves codebase searchability by ensuring consistent id
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
export default class {}
export default function () {}
export default () => {};
module.exports = class {};
module.exports = function () {};
module.exports = () => {};
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
export default class Foo {}
export default function foo () {}
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-array-for-each.md b/src/docs/guide/usage/linter/rules/unicorn/no-array-for-each.md
index f5f8184de04..53cae4b10ff 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-array-for-each.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-array-for-each.md
@@ -3,6 +3,9 @@
# unicorn/no-array-for-each
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -21,14 +24,18 @@ Additionally, using `for…of` has great benefits if you are using TypeScript, b
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const foo = [1, 2, 3];
foo.forEach((element) => {
/* ... */
});
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const foo = [1, 2, 3];
for (const element of foo) {
/* ... */
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md b/src/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md
index 2f903115e2e..fd00d326890 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md
@@ -20,9 +20,9 @@ mistake.
### Example
-Bad
+Examples of **incorrect** code for this rule:
-```js
+```javascript
async function foo() {
Promise.all([await promise, anotherPromise]);
Promise.allSettled([await promise, anotherPromise]);
@@ -31,9 +31,9 @@ async function foo() {
}
```
-Good
+Examples of **correct** code for this rule:
-```js
+```javascript
async function foo() {
Promise.all([promise, anotherPromise]);
Promise.allSettled([promise, anotherPromise]);
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-console-spaces.md b/src/docs/guide/usage/linter/rules/unicorn/no-console-spaces.md
index 669d6dc7b85..261ec8cbfd7 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-console-spaces.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-console-spaces.md
@@ -18,11 +18,15 @@ The `console.log()` method and similar methods join the parameters with a space
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
console.log("abc ", "def");
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
console.log("abc", "def");
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-document-cookie.md b/src/docs/guide/usage/linter/rules/unicorn/no-document-cookie.md
index 652067d778e..5475d07fdc1 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-document-cookie.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-document-cookie.md
@@ -22,14 +22,18 @@ the [Cookie Store
API](https://developer.mozilla.org/en-US/docs/Web/API/Cookie_Store_API)
or a [cookie library](https://www.npmjs.com/search?q=cookie).
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
document.cookie =
"foo=bar" + "; Path=/" + "; Domain=example.com" + "; expires=Fri, 31 Dec 9999 23:59:59 GMT" + "; Secure";
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
async function storeCookies() {
await cookieStore.set({
name: "foo",
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-hex-escape.md b/src/docs/guide/usage/linter/rules/unicorn/no-hex-escape.md
index 0d633397189..cee91bbd8bf 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-hex-escape.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-hex-escape.md
@@ -12,14 +12,20 @@
Enforces a convention of using [Unicode escapes](https://mathiasbynens.be/notes/javascript-escapes#unicode) instead of [hexadecimal escapes](https://mathiasbynens.be/notes/javascript-escapes#hexadecimal) for consistency and clarity.
-### Example
+### Why is this bad?
+
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// fail
const foo = "\x1B";
const foo = `\x1B${bar}`;
+```
-// pass
+Examples of **correct** code for this rule:
+
+```javascript
const foo = "\u001B";
const foo = `\u001B${bar}`;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.md b/src/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.md
index 3d20b5497ac..5a4123e5dc2 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.md
@@ -18,12 +18,16 @@ The [`removeEventListener`](https://developer.mozilla.org/en-US/docs/Web/API/Eve
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
el.removeEventListener("click", () => {});
el.removeEventListener("click", function () {});
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
el.removeEventListener("click", handler);
el.removeEventListener("click", handler.bind(this));
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-length-as-slice-end.md b/src/docs/guide/usage/linter/rules/unicorn/no-length-as-slice-end.md
index 80935590ee6..bf2d445bdf1 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-length-as-slice-end.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-length-as-slice-end.md
@@ -18,11 +18,15 @@ Passing `length` as the end argument of a `slice` call is unnecessary and can be
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
foo.slice(1, foo.length);
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
foo.slice(1);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-lonely-if.md b/src/docs/guide/usage/linter/rules/unicorn/no-lonely-if.md
index fe2cd4b0993..9561aa2c2b6 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-lonely-if.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-lonely-if.md
@@ -15,15 +15,19 @@ It can be confusing to have an `if` statement without an `else` clause as the on
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
if (foo) {
if (bar) {
}
}
if (foo) if (bar) baz();
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
if (foo && bar) {
}
if (foo && bar) baz();
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-magic-array-flat-depth.md b/src/docs/guide/usage/linter/rules/unicorn/no-magic-array-flat-depth.md
index f727964c7df..42d3795a5f2 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-magic-array-flat-depth.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-magic-array-flat-depth.md
@@ -15,12 +15,16 @@ Magic numbers are hard to understand and maintain. When calling `Array.prototype
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
array.flat(2);
array.flat(20);
-//
-// Good
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
array.flat(2 /* explanation */);
array.flat(1);
array.flat();
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-negated-condition.md b/src/docs/guide/usage/linter/rules/unicorn/no-negated-condition.md
index fa9a721c891..9c95cfa515d 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-negated-condition.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-negated-condition.md
@@ -3,6 +3,9 @@
# unicorn/no-negated-condition
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -15,9 +18,9 @@ Negated conditions are more difficult to understand. Code can be made more reada
### Example
-```javascript
-// Bad
+Examples of **incorrect** code for this rule:
+```javascript
if (!a) {
doSomethingC();
} else {
@@ -25,9 +28,11 @@ if (!a) {
}
!a ? doSomethingC() : doSomethingB();
+```
-// Good
+Examples of **correct** code for this rule:
+```javascript
if (a) {
doSomethingB();
} else {
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-negation-in-equality-check.md b/src/docs/guide/usage/linter/rules/unicorn/no-negation-in-equality-check.md
index d10a738c8cc..e2dda11a69c 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-negation-in-equality-check.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-negation-in-equality-check.md
@@ -3,6 +3,9 @@
# unicorn/no-negation-in-equality-check
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -15,17 +18,19 @@ A negated expression on the left of an (in)equality check is likely a mistake fr
### Example
-```javascript
-// Bad
+Examples of **incorrect** code for this rule:
+```javascript
if (!foo === bar) {
}
if (!foo !== bar) {
}
+```
-// Good
+Examples of **correct** code for this rule:
+```javascript
if (foo !== bar) {
}
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-nested-ternary.md b/src/docs/guide/usage/linter/rules/unicorn/no-nested-ternary.md
index fe8bf672b35..5342e0585da 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-nested-ternary.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-nested-ternary.md
@@ -17,14 +17,18 @@ Nested ternary expressions that are only one level deep and wrapped in parenthes
Nesting ternary expressions can make code more difficult to understand.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Fail
const foo = i > 5 ? (i < 100 ? true : false) : true;
const foo = i > 5 ? true : i < 100 ? true : i < 1000 ? true : false;
+```
-// Pass
+Examples of **correct** code for this rule:
+
+```javascript
const foo = i > 5 ? (i < 100 ? true : false) : true;
const foo = i > 5 ? (i < 100 ? true : false) : i < 100 ? true : false;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-new-array.md b/src/docs/guide/usage/linter/rules/unicorn/no-new-array.md
index 5f6d028d183..93685afc5c4 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-new-array.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-new-array.md
@@ -6,6 +6,9 @@
✅ This rule is turned on by default.
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -16,15 +19,19 @@ Disallow `new Array()`.
When using the `Array` constructor with one argument, it's not clear whether the argument is meant to be the length of the array or the only element.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
const array = new Array(1);
const array = new Array(42);
const array = new Array(foo);
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
const array = Array.from({ length: 42 });
const array = [42];
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-new-buffer.md b/src/docs/guide/usage/linter/rules/unicorn/no-new-buffer.md
index d73005c2235..ab3d850bc9b 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-new-buffer.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-new-buffer.md
@@ -3,6 +3,9 @@
# unicorn/no-new-buffer
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -15,11 +18,15 @@ Enforces the use of [Buffer.from](https://nodejs.org/api/buffer.html#static-meth
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const buffer = new Buffer(10);
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const buffer = Buffer.alloc(10);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-null.md b/src/docs/guide/usage/linter/rules/unicorn/no-null.md
index aacb570abfd..0589da48132 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-null.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-null.md
@@ -22,11 +22,15 @@ There are some reasons for using `undefined` instead of `null`.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
let foo = null;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
let foo;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-object-as-default-parameter.md b/src/docs/guide/usage/linter/rules/unicorn/no-object-as-default-parameter.md
index be2dc779258..810208f8dba 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-object-as-default-parameter.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-object-as-default-parameter.md
@@ -15,11 +15,15 @@ Default parameters should not be passed to a function through an object literal.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
function foo(foo = { a: false }) {}
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
function foo({ a = false } = {}) {}
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-process-exit.md b/src/docs/guide/usage/linter/rules/unicorn/no-process-exit.md
index ef6d26d4fc7..a9732b11ad8 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-process-exit.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-process-exit.md
@@ -15,11 +15,15 @@ Only use `process.exit()` in CLI apps. Throw an error instead.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
if (problem) process.exit(1);
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
if (problem) throw new Error("message");
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-single-promise-in-promise-methods.md b/src/docs/guide/usage/linter/rules/unicorn/no-single-promise-in-promise-methods.md
index 51a2d7cb35d..e7e647f59f0 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-single-promise-in-promise-methods.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-single-promise-in-promise-methods.md
@@ -22,9 +22,9 @@ Passing a single-element array to `Promise.all()`, `Promise.any()`, or
### Example
-Bad
+Examples of **incorrect** code for this rule:
-```js
+```javascript
async function bad() {
const foo = await Promise.all([promise]);
const foo = await Promise.any([promise]);
@@ -33,9 +33,9 @@ async function bad() {
}
```
-Good
+Examples of **correct** code for this rule:
-```js
+```javascript
async function good() {
const foo = await promise;
const promise = Promise.resolve(nonPromise);
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-static-only-class.md b/src/docs/guide/usage/linter/rules/unicorn/no-static-only-class.md
index 7fc76d2fbaa..3864963ff36 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-static-only-class.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-static-only-class.md
@@ -15,13 +15,17 @@ A class with only static members could just be an object instead.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
class A {
static a() {}
}
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
class A {
static a() {}
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-this-assignment.md b/src/docs/guide/usage/linter/rules/unicorn/no-this-assignment.md
index 5e5c5b85de3..69fb36db705 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-this-assignment.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-this-assignment.md
@@ -13,10 +13,11 @@ Disallow assigning `this` to a variable.
Assigning `this` to a variable is unnecessary and confusing.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// fail
const foo = this;
class Bar {
method() {
@@ -25,8 +26,11 @@ class Bar {
}
new Bar().method();
+```
-// pass
+Examples of **correct** code for this rule:
+
+```javascript
class Bar {
constructor(fooInstance) {
this.fooInstance = fooInstance;
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-typeof-undefined.md b/src/docs/guide/usage/linter/rules/unicorn/no-typeof-undefined.md
index aa7e4ec8cc5..77e050c70e4 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-typeof-undefined.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-typeof-undefined.md
@@ -3,6 +3,9 @@
# unicorn/no-typeof-undefined
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -13,13 +16,17 @@ Disallow `typeof` comparisons with `undefined`.
Checking if a value is `undefined` by using `typeof value === 'undefined'` is needlessly verbose. It's generally better to compare against `undefined` directly. The only time `typeof` is needed is when a global variable potentially does not exists, in which case, using `globalThis.value === undefined` may be better.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
typeof foo === "undefined";
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
foo === undefined;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.md b/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.md
index b4afa82c330..e00bced9393 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.md
@@ -16,11 +16,15 @@ This rule prevents ignoring consecutive values when destructuring from an array.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const [, , foo] = parts;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const [foo] = parts;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-iife.md b/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-iife.md
index 67b1d8ac17b..b1ed9665e15 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-iife.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-unreadable-iife.md
@@ -13,15 +13,19 @@ This rule disallows IIFEs with a parenthesized arrow function body.
IIFEs with a parenthesized arrow function body are unreadable.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Fail
const foo = ((bar) => (bar ? bar.baz : baz))(getBar());
const foo = ((bar, baz) => ({ bar, baz }))(bar, baz);
+```
-// Pass
+Examples of **correct** code for this rule:
+
+```javascript
const bar = getBar();
const foo = bar ? bar.baz : baz;
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-useless-fallback-in-spread.md b/src/docs/guide/usage/linter/rules/unicorn/no-useless-fallback-in-spread.md
index 81b0e89f598..8252eeb0904 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-useless-fallback-in-spread.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-useless-fallback-in-spread.md
@@ -19,13 +19,17 @@ Disallow useless fallback when spreading in object literals.
Spreading [falsy values](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) in object literals won't add any unexpected properties, so it's unnecessary to add an empty object as fallback.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
const object = { ...(foo || {}) };
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
const object = { ...foo };
const object = { ...(foo || { not: "empty" }) };
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.md b/src/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.md
index 56bc136eadb..65edd0dd666 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.md
@@ -6,6 +6,9 @@
✅ This rule is turned on by default.
+
+🚧 An auto-fix is still under development.
+
### What it does
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-useless-promise-resolve-reject.md b/src/docs/guide/usage/linter/rules/unicorn/no-useless-promise-resolve-reject.md
index 9bcd6d1d167..98edc0f3231 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-useless-promise-resolve-reject.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-useless-promise-resolve-reject.md
@@ -16,13 +16,17 @@ Disallows returning values wrapped in `Promise.resolve` or `Promise.reject` in a
Wrapping a return value in `Promise.resolve` in an async function or a `Promise#then`/`catch`/`finally` callback is unnecessary as all return values in async functions and promise callback functions are already wrapped in a `Promise`. Similarly, returning an error wrapped in `Promise.reject` is equivalent to simply `throw`ing the error. This is the same for `yield`ing in async generators as well.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
async () => Promise.resolve(bar);
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
async () => bar;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-useless-switch-case.md b/src/docs/guide/usage/linter/rules/unicorn/no-useless-switch-case.md
index 45c404c72df..fd712b6f709 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-useless-switch-case.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-useless-switch-case.md
@@ -3,6 +3,9 @@
# unicorn/no-useless-switch-case
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -13,17 +16,22 @@ Disallows useless default cases in switch statements.
An empty case before the last default case is useless.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
switch (foo) {
case 1:
default:
handleDefaultCase();
break;
}
-// good:
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
switch (foo) {
case 1:
case 2:
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-useless-undefined.md b/src/docs/guide/usage/linter/rules/unicorn/no-useless-undefined.md
index 05baed9c6fd..9a3808b82e6 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-useless-undefined.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-useless-undefined.md
@@ -16,12 +16,17 @@ Do not use useless `undefined`.
`undefined` is the default value for new variables, parameters, return statements, etc… so specifying it doesn't make any difference.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
let foo = undefined;
-// good:
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
let foo;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-zero-fractions.md b/src/docs/guide/usage/linter/rules/unicorn/no-zero-fractions.md
index ec342286e1d..5ab35f83fd2 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/no-zero-fractions.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/no-zero-fractions.md
@@ -18,13 +18,17 @@ There is no difference in JavaScript between, for example, `1`, `1.0` and `1.`,
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const foo = 1.0;
const foo = -1.0;
const foo = 123_456.000_000;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const foo = 1;
const foo = -1;
const foo = 123456;
diff --git a/src/docs/guide/usage/linter/rules/unicorn/number-literal-case.md b/src/docs/guide/usage/linter/rules/unicorn/number-literal-case.md
index efed24b2704..64a657aa25a 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/number-literal-case.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/number-literal-case.md
@@ -16,10 +16,11 @@ This rule enforces proper case for numeric literals.
When both an identifier and a number literal are in lower case, it can be hard to differentiate between them.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Fail
const foo = 0xff;
const foo = 0xff;
const foo = 0xff;
@@ -32,8 +33,11 @@ const foo = 0o76;
const foo = 0o76n;
const foo = 2e-5;
+```
-// Pass
+Examples of **correct** code for this rule:
+
+```javascript
const foo = 0xff;
const foo = 0b10;
const foo = 0o76;
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.md
index 4ffe6dae4ad..a5f854a5c71 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.md
@@ -3,6 +3,9 @@
# unicorn/prefer-add-event-listener
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -15,13 +18,17 @@ For example, `foo.addEventListener('click', handler);` is preferred over `foo.on
There are [numerous advantages of using `addEventListener`](https://stackoverflow.com/questions/6348494/addeventlistener-vs-onclick/35093997#35093997). Some of these advantages include registering unlimited event handlers and optionally having the event handler invoked only once.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
foo.onclick = () => {};
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
foo.addEventListener("click", () => {});
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-array-flat.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-array-flat.md
index b9aec4015ef..ffab5738513 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-array-flat.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-array-flat.md
@@ -20,8 +20,9 @@ This rule aims to standardize the use of `Array#flat()` over legacy techniques t
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const foo = array.flatMap((x) => x);
const foo = array.reduce((a, b) => a.concat(b), []);
const foo = array.reduce((a, b) => [...a, ...b], []);
@@ -31,8 +32,11 @@ const foo = [].concat.apply([], array);
const foo = Array.prototype.concat.apply([], array);
const foo = Array.prototype.concat.call([], maybeArray);
const foo = Array.prototype.concat.call([], ...array);
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const foo = array.flat();
const foo = [maybeArray].flat();
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-array-some.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-array-some.md
index 14d7b04038e..bdb2bf8bccd 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-array-some.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-array-some.md
@@ -18,11 +18,15 @@ Using `.some()` is more idiomatic and easier to read.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const foo = array.find(fn) ? bar : baz;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const foo = array.some(fn) ? bar : baz;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-blob-reading-methods.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-blob-reading-methods.md
index f491cc2d7d2..083fd559e9c 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-blob-reading-methods.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-blob-reading-methods.md
@@ -3,6 +3,9 @@
# unicorn/prefer-blob-reading-methods
+
+🚧 An auto-fix is still under development.
+
### What it does
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-code-point.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-code-point.md
index 99ea3e3ad9d..e76c5e98afd 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-code-point.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-code-point.md
@@ -19,14 +19,18 @@ Unicode is better supported in [`String#codePointAt()`](https://developer.mozill
[Difference between `String.fromCodePoint()` and `String.fromCharCode()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint#compared_to_fromcharcode)
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
"🦄".charCodeAt(0);
String.fromCharCode(0x1f984);
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
"🦄".codePointAt(0);
String.fromCodePoint(0x1f984);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-date-now.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-date-now.md
index a76f5f6ed44..5dbe6430af1 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-date-now.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-date-now.md
@@ -16,14 +16,18 @@ Prefers use of `Date.now()` over `new Date().getTime()` or `new Date().valueOf()
Using `Date.now()` is shorter and nicer than `new Date().getTime()`, and avoids unnecessary instantiation of `Date` objects.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
const ts = new Date().getTime();
const ts = new Date().valueOf();
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
const ts = Date.now();
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-append.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-append.md
index a55a3b661f5..bb672d004b3 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-append.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-append.md
@@ -16,12 +16,17 @@ Enforces the use of, for example, `document.body.append(div);` over `document.bo
There are [some advantages of using `Node#append()`](https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append), like the ability to append multiple nodes and to append both [`DOMString`](https://developer.mozilla.org/en-US/docs/Web/API/DOMString) and DOM node objects.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
foo.appendChild(bar);
+```
+Examples of **correct** code for this rule:
+
+```javascript
foo.append(bar);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-dataset.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-dataset.md
index af140950286..df687273404 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-dataset.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-dataset.md
@@ -3,6 +3,9 @@
# unicorn/prefer-dom-node-dataset
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -15,11 +18,15 @@ The `dataset` property is a map of strings that contains all the `data-*` attrib
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
element.setAttribute("data-unicorn", "🦄");
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
element.dataset.unicorn = "🦄";
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.md
index 50e0fd17d8f..86e6c297ae9 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.md
@@ -13,13 +13,17 @@ Prefers the use of `child.remove()` over `parentNode.removeChild(child)`.
The DOM function [`Node#remove()`](https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove) is preferred over the indirect removal of an object with [`Node#removeChild()`](https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild).
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
parentNode.removeChild(childNode);
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
childNode.remove();
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.md
index 813e6054b02..460a0d1fc1c 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.md
@@ -22,11 +22,15 @@ There are some disadvantages of using .innerText.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const text = foo.innerText;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const text = foo.textContent;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-event-target.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-event-target.md
index 5f6c05704ed..cadabcce1ed 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-event-target.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-event-target.md
@@ -19,11 +19,15 @@ While [`EventEmitter`](https://nodejs.org/api/events.html#class-eventemitter) is
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
class Foo extends EventEmitter {}
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
class Foo extends OtherClass {}
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-includes.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-includes.md
index d7ca972b398..02616ea1a7d 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-includes.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-includes.md
@@ -3,26 +3,32 @@
# unicorn/prefer-includes
+
+🚧 An auto-fix is still under development.
+
### What it does
Prefer `includes()` over `indexOf()` when checking for existence or non-existence.
-
All built-ins have `.includes()` in addition to `.indexOf()`.
### Why is this bad?
The `.includes()` method is more readable and less error-prone than `.indexOf()`.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
if (str.indexOf("foo") !== -1) {
}
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
if (str.includes("foo")) {
}
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-logical-operator-over-ternary.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-logical-operator-over-ternary.md
index 987d2511259..7654c0b642d 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-logical-operator-over-ternary.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-logical-operator-over-ternary.md
@@ -3,6 +3,9 @@
# unicorn/prefer-logical-operator-over-ternary
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -15,16 +18,20 @@ Using a logical operator is shorter and simpler than a ternary expression.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const foo = bar ? bar : baz;
console.log(foo ? foo : bar);
+```
-// Good
+Examples of **correct** code for this rule:
const foo = bar || baz;
console.log(foo ?? bar);
+
```
-## References
+## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/unicorn/prefer_logical_operator_over_ternary.rs)
+```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-math-trunc.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-math-trunc.md
index 9bebb41b5ff..131dfeade39 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-math-trunc.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-math-trunc.md
@@ -3,6 +3,9 @@
# unicorn/prefer-math-trunc
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -23,11 +26,15 @@ Using bitwise operations to truncate numbers is not clear and do not work in [so
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const foo = 1.1 | 0;
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const foo = Math.trunc(1.1);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-modern-dom-apis.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-modern-dom-apis.md
index dc92e4da8a2..d0ef1c3a65a 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-modern-dom-apis.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-modern-dom-apis.md
@@ -3,6 +3,9 @@
# unicorn/prefer-modern-dom-apis
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -24,11 +27,15 @@ There are some advantages of using the newer DOM APIs, like:
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
oldChildNode.replaceWith(newChildNode);
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
parentNode.replaceChild(newChildNode, oldChildNode);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-modern-math-apis.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-modern-math-apis.md
index 10f7b1b1ef7..845e175a4c9 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-modern-math-apis.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-modern-math-apis.md
@@ -23,12 +23,16 @@ Currently, the following cases are checked:
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
Math.log(x) * Math.LOG10E;
Math.sqrt(a * a + b * b);
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
Math.log10(x);
Math.hypot(a, b);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-native-coercion-functions.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-native-coercion-functions.md
index ceaa20c9800..fca7411e678 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-native-coercion-functions.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-native-coercion-functions.md
@@ -17,16 +17,20 @@ Prefers built in functions, over custom ones with the same functionality.
If a function is equivalent to [`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt), [`Boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean), or [`Symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), you should use the built-in one directly.
Wrapping the built-in in a function is moot.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
const foo = (v) => String(v);
foo(1);
const foo = (v) => Number(v);
array.some((v) => /* comment */ v);
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
String(1);
Number(1);
array.some(Boolean);
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.md
index 99dc4c9b943..0a86ba65cde 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.md
@@ -14,10 +14,15 @@ Prefer using the `node:protocol` when importing Node.js builtin modules
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
import fs from "fs";
-// Good
+```
+
+Examples of **correct** code for this rule:
+
+```javascript
import fs from "node:fs";
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.md
index 2c1df4a1c03..7500fe45e1d 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.md
@@ -3,6 +3,9 @@
# unicorn/prefer-number-properties
+
+🚧 An auto-fix is still under development.
+
### What it does
@@ -21,14 +24,18 @@ ECMAScript 2015 moved globals onto the `Number` constructor for consistency and
- [`Number.POSITIVE_INFINITY`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY) over [`Infinity`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity)
- [`Number.NEGATIVE_INFINITY`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY) over [`-Infinity`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity)
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
const foo = parseInt("10", 2);
const bar = parseFloat("10.5");
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
const foo = Number.parseInt("10", 2);
const bar = Number.parseFloat("10.5");
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-optional-catch-binding.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-optional-catch-binding.md
index 37ccb5692d7..6ce6d2fec58 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-optional-catch-binding.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-optional-catch-binding.md
@@ -18,13 +18,17 @@ It is unnecessary to bind the error to a variable if it is not used.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
try {
// ...
} catch (e) {}
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
try {
// ...
} catch {}
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-prototype-methods.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-prototype-methods.md
index 5205ba0af1b..3428936c1b3 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-prototype-methods.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-prototype-methods.md
@@ -16,15 +16,19 @@ This rule prefers borrowing methods from the prototype instead of the instance.
“Borrowing” a method from an instance of `Array` or `Object` is less clear than getting it from the corresponding prototype.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Fail
const array = [].slice.apply(bar);
const type = {}.toString.call(foo);
Reflect.apply([].forEach, arrayLike, [callback]);
+```
-// Pass
+Examples of **correct** code for this rule:
+
+```javascript
const array = Array.prototype.slice.apply(bar);
const type = Object.prototype.toString.call(foo);
Reflect.apply(Array.prototype.forEach, arrayLike, [callback]);
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-query-selector.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-query-selector.md
index 0c68488a72d..2431865ce61 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-query-selector.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-query-selector.md
@@ -14,14 +14,18 @@ Prefer `.querySelector()` over `.getElementById()`, `.querySelectorAll()` over `
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
document.getElementById("foo");
document.getElementsByClassName("foo bar");
document.getElementsByTagName("main");
document.getElementsByClassName(fn());
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
document.querySelector("#foo");
document.querySelector(".bar");
document.querySelector("main #foo .bar");
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-reflect-apply.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-reflect-apply.md
index 94e78a5d87f..81bc91cab1c 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-reflect-apply.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-reflect-apply.md
@@ -15,11 +15,15 @@ it's not safe to assume .apply() exists or is not overridden.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
foo.apply(null, [42]);
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
Reflect.apply(foo, null);
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-regexp-test.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-regexp-test.md
index 36147afdc9d..3d876c9d96e 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-regexp-test.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-regexp-test.md
@@ -18,14 +18,18 @@ When you want to know whether a pattern is found in a string, use [`RegExp#test(
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
if (string.match(/unicorn/)) {
}
if (/unicorn/.exec(string)) {
}
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
if (/unicorn/.test(string)) {
}
Boolean(string.match(/unicorn/));
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-set-size.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-set-size.md
index ceaf74c2410..ff7b83aa630 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-set-size.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-set-size.md
@@ -19,13 +19,17 @@ Prefer `Set#size` over `Set#length` when the `Set` is converted to an array.
Using `Set#size` is more readable and performant.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
const length = [...new Set([1, 2, 3])].length;
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
const size = new Set([1, 2, 3]).size;
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-spread.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-spread.md
index 51a53aaba8f..9818de0bc7e 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-spread.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-spread.md
@@ -16,14 +16,20 @@ Enforces the use of [the spread operator (`...`)](https://developer.mozilla.org/
Using the spread operator is more concise and readable.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// bad
const foo = Array.from(set);
const foo = Array.from(new Set([1, 2]));
+```
-// good
+Examples of **correct** code for this rule:
+
+```javascript
+[...set].map(() => {});
+Array.from(...argumentsArray);
```
## References
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.md
index 434c6b85a2e..b9a40a460ff 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.md
@@ -21,12 +21,16 @@ Using `String#startsWith()` and `String#endsWith()` is more readable and perform
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
const foo = "hello";
/^abc/.test(foo);
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
const foo = "hello";
foo.startsWith("abc");
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-string-trim-start-end.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-string-trim-start-end.md
index 48adc2447b9..cddebf0eddf 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-string-trim-start-end.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-string-trim-start-end.md
@@ -18,12 +18,16 @@ The `trimLeft` and `trimRight` names are confusing and inconsistent with the res
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
str.trimLeft();
str.trimRight();
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
str.trimStart();
str.trimEnd();
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-type-error.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-type-error.md
index fb20b460c0f..b6dbcee282c 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/prefer-type-error.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-type-error.md
@@ -18,13 +18,17 @@ Throwing a `TypeError` instead of a generic `Error` after a type checking if-sta
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
if (Array.isArray(foo)) {
throw new Error("Expected foo to be an array");
}
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
if (Array.isArray(foo)) {
throw new TypeError("Expected foo to be an array");
}
diff --git a/src/docs/guide/usage/linter/rules/unicorn/require-array-join-separator.md b/src/docs/guide/usage/linter/rules/unicorn/require-array-join-separator.md
index fbb71fdef76..6c19d22903d 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/require-array-join-separator.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/require-array-join-separator.md
@@ -19,11 +19,15 @@ instead of relying on the default comma (',') separator.
### Example
+Examples of **incorrect** code for this rule:
+
```javascript
-// Bad
foo.join();
+```
-// Good
+Examples of **correct** code for this rule:
+
+```javascript
foo.join(",");
```
diff --git a/src/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.md b/src/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.md
index 9bec65f4e8d..4b1f5404613 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.md
@@ -17,15 +17,19 @@ Enforce using the digits argument with Number.toFixed()
It's better to make it clear what the value of the digits argument is when calling Number.toFixed(),
instead of relying on the default value of 0.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
+
+```javascript
+number.toFixed();
+```
+
+Examples of **correct** code for this rule:
```javascript
-// Pass
number.toFixed(0);
number.toFixed(2);
-
-// Fail:
-number.toFixed();
```
## References
diff --git a/src/docs/guide/usage/linter/rules/unicorn/throw-new-error.md b/src/docs/guide/usage/linter/rules/unicorn/throw-new-error.md
index a85b5864b50..e2b6177d197 100644
--- a/src/docs/guide/usage/linter/rules/unicorn/throw-new-error.md
+++ b/src/docs/guide/usage/linter/rules/unicorn/throw-new-error.md
@@ -16,15 +16,19 @@ Require `new` when throwing an error.`
While it's possible to create a new error without using the `new` keyword, it's better to be explicit.
-### Example
+### Examples
+
+Examples of **incorrect** code for this rule:
```javascript
-// Fail
throw Error("🦄");
throw TypeError("unicorn");
throw lib.TypeError("unicorn");
+```
-// Pass
+Examples of **correct** code for this rule:
+
+```javascript
throw new Error("🦄");
throw new TypeError("unicorn");
throw new lib.TypeError("unicorn");
diff --git a/src/docs/guide/usage/linter/rules/vitest/no-conditional-tests.md b/src/docs/guide/usage/linter/rules/vitest/no-conditional-tests.md
index 8743d1a7e99..51c57dd1a27 100644
--- a/src/docs/guide/usage/linter/rules/vitest/no-conditional-tests.md
+++ b/src/docs/guide/usage/linter/rules/vitest/no-conditional-tests.md
@@ -7,7 +7,14 @@
### What it does
-The rule disallows the use of conditional statements within test cases to ensure that tests are deterministic and clearly readable.
+The rule disallows the use of conditional statements within test cases to
+ensure that tests are deterministic and clearly readable.
+
+### Why is this bad?
+
+Conditional statements in test cases can make tests unpredictable and
+harder to understand. Tests should be consistent and straightforward to
+ensure reliable results and maintainability.
### Examples
diff --git a/src/docs/guide/usage/linter/rules/vitest/no-import-node-test.md b/src/docs/guide/usage/linter/rules/vitest/no-import-node-test.md
index 61261f14823..8fe3503324f 100644
--- a/src/docs/guide/usage/linter/rules/vitest/no-import-node-test.md
+++ b/src/docs/guide/usage/linter/rules/vitest/no-import-node-test.md
@@ -10,12 +10,20 @@
### What it does
-This rule warns when `node:test` is imported (usually accidentally). With `--fix`, it will replace the import with `vitest`.
+This rule warns when `node:test` is imported (usually accidentally).
+With `--fix`, it will replace the import with `vitest`.
+
+### Why is this bad?
+
+Using `node:test` instead of `vitest` can lead to inconsistent test results
+and missing features. `vitest` should be used for all testing to ensure
+compatibility and access to its full functionality.
### Examples
+Examples of **incorrect** code for this rule:
+
```javascript
-// invalid
import { test } from "node:test";
import { expect } from "vitest";
@@ -24,8 +32,9 @@ test("foo", () => {
});
```
+Examples of **correct** code for this rule:
+
```javascript
-// valid
import { test, expect } from "vitest";
test("foo", () => {
diff --git a/src/docs/guide/usage/linter/rules/vitest/prefer-each.md b/src/docs/guide/usage/linter/rules/vitest/prefer-each.md
index 394c973e85a..d6203c5867a 100644
--- a/src/docs/guide/usage/linter/rules/vitest/prefer-each.md
+++ b/src/docs/guide/usage/linter/rules/vitest/prefer-each.md
@@ -9,6 +9,12 @@
This rule enforces using `each` rather than manual loops.
+### Why is this bad?
+
+Manual loops for tests can be less readable and more error-prone. Using
+`each` provides a clearer and more concise way to run parameterized tests,
+improving readability and maintainability.
+
### Examples
Examples of **incorrect** code for this rule:
diff --git a/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-falsy.md b/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-falsy.md
index 8277bd003d7..9e03e665055 100644
--- a/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-falsy.md
+++ b/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-falsy.md
@@ -10,16 +10,27 @@
### What it does
-This rule warns when `toBe(false)` is used with `expect` or `expectTypeOf`. With `--fix`, it will be replaced with `toBeFalsy()`.
+This rule warns when `toBe(false)` is used with `expect` or `expectTypeOf`.
+With `--fix`, it will be replaced with `toBeFalsy()`.
+
+### Why is this bad?
+
+Using `toBe(false)` is less expressive and may not account for other falsy
+values like `0`, `null`, or `undefined`. `toBeFalsy()` provides a more
+comprehensive check for any falsy value, improving the robustness of the tests.
### Examples
+Examples of **incorrect** code for this rule:
+
```javascript
-// bad
expect(foo).toBe(false);
expectTypeOf(foo).toBe(false);
+```
+
+Examples of **correct** code for this rule:
-// good
+```javascript
expect(foo).toBeFalsy();
expectTypeOf(foo).toBeFalsy();
```
diff --git a/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-object.md b/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-object.md
index 6f0d0d240e2..ecdabee11e3 100644
--- a/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-object.md
+++ b/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-object.md
@@ -14,7 +14,10 @@ This rule enforces using `toBeObject()` to check if a value is of type `Object`.
### Why is this bad?
-Using other methods such as `toBeInstanceOf(Object)` or `instanceof Object` can be less clear and potentially misleading. Enforcing the use of `toBeObject()` provides more explicit and readable code, making your intentions clear and improving the overall maintainability and readability of your tests.
+Using other methods such as `toBeInstanceOf(Object)` or `instanceof Object` can
+be less clear and potentially misleading. Enforcing the use of `toBeObject()`
+provides more explicit and readable code, making your intentions clear and
+improving the overall maintainability and readability of your tests.
### Examples
diff --git a/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-truthy.md b/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-truthy.md
index f6bf3fe0f02..e1ec2f677f0 100644
--- a/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-truthy.md
+++ b/src/docs/guide/usage/linter/rules/vitest/prefer-to-be-truthy.md
@@ -10,16 +10,27 @@
### What it does
-This rule warns when `toBe(true)` is used with `expect` or `expectTypeOf`. With `--fix`, it will be replaced with `toBeTruthy()`.
+This rule warns when `toBe(true)` is used with `expect` or `expectTypeOf`.
+With `--fix`, it will be replaced with `toBeTruthy()`.
+
+### Why is this bad?
+
+Using `toBe(true)` is less flexible and may not account for other truthy
+values like non-empty strings or objects. `toBeTruthy()` checks for any
+truthy value, which makes the tests more comprehensive and robust.
### Examples
+Examples of **incorrect** code for this rule:
+
```javascript
-// bad
expect(foo).toBe(true);
expectTypeOf(foo).toBe(true);
+```
+
+Examples of **correct** code for this rule:
-// good
+```javascript
expect(foo).toBeTruthy();
expectTypeOf(foo).toBeTruthy();
```
diff --git a/src/docs/guide/usage/linter/rules/vitest/require-local-test-context-for-concurrent-snapshots.md b/src/docs/guide/usage/linter/rules/vitest/require-local-test-context-for-concurrent-snapshots.md
index b43e3900700..4047550a733 100644
--- a/src/docs/guide/usage/linter/rules/vitest/require-local-test-context-for-concurrent-snapshots.md
+++ b/src/docs/guide/usage/linter/rules/vitest/require-local-test-context-for-concurrent-snapshots.md
@@ -3,17 +3,28 @@
# vitest/require-local-test-context-for-concurrent-snapshots
+
+🚧 An auto-fix is still under development.
+
### What it does
-The rule is intended to ensure that concurrent snapshot tests are executed within a properly configured local test context.
+The rule is intended to ensure that concurrent snapshot tests are executed
+within a properly configured local test context.
+
+### Why is this bad?
+
+Running snapshot tests concurrently without a proper context can lead to
+unreliable or inconsistent snapshots. Ensuring that concurrent tests are
+correctly configured with the appropriate context helps maintain accurate
+and stable snapshots, avoiding potential conflicts or failures.
### Examples
Examples of **incorrect** code for this rule:
-```js
+```javascript
test.concurrent("myLogic", () => {
expect(true).toMatchSnapshot();
});
@@ -27,7 +38,7 @@ describe.concurrent("something", () => {
Examples of **correct** code for this rule:
-```js
+```javascript
test.concurrent("myLogic", ({ expect }) => {
expect(true).toMatchSnapshot();
});