diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 00000000000..1242521f9a1 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,5 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "ignorePatterns": [], + "embeddedLanguageFormatting": "auto" +} diff --git a/.vitepress/theme/components/AppBlogPostHeader.vue b/.vitepress/theme/components/AppBlogPostHeader.vue index d3f494780e8..dc5a45bd26a 100644 --- a/.vitepress/theme/components/AppBlogPostHeader.vue +++ b/.vitepress/theme/components/AppBlogPostHeader.vue @@ -13,13 +13,14 @@ const authors = computed(() => if (member) { const { avatar, links, name, title } = member; - const { link = "" } = links?.find((link) => link.link.startsWith("https://github.com/")) ?? {}; + const { link = "" } = + links?.find((link) => link.link.startsWith("https://github.com/")) ?? {}; return [{ avatar, link, name, title }]; } return []; - }) + }), ); const date = computed(() => { const filePath = vitePressData.page.value.filePath; @@ -39,7 +40,9 @@ const datetime = ref(""); onMounted(() => { watchEffect(() => { if (date.value) { - datetime.value = new Intl.DateTimeFormat(lang.value, { dateStyle: "long" }).format(date.value); + datetime.value = new Intl.DateTimeFormat(lang.value, { dateStyle: "long" }).format( + date.value, + ); } }); }); @@ -52,7 +55,7 @@ onMounted(() => {
{{ name }}
diff --git a/src/blog/2024-10-18-oxlint-v0.10-release.md b/src/blog/2024-10-18-oxlint-v0.10-release.md
index 47106e1bf30..d8a7ecc1957 100644
--- a/src/blog/2024-10-18-oxlint-v0.10-release.md
+++ b/src/blog/2024-10-18-oxlint-v0.10-release.md
@@ -50,7 +50,8 @@ You can add a `categories` field to your `oxlint.json`:
```jsonc [oxlintrc.json]
{
- "categories": { // [!code ++]
+ "categories": {
+ // [!code ++]
"correctness": "deny", // [!code ++]
"suspicious": "warn", // [!code ++]
}, // [!code ++]
@@ -149,7 +150,8 @@ oxlint -c oxlint.json
```jsonc [oxlintrc.json]
{
- "categories": { // [!code ++]
+ "categories": {
+ // [!code ++]
"correctness": "allow", // [!code ++]
}, // [!code ++]
"rules": {
diff --git a/src/docs/guide/usage/linter/generated-config.md b/src/docs/guide/usage/linter/generated-config.md
index 7edb9098d25..61252cfb179 100644
--- a/src/docs/guide/usage/linter/generated-config.md
+++ b/src/docs/guide/usage/linter/generated-config.md
@@ -21,11 +21,7 @@ Example
```json
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
- "plugins": [
- "import",
- "typescript",
- "unicorn"
- ],
+ "plugins": ["import", "typescript", "unicorn"],
"env": {
"browser": true
},
@@ -45,10 +41,7 @@ Example
},
"overrides": [
{
- "files": [
- "*.test.ts",
- "*.spec.ts"
- ],
+ "files": ["*.test.ts", "*.spec.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
@@ -355,13 +348,13 @@ Example:
```json
{
-"settings": {
-"jsx-a11y": {
-"attributes": {
-"for": ["htmlFor", "for"]
-}
-}
-}
+ "settings": {
+ "jsx-a11y": {
+ "attributes": {
+ "for": ["htmlFor", "for"]
+ }
+ }
+ }
}
```
@@ -378,14 +371,14 @@ Example:
```json
{
-"settings": {
-"jsx-a11y": {
-"components": {
-"Link": "a",
-"IconButton": "button"
-}
-}
-}
+ "settings": {
+ "jsx-a11y": {
+ "components": {
+ "Link": "a",
+ "IconButton": "button"
+ }
+ }
+ }
}
```
@@ -440,17 +433,17 @@ Example:
```jsonc
{
-"settings": {
-"react": {
-"formComponents": [
-"CustomForm",
-// OtherForm is considered a form component and has an endpoint attribute
-{ "name": "OtherForm", "formAttribute": "endpoint" },
-// allows specifying multiple properties if necessary
-{ "name": "Form", "formAttribute": ["registerEndpoint", "loginEndpoint"] }
-]
-}
-}
+ "settings": {
+ "react": {
+ "formComponents": [
+ "CustomForm",
+ // OtherForm is considered a form component and has an endpoint attribute
+ { "name": "OtherForm", "formAttribute": "endpoint" },
+ // allows specifying multiple properties if necessary
+ { "name": "Form", "formAttribute": ["registerEndpoint", "loginEndpoint"] },
+ ],
+ },
+ },
}
```
@@ -478,18 +471,18 @@ Example:
```jsonc
{
-"settings": {
-"react": {
-"linkComponents": [
-"HyperLink",
-// Use `linkAttribute` for components that use a different prop name
-// than `href`.
-{ "name": "MyLink", "linkAttribute": "to" },
-// allows specifying multiple properties if necessary
-{ "name": "Link", "linkAttribute": ["to", "href"] }
-]
-}
-}
+ "settings": {
+ "react": {
+ "linkComponents": [
+ "HyperLink",
+ // Use `linkAttribute` for components that use a different prop name
+ // than `href`.
+ { "name": "MyLink", "linkAttribute": "to" },
+ // allows specifying multiple properties if necessary
+ { "name": "Link", "linkAttribute": ["to", "href"] },
+ ],
+ },
+ },
}
```
diff --git a/src/docs/guide/usage/linter/js-plugins.md b/src/docs/guide/usage/linter/js-plugins.md
index 421d21713ea..fa8d785bd1b 100644
--- a/src/docs/guide/usage/linter/js-plugins.md
+++ b/src/docs/guide/usage/linter/js-plugins.md
@@ -39,10 +39,7 @@ Paths are resolved relative to the config file itself.
```json
// .oxlintrc.json
{
- "jsPlugins": [
- "./path/to/my-plugin.js",
- "eslint-plugin-whatever"
- ],
+ "jsPlugins": ["./path/to/my-plugin.js", "eslint-plugin-whatever"],
"rules": {
"my-plugin/rule1": "error",
"my-plugin/rule2": "warn",
@@ -262,7 +259,9 @@ const rule = defineRule({
// This always runs for every file, even if
// it doesn't contain any `FunctionDeclaration`s
},
- FunctionDeclaration(node) {/* do stuff */},
+ FunctionDeclaration(node) {
+ /* do stuff */
+ },
};
},
});
diff --git a/src/docs/guide/usage/linter/rules/eslint/accessor-pairs.md b/src/docs/guide/usage/linter/rules/eslint/accessor-pairs.md
index 40f0f1b4d27..71edd120346 100644
--- a/src/docs/guide/usage/linter/rules/eslint/accessor-pairs.md
+++ b/src/docs/guide/usage/linter/rules/eslint/accessor-pairs.md
@@ -26,15 +26,15 @@ Examples of **incorrect** code for this rule:
```js
var o = {
- set a(value) {
- this.val = value;
- }
+ set a(value) {
+ this.val = value;
+ },
};
class C {
- set a(value) {
- this.val = value;
- }
+ set a(value) {
+ this.val = value;
+ }
}
```
@@ -42,21 +42,21 @@ Examples of **correct** code for this rule:
```js
var o = {
- set a(value) {
- this.val = value;
- },
- get a() {
- return this.val;
- }
+ set a(value) {
+ this.val = value;
+ },
+ get a() {
+ return this.val;
+ },
};
class C {
- set a(value) {
- this.val = value;
- }
- get a() {
- return this.val;
- }
+ set a(value) {
+ this.val = value;
+ }
+ get a() {
+ return this.val;
+ }
}
```
@@ -104,9 +104,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "accessor-pairs": "error"
- }
+ "rules": {
+ "accessor-pairs": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/array-callback-return.md b/src/docs/guide/usage/linter/rules/eslint/array-callback-return.md
index e39b285d431..a43ab91305c 100644
--- a/src/docs/guide/usage/linter/rules/eslint/array-callback-return.md
+++ b/src/docs/guide/usage/linter/rules/eslint/array-callback-return.md
@@ -28,7 +28,7 @@ Examples of **incorrect** code for this rule:
```javascript
let foo = [1, 2, 3, 4];
foo.map((a) => {
- console.log(a)
+ console.log(a);
});
```
@@ -37,8 +37,8 @@ Examples of **correct** code for this rule:
```javascript
let foo = [1, 2, 3, 4];
foo.map((a) => {
- console.log(a)
- return a
+ console.log(a);
+ return a;
});
```
@@ -71,9 +71,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "array-callback-return": "error"
- }
+ "rules": {
+ "array-callback-return": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md b/src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md
index 776fcd246c8..3458b9900ba 100644
--- a/src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md
+++ b/src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md
@@ -52,7 +52,7 @@ Example configuration:
```json
{
- "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
+ "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
}
```
@@ -67,7 +67,7 @@ Examples of **incorrect** code for this rule with the `never` option:
/* ✘ Bad: */
const foo = () => {
- return 0;
+ return 0;
};
```
@@ -99,7 +99,7 @@ Examples of **correct** code for this rule with the `always` option:
/* ✔ Good: */
const foo = () => {
- return 0;
+ return 0;
};
```
@@ -112,7 +112,7 @@ Examples of **incorrect** code for this rule with the `as-needed` option:
/* ✘ Bad: */
const foo = () => {
- return 0;
+ return 0;
};
```
@@ -125,12 +125,12 @@ Examples of **correct** code for this rule with the `as-needed` option:
const foo1 = () => 0;
const foo2 = (retv, name) => {
- retv[name] = true;
- return retv;
+ retv[name] = true;
+ return retv;
};
const foo3 = () => {
- bar();
+ bar();
};
```
@@ -153,7 +153,9 @@ Examples of **correct** code for this rule with the `{ "requireReturnForObjectLi
/* ✔ Good: */
const foo = () => {};
-const bar = () => { return { bar: 0 }; };
+const bar = () => {
+ return { bar: 0 };
+};
```
## How to use
@@ -164,9 +166,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "arrow-body-style": "error"
- }
+ "rules": {
+ "arrow-body-style": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/block-scoped-var.md b/src/docs/guide/usage/linter/rules/eslint/block-scoped-var.md
index e8b46511835..ef31a46083f 100644
--- a/src/docs/guide/usage/linter/rules/eslint/block-scoped-var.md
+++ b/src/docs/guide/usage/linter/rules/eslint/block-scoped-var.md
@@ -29,36 +29,35 @@ Examples of **incorrect** code for this rule:
/* block-scoped-var: "error" */
function doIf() {
- if (true) {
- var build = true;
- }
- console.log(build);
+ if (true) {
+ var build = true;
+ }
+ console.log(build);
}
function doLoop() {
- for (var i = 0; i < 10; i++) {
- // do something
- }
- console.log(i); // i is accessible here
+ for (var i = 0; i < 10; i++) {
+ // do something
+ }
+ console.log(i); // i is accessible here
}
function doSomething() {
- if (true) {
- var foo = 1;
- }
- if (false) {
- foo = 2;
- }
+ if (true) {
+ var foo = 1;
+ }
+ if (false) {
+ foo = 2;
+ }
}
function doTry() {
- try {
- var foo = 1;
- } catch (e) {
- console.log(foo);
- }
+ try {
+ var foo = 1;
+ } catch (e) {
+ console.log(foo);
+ }
}
-
```
Examples of **correct** code for this rule:
@@ -67,38 +66,38 @@ Examples of **correct** code for this rule:
/* block-scoped-var: "error" */
function doIf() {
- var build;
- if (true) {
- build = true;
- }
- console.log(build);
+ var build;
+ if (true) {
+ build = true;
+ }
+ console.log(build);
}
function doLoop() {
- var i;
- for (i = 0; i < 10; i++) {
- // do something
- }
- console.log(i);
+ var i;
+ for (i = 0; i < 10; i++) {
+ // do something
+ }
+ console.log(i);
}
function doSomething() {
- var foo;
- if (true) {
- foo = 1;
- }
- if (false) {
- foo = 2;
- }
+ var foo;
+ if (true) {
+ foo = 1;
+ }
+ if (false) {
+ foo = 2;
+ }
}
function doTry() {
- var foo;
- try {
- foo = 1;
- } catch (e) {
- console.log(foo);
- }
+ var foo;
+ try {
+ foo = 1;
+ } catch (e) {
+ console.log(foo);
+ }
}
```
@@ -110,9 +109,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "block-scoped-var": "error"
- }
+ "rules": {
+ "block-scoped-var": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/class-methods-use-this.md b/src/docs/guide/usage/linter/rules/eslint/class-methods-use-this.md
index f80b266c9e4..c0077526686 100644
--- a/src/docs/guide/usage/linter/rules/eslint/class-methods-use-this.md
+++ b/src/docs/guide/usage/linter/rules/eslint/class-methods-use-this.md
@@ -30,21 +30,21 @@ Examples of **correct** code for this rule:
```js
class A {
- foo() {
- this.bar = "Hello World"; // OK, this is used
- }
+ foo() {
+ this.bar = "Hello World"; // OK, this is used
+ }
}
class B {
- constructor() {
- // OK. constructor is exempt
- }
+ constructor() {
+ // OK. constructor is exempt
+ }
}
class C {
- static foo() {
- // OK. static methods aren't expected to use this.
- }
+ static foo() {
+ // OK. static methods aren't expected to use this.
+ }
}
```
@@ -104,9 +104,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "class-methods-use-this": "error"
- }
+ "rules": {
+ "class-methods-use-this": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/constructor-super.md b/src/docs/guide/usage/linter/rules/eslint/constructor-super.md
index 52d47a50a6d..3bc81a2a97c 100644
--- a/src/docs/guide/usage/linter/rules/eslint/constructor-super.md
+++ b/src/docs/guide/usage/linter/rules/eslint/constructor-super.md
@@ -59,25 +59,25 @@ Examples of **correct** code for this rule:
```js
// Proper super() call in derived class
class A extends B {
- constructor() {
- super();
- }
+ constructor() {
+ super();
+ }
}
// No super() in non-derived class
class A {
- constructor() { }
+ constructor() {}
}
// super() in all code paths
class C extends D {
- constructor() {
- if (condition) {
- super();
- } else {
- super();
- }
+ constructor() {
+ if (condition) {
+ super();
+ } else {
+ super();
}
+ }
}
```
@@ -89,9 +89,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "constructor-super": "error"
- }
+ "rules": {
+ "constructor-super": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/curly.md b/src/docs/guide/usage/linter/rules/eslint/curly.md
index 8b37466fcd2..6eef1cc99d9 100644
--- a/src/docs/guide/usage/linter/rules/eslint/curly.md
+++ b/src/docs/guide/usage/linter/rules/eslint/curly.md
@@ -51,7 +51,9 @@ if (foo) {
while (bar) {
bar--;
}
-do { foo(); } while (bar);
+do {
+ foo();
+} while (bar);
```
#### `"multi"`
@@ -62,7 +64,10 @@ Examples of **incorrect** code for this rule with the `"multi"` option:
/* curly: ["error", "multi"] */
if (foo) foo();
-else { bar(); baz(); }
+else {
+ bar();
+ baz();
+}
```
Examples of **correct** code for this rule with the `"multi"` option:
@@ -81,12 +86,10 @@ Examples of **incorrect** code for this rule with the `"multi-line"` option:
```js
/* curly: ["error", "multi-line"] */
-if (foo) foo()
-else
- bar();
+if (foo) foo();
+else bar();
-while (foo)
- foo()
+while (foo) foo();
```
Examples of **correct** code for this rule with the `"multi-line"` option:
@@ -100,8 +103,8 @@ else bar();
while (foo) foo();
while (true) {
- doSomething();
- doSomethingElse();
+ doSomething();
+ doSomethingElse();
}
```
@@ -112,11 +115,9 @@ Examples of **incorrect** code for this rule with the `"multi-or-nest"` option:
```js
/* curly: ["error", "multi-or-nest"] */
-if (foo)
- if (bar) bar();
+if (foo) if (bar) bar();
-while (foo)
- while (bar) bar();
+while (foo) while (bar) bar();
```
Examples of **correct** code for this rule with the `"multi-or-nest"` option:
@@ -182,8 +183,7 @@ Examples of **incorrect** code with `"multi-line"` and `consistent: true`:
if (foo) {
bar();
-} else
- baz();
+} else baz();
```
Examples of **correct** code with `"multi-line"` and `consistent: true`:
@@ -253,9 +253,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "curly": "error"
- }
+ "rules": {
+ "curly": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/default-case-last.md b/src/docs/guide/usage/linter/rules/eslint/default-case-last.md
index e609007c683..d6a36940160 100644
--- a/src/docs/guide/usage/linter/rules/eslint/default-case-last.md
+++ b/src/docs/guide/usage/linter/rules/eslint/default-case-last.md
@@ -85,9 +85,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "default-case-last": "error"
- }
+ "rules": {
+ "default-case-last": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/default-case.md b/src/docs/guide/usage/linter/rules/eslint/default-case.md
index 9474fc3fde1..94729db5912 100644
--- a/src/docs/guide/usage/linter/rules/eslint/default-case.md
+++ b/src/docs/guide/usage/linter/rules/eslint/default-case.md
@@ -28,7 +28,7 @@ Example configuration:
```json
{
- "default-case": ["error", { "commentPattern": "^skip\\sdefault" }]
+ "default-case": ["error", { "commentPattern": "^skip\\sdefault" }]
}
```
@@ -81,9 +81,9 @@ Examples of **incorrect** code for this rule with the `{ "commentPattern": "^ski
/* default-case: ["error", { "commentPattern": "^skip\sdefault" }] */
switch (a) {
-case 1:
-break;
-// no default
+ case 1:
+ break;
+ // no default
}
```
@@ -93,9 +93,9 @@ Examples of **correct** code for this rule with the `{ "commentPattern": "^skip\
/* default-case: ["error", { "commentPattern": "^skip\\sdefault" }] */
switch (a) {
-case 1:
-break;
-// skip default
+ case 1:
+ break;
+ // skip default
}
```
@@ -107,9 +107,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "default-case": "error"
- }
+ "rules": {
+ "default-case": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/default-param-last.md b/src/docs/guide/usage/linter/rules/eslint/default-param-last.md
index 28819342ae3..16953df13a7 100644
--- a/src/docs/guide/usage/linter/rules/eslint/default-param-last.md
+++ b/src/docs/guide/usage/linter/rules/eslint/default-param-last.md
@@ -30,7 +30,7 @@ Examples of **incorrect** code for this rule:
function f(a = 0, b) {}
function f(a, b = 0, c) {}
function createUser(isAdmin = false, id) {}
-createUser(undefined, "tabby")
+createUser(undefined, "tabby");
```
Examples of **correct** code for this rule:
@@ -41,7 +41,7 @@ Examples of **correct** code for this rule:
function f(a, b = 0) {}
function f(a = 0, b = 0) {}
function createUser(id, isAdmin = false) {}
-createUser("tabby")
+createUser("tabby");
```
Examples of **incorrect** TypeScript code for this rule:
@@ -73,9 +73,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "default-param-last": "error"
- }
+ "rules": {
+ "default-param-last": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/eqeqeq.md b/src/docs/guide/usage/linter/rules/eslint/eqeqeq.md
index b18275e3bbf..feaf1cbcd86 100644
--- a/src/docs/guide/usage/linter/rules/eslint/eqeqeq.md
+++ b/src/docs/guide/usage/linter/rules/eslint/eqeqeq.md
@@ -62,9 +62,12 @@ Examples of **incorrect** code for this rule:
```js
/* eslint eqeqeq: "error" */
-if (x == 42) {}
-if ("" == text) {}
-if (obj.getStuff() != undefined) {}
+if (x == 42) {
+}
+if ("" == text) {
+}
+if (obj.getStuff() != undefined) {
+}
```
Examples of **correct** code for this rule:
@@ -72,9 +75,12 @@ Examples of **correct** code for this rule:
```js
/* eslint eqeqeq: "error" */
-if (x === 42) {}
-if ("" === text) {}
-if (obj.getStuff() !== undefined) {}
+if (x === 42) {
+}
+if ("" === text) {
+}
+if (obj.getStuff() !== undefined) {
+}
```
#### `"smart"`
@@ -84,8 +90,10 @@ Examples of **incorrect** code for this rule with the `"smart"` option:
```js
/* eslint eqeqeq: ["error", "smart"] */
-if (x == 42) {}
-if ("" == text) {}
+if (x == 42) {
+}
+if ("" == text) {
+}
```
Examples of **correct** code for this rule with the `"smart"` option:
@@ -93,9 +101,12 @@ Examples of **correct** code for this rule with the `"smart"` option:
```js
/* eslint eqeqeq: ["error", "smart"] */
-if (typeof foo == "undefined") {}
-if (foo == null) {}
-if (foo != null) {}
+if (typeof foo == "undefined") {
+}
+if (foo == null) {
+}
+if (foo != null) {
+}
```
#### `{"null": "ignore"}` (with `"always"` first option)
@@ -104,16 +115,20 @@ Examples of **incorrect** code for this rule with the `{ "null": "ignore" }` opt
```js
/* eslint eqeqeq: ["error", "always", { "null": "ignore" }] */
-if (x == 42) {}
-if ("" == text) {}
+if (x == 42) {
+}
+if ("" == text) {
+}
```
Examples of **correct** code for this rule with the `{ "null": "ignore" }` option:
```js
/* eslint eqeqeq: ["error", "always", { "null": "ignore" }] */
-if (foo == null) {}
-if (foo != null) {}
+if (foo == null) {
+}
+if (foo != null) {
+}
```
#### `{"null": "always"}` (default - with `"always"` first option)
@@ -123,8 +138,10 @@ Examples of **incorrect** code for this rule with the `{ "null": "always" }` opt
```js
/* eslint eqeqeq: ["error", "always", { "null": "always" }] */
-if (foo == null) {}
-if (foo != null) {}
+if (foo == null) {
+}
+if (foo != null) {
+}
```
Examples of **correct** code for this rule with the `{ "null": "always" }` option:
@@ -132,8 +149,10 @@ Examples of **correct** code for this rule with the `{ "null": "always" }` optio
```js
/* eslint eqeqeq: ["error", "always", { "null": "always" }] */
-if (foo === null) {}
-if (foo !== null) {}
+if (foo === null) {
+}
+if (foo !== null) {
+}
```
#### `{"null": "never"}` (with `"always"` first option)
@@ -143,10 +162,14 @@ Examples of **incorrect** code for this rule with the `{ "null": "never" }` opti
```js
/* eslint eqeqeq: ["error", "always", { "null": "never" }] */
-if (x == 42) {}
-if ("" == text) {}
-if (foo === null) {}
-if (foo !== null) {}
+if (x == 42) {
+}
+if ("" == text) {
+}
+if (foo === null) {
+}
+if (foo !== null) {
+}
```
Examples of **correct** code for this rule with the `{ "null": "never" }` option:
@@ -154,10 +177,14 @@ Examples of **correct** code for this rule with the `{ "null": "never" }` option
```js
/* eslint eqeqeq: ["error", "always", { "null": "never" }] */
-if (x === 42) {}
-if ("" === text) {}
-if (foo == null) {}
-if (foo != null) {}
+if (x === 42) {
+}
+if ("" === text) {
+}
+if (foo == null) {
+}
+if (foo != null) {
+}
```
## Configuration
@@ -180,9 +207,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "eqeqeq": "error"
- }
+ "rules": {
+ "eqeqeq": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/for-direction.md b/src/docs/guide/usage/linter/rules/eslint/for-direction.md
index cd4cf0331f6..cc2a06e5660 100644
--- a/src/docs/guide/usage/linter/rules/eslint/for-direction.md
+++ b/src/docs/guide/usage/linter/rules/eslint/for-direction.md
@@ -34,21 +34,16 @@ Examples of **incorrect** code for this rule:
```js
/* for-direction: "error" */
-for (var i = 0; i < 10; i--) {
-}
+for (var i = 0; i < 10; i--) {}
-for (var i = 10; i >= 0; i++) {
-}
+for (var i = 10; i >= 0; i++) {}
-for (var i = 0; i > 10; i++) {
-}
+for (var i = 0; i > 10; i++) {}
-for (var i = 0; 10 > i; i--) {
-}
+for (var i = 0; 10 > i; i--) {}
const n = -2;
-for (let i = 0; i < 10; i += n) {
-}
+for (let i = 0; i < 10; i += n) {}
```
Examples of **correct** code for this rule:
@@ -56,16 +51,18 @@ Examples of **correct** code for this rule:
```js
/* for-direction: "error" */
-for (var i = 0; i < 10; i++) {
-}
+for (var i = 0; i < 10; i++) {}
-for (var i = 0; 10 > i; i++) { // with counter "i" on the right
+for (var i = 0; 10 > i; i++) {
+ // with counter "i" on the right
}
-for (let i = 10; i >= 0; i += this.step) { // direction unknown
+for (let i = 10; i >= 0; i += this.step) {
+ // direction unknown
}
-for (let i = MIN; i <= MAX; i -= 0) { // not increasing or decreasing
+for (let i = MIN; i <= MAX; i -= 0) {
+ // not increasing or decreasing
}
```
@@ -77,9 +74,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "for-direction": "error"
- }
+ "rules": {
+ "for-direction": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/func-names.md b/src/docs/guide/usage/linter/rules/eslint/func-names.md
index 92816961bf1..4f568e70e63 100644
--- a/src/docs/guide/usage/linter/rules/eslint/func-names.md
+++ b/src/docs/guide/usage/linter/rules/eslint/func-names.md
@@ -59,10 +59,12 @@ Examples of **incorrect** code for this rule:
```js
/* func-names: ["error", "always"] */
-Foo.prototype.bar = function() {};
-const cat = { meow: function() {} };
-(function() { /* ... */ }());
-export default function() {}
+Foo.prototype.bar = function () {};
+const cat = { meow: function () {} };
+(function () {
+ /* ... */
+})();
+export default function () {}
```
Examples of **correct** code for this rule:
@@ -72,7 +74,9 @@ Examples of **correct** code for this rule:
Foo.prototype.bar = function bar() {};
const cat = { meow() {} };
-(function bar() { /* ... */ }());
+(function bar() {
+ /* ... */
+})();
export default function foo() {}
```
@@ -83,9 +87,11 @@ Examples of **incorrect** code for this rule with the `"as-needed"` option:
```js
/* func-names: ["error", "as-needed"] */
-Foo.prototype.bar = function() {};
-(function() { /* ... */ }());
-export default function() {}
+Foo.prototype.bar = function () {};
+(function () {
+ /* ... */
+})();
+export default function () {}
```
Examples of **correct** code for this rule with the `"as-needed"` option:
@@ -93,11 +99,16 @@ Examples of **correct** code for this rule with the `"as-needed"` option:
```js
/* func-names: ["error", "as-needed"] */
-const bar = function() {};
-const cat = { meow: function() {} };
-class C { #bar = function() {}; baz = function() {}; }
-quux ??= function() {};
-(function bar() { /* ... */ }());
+const bar = function () {};
+const cat = { meow: function () {} };
+class C {
+ #bar = function () {};
+ baz = function () {};
+}
+quux ??= function () {};
+(function bar() {
+ /* ... */
+})();
export default function foo() {}
```
@@ -109,7 +120,9 @@ Examples of **incorrect** code for this rule with the `"never"` option:
/* func-names: ["error", "never"] */
Foo.prototype.bar = function bar() {};
-(function bar() { /* ... */ }());
+(function bar() {
+ /* ... */
+})();
```
Examples of **correct** code for this rule with the `"never"` option:
@@ -117,8 +130,10 @@ Examples of **correct** code for this rule with the `"never"` option:
```js
/* func-names: ["error", "never"] */
-Foo.prototype.bar = function() {};
-(function() { /* ... */ }());
+Foo.prototype.bar = function () {};
+(function () {
+ /* ... */
+})();
```
#### `generators`
@@ -128,7 +143,9 @@ Examples of **incorrect** code for this rule with the `"always", { "generators":
```js
/* func-names: ["error", "always", { "generators": "as-needed" }] */
-(function*() { /* ... */ }());
+(function* () {
+ /* ... */
+})();
```
Examples of **correct** code for this rule with the `"always", { "generators": "as-needed" }` options:
@@ -136,7 +153,7 @@ Examples of **correct** code for this rule with the `"always", { "generators": "
```js
/* func-names: ["error", "always", { "generators": "as-needed" }] */
-const foo = function*() {};
+const foo = function* () {};
```
Examples of **incorrect** code for this rule with the `"always", { "generators": "never" }` options:
@@ -144,7 +161,7 @@ Examples of **incorrect** code for this rule with the `"always", { "generators":
```js
/* func-names: ["error", "always", { "generators": "never" }] */
-const foo = bar(function *baz() {});
+const foo = bar(function* baz() {});
```
Examples of **correct** code for this rule with the `"always", { "generators": "never" }` options:
@@ -152,7 +169,7 @@ Examples of **correct** code for this rule with the `"always", { "generators": "
```js
/* func-names: ["error", "always", { "generators": "never" }] */
-const foo = bar(function *() {});
+const foo = bar(function* () {});
```
Examples of **incorrect** code for this rule with the `"as-needed", { "generators": "never" }` options:
@@ -160,7 +177,7 @@ Examples of **incorrect** code for this rule with the `"as-needed", { "generator
```js
/* func-names: ["error", "as-needed", { "generators": "never" }] */
-const foo = bar(function *baz() {});
+const foo = bar(function* baz() {});
```
Examples of **correct** code for this rule with the `"as-needed", { "generators": "never" }` options:
@@ -168,7 +185,7 @@ Examples of **correct** code for this rule with the `"as-needed", { "generators"
```js
/* func-names: ["error", "as-needed", { "generators": "never" }] */
-const foo = bar(function *() {});
+const foo = bar(function* () {});
```
Examples of **incorrect** code for this rule with the `"never", { "generators": "always" }` options:
@@ -176,7 +193,7 @@ Examples of **incorrect** code for this rule with the `"never", { "generators":
```js
/* func-names: ["error", "never", { "generators": "always" }] */
-const foo = bar(function *() {});
+const foo = bar(function* () {});
```
Examples of **correct** code for this rule with the `"never", { "generators": "always" }` options:
@@ -184,7 +201,7 @@ Examples of **correct** code for this rule with the `"never", { "generators": "a
```js
/* func-names: ["error", "never", { "generators": "always" }] */
-const foo = bar(function *baz() {});
+const foo = bar(function* baz() {});
```
## How to use
@@ -195,9 +212,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "func-names": "error"
- }
+ "rules": {
+ "func-names": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/func-style.md b/src/docs/guide/usage/linter/rules/eslint/func-style.md
index aeffe0077b5..ee200f82151 100644
--- a/src/docs/guide/usage/linter/rules/eslint/func-style.md
+++ b/src/docs/guide/usage/linter/rules/eslint/func-style.md
@@ -27,17 +27,17 @@ You can specify which you prefer in the configuration.
```js
// function declaration
function doSomething() {
- // ...
+ // ...
}
// arrow function expression assigned to a variable
const doSomethingElse = () => {
- // ...
+ // ...
};
// function expression assigned to a variable
-const doSomethingAgain = function() {
- // ...
+const doSomethingAgain = function () {
+ // ...
};
```
@@ -47,7 +47,7 @@ Examples of incorrect code for this rule with the default "expression" option:
/*eslint func-style: ["error", "expression"]*/
function foo() {
- // ...
+ // ...
}
```
@@ -55,8 +55,8 @@ Examples of incorrect code for this rule with the "declaration" option:
```js
/*eslint func-style: ["error", "declaration"]*/
-var foo = function() {
- // ...
+var foo = function () {
+ // ...
};
var foo = () => {};
@@ -67,7 +67,7 @@ Examples of incorrect code for this rule with the "declaration" and {"overrides"
```js
/*eslint func-style: ["error", "declaration", { "overrides": { "namedExports": "expression" } }]*/
export function foo() {
- // ...
+ // ...
}
```
@@ -75,8 +75,8 @@ Examples of incorrect code for this rule with the "expression" and {"overrides":
```js
/*eslint func-style: ["error", "expression", { "overrides": { "namedExports": "declaration" } }]*/
-export var foo = function() {
- // ...
+export var foo = function () {
+ // ...
};
export var bar = () => {};
@@ -86,8 +86,8 @@ Examples of correct code for this rule with the default "expression" option:
```js
/*eslint func-style: ["error", "expression"]*/
-var foo = function() {
- // ...
+var foo = function () {
+ // ...
};
```
@@ -96,11 +96,11 @@ Examples of correct code for this rule with the "declaration" option:
```js
/*eslint func-style: ["error", "declaration"]*/
function foo() {
- // ...
+ // ...
}
- // Methods (functions assigned to objects) are not checked by this rule
-SomeObject.foo = function() {
- // ...
+// Methods (functions assigned to objects) are not checked by this rule
+SomeObject.foo = function () {
+ // ...
};
```
@@ -115,8 +115,8 @@ Examples of correct code for this rule with the "declaration" and {"overrides":
```js
/*eslint func-style: ["error", "declaration", { "overrides": { "namedExports": "expression" } }]*/
-export var foo = function() {
- // ...
+export var foo = function () {
+ // ...
};
export var bar = () => {};
```
@@ -126,7 +126,7 @@ Examples of correct code for this rule with the "expression" and {"overrides": {
```js
/*eslint func-style: ["error", "expression", { "overrides": { "namedExports": "declaration" } }]*/
export function foo() {
- // ...
+ // ...
}
```
@@ -134,13 +134,13 @@ Examples of correct code for this rule with the {"overrides": { "namedExports":
```js
/*eslint func-style: ["error", "expression", { "overrides": { "namedExports": "ignore" } }]*/
-export var foo = function() {
- // ...
+export var foo = function () {
+ // ...
};
export var bar = () => {};
export function baz() {
- // ...
+ // ...
}
```
@@ -188,9 +188,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "func-style": "error"
- }
+ "rules": {
+ "func-style": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/getter-return.md b/src/docs/guide/usage/linter/rules/eslint/getter-return.md
index c7acd581350..d319d6022f9 100644
--- a/src/docs/guide/usage/linter/rules/eslint/getter-return.md
+++ b/src/docs/guide/usage/linter/rules/eslint/getter-return.md
@@ -27,25 +27,25 @@ Examples of **incorrect** code for this rule:
```javascript
class Person {
- get name() {
- // no return
- }
+ get name() {
+ // no return
+ }
}
const obj = {
- get foo() {
- // object getter are also checked
- }
-}
+ get foo() {
+ // object getter are also checked
+ },
+};
```
Examples of **correct** code for this rule:
```javascript
class Person {
- get name() {
- return this._name;
- }
+ get name() {
+ return this._name;
+ }
}
```
@@ -69,9 +69,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "getter-return": "error"
- }
+ "rules": {
+ "getter-return": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/grouped-accessor-pairs.md b/src/docs/guide/usage/linter/rules/eslint/grouped-accessor-pairs.md
index afe7593197e..5fd88a1bfde 100644
--- a/src/docs/guide/usage/linter/rules/eslint/grouped-accessor-pairs.md
+++ b/src/docs/guide/usage/linter/rules/eslint/grouped-accessor-pairs.md
@@ -28,13 +28,13 @@ Examples of **incorrect** code for this rule:
```js
const foo = {
- get a() {
- return this.val;
- },
- b: 1,
- set a(value) {
- this.val = value;
- }
+ get a() {
+ return this.val;
+ },
+ b: 1,
+ set a(value) {
+ this.val = value;
+ },
};
```
@@ -42,13 +42,13 @@ Examples of **correct** code for this rule:
```js
const foo = {
- get a() {
- return this.val;
- },
- set a(value) {
- this.val = value;
- },
- b: 1
+ get a() {
+ return this.val;
+ },
+ set a(value) {
+ this.val = value;
+ },
+ b: 1,
};
```
@@ -56,12 +56,12 @@ Examples of **incorrect** code for this rule with the `getBeforeSet` option:
```js
const foo = {
- set a(value) {
- this.val = value;
- },
- get a() {
- return this.val;
- }
+ set a(value) {
+ this.val = value;
+ },
+ get a() {
+ return this.val;
+ },
};
```
@@ -69,12 +69,12 @@ Examples of **correct** code for this rule with the `getBeforeSet` option:
```js
const foo = {
- get a() {
- return this.val;
- },
- set a(value) {
- this.val = value;
- }
+ get a() {
+ return this.val;
+ },
+ set a(value) {
+ this.val = value;
+ },
};
```
@@ -82,12 +82,12 @@ Examples of **incorrect** code for this rule with the `setBeforeGet` option:
```js
const foo = {
- get a() {
- return this.val;
- },
- set a(value) {
- this.val = value;
- }
+ get a() {
+ return this.val;
+ },
+ set a(value) {
+ this.val = value;
+ },
};
```
@@ -95,12 +95,12 @@ Examples of **correct** code for this rule with the `setBeforeGet` option:
```js
const foo = {
- set a(value) {
- this.val = value;
- },
- get a() {
- return this.val;
- }
+ set a(value) {
+ this.val = value;
+ },
+ get a() {
+ return this.val;
+ },
};
```
@@ -120,15 +120,15 @@ Examples of **incorrect** TypeScript code:
```ts
interface Foo {
-get a(): string;
-someProperty: string;
-set a(value: string);
+ get a(): string;
+ someProperty: string;
+ set a(value: string);
}
type Bar = {
-get b(): string;
-someProperty: string;
-set b(value: string);
+ get b(): string;
+ someProperty: string;
+ set b(value: string);
};
```
@@ -136,15 +136,15 @@ Examples of **correct** TypeScript code:
```ts
interface Foo {
-get a(): string;
-set a(value: string);
-someProperty: string;
+ get a(): string;
+ set a(value: string);
+ someProperty: string;
}
type Bar = {
-get b(): string;
-set b(value: string);
-someProperty: string;
+ get b(): string;
+ set b(value: string);
+ someProperty: string;
};
```
@@ -168,9 +168,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "grouped-accessor-pairs": "error"
- }
+ "rules": {
+ "grouped-accessor-pairs": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/guard-for-in.md b/src/docs/guide/usage/linter/rules/eslint/guard-for-in.md
index bf347cf0541..baecf63cb8a 100644
--- a/src/docs/guide/usage/linter/rules/eslint/guard-for-in.md
+++ b/src/docs/guide/usage/linter/rules/eslint/guard-for-in.md
@@ -50,9 +50,9 @@ for (key in foo) {
```javascript
for (key in foo) {
- if ({}.hasOwnProperty.call(foo, key)) {
- doSomething(key);
- }
+ if ({}.hasOwnProperty.call(foo, key)) {
+ doSomething(key);
+ }
}
```
@@ -64,9 +64,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "guard-for-in": "error"
- }
+ "rules": {
+ "guard-for-in": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/id-length.md b/src/docs/guide/usage/linter/rules/eslint/id-length.md
index 0ada5e06369..19315ec57e9 100644
--- a/src/docs/guide/usage/linter/rules/eslint/id-length.md
+++ b/src/docs/guide/usage/linter/rules/eslint/id-length.md
@@ -26,67 +26,97 @@ maintainable. To prevent this, one may enforce a minimum and/or maximum identifi
Examples of **incorrect** code for this rule:
```js
-/*eslint id-length: "error"*/ // default is minimum 2-chars ({ "min": 2 })
+/*eslint id-length: "error"*/ // default is minimum 2-chars ({ "min": 2 })
const x = 5;
obj.e = document.body;
-const foo = function (e) { };
+const foo = function (e) {};
try {
- dangerousStuff();
+ dangerousStuff();
} catch (e) {
- // ignore as many do
+ // ignore as many do
}
const myObj = { a: 1 };
-(a) => { a * a };
-class y { }
-class Foo { x() {} }
-class Bar { #x() {} }
-class Baz { x = 1 }
-class Qux { #x = 1 }
-function bar(...x) { }
-function baz([x]) { }
+(a) => {
+ a * a;
+};
+class y {}
+class Foo {
+ x() {}
+}
+class Bar {
+ #x() {}
+}
+class Baz {
+ x = 1;
+}
+class Qux {
+ #x = 1;
+}
+function bar(...x) {}
+function baz([x]) {}
const [z] = arr;
-const { prop: [i]} = {};
-function qux({x}) { }
+const {
+ prop: [i],
+} = {};
+function qux({ x }) {}
const { j } = {};
-const { prop: a} = {};
+const { prop: a } = {};
({ prop: obj.x } = {});
```
Examples of **correct** code for this rule:
```js
-/*eslint id-length: "error"*/ // default is minimum 2-chars ({ "min": 2 })
+/*eslint id-length: "error"*/ // default is minimum 2-chars ({ "min": 2 })
const num = 5;
-function _f() { return 42; }
-function _func() { return 42; }
+function _f() {
+ return 42;
+}
+function _func() {
+ return 42;
+}
obj.el = document.body;
-const foo = function (evt) { /* do stuff */ };
+const foo = function (evt) {
+ /* do stuff */
+};
try {
- dangerousStuff();
+ dangerousStuff();
} catch (error) {
- // ignore as many do
+ // ignore as many do
}
const myObj = { apple: 1 };
-(num) => { num * num };
-function bar(num = 0) { }
-class MyClass { }
-class Foo { method() {} }
-class Bar { #method() {} }
-class Baz { field = 1 }
-class Qux { #field = 1 }
-function baz(...args) { }
-function qux([longName]) { }
+(num) => {
+ num * num;
+};
+function bar(num = 0) {}
+class MyClass {}
+class Foo {
+ method() {}
+}
+class Bar {
+ #method() {}
+}
+class Baz {
+ field = 1;
+}
+class Qux {
+ #field = 1;
+}
+function baz(...args) {}
+function qux([longName]) {}
const { prop } = {};
-const { prop: [name] } = {};
+const {
+ prop: [name],
+} = {};
const [longName] = arr;
-function foobar({ prop }) { }
-function foobaz({ a: prop }) { }
+function foobar({ prop }) {}
+function foobaz({ a: prop }) {}
const { a: property } = {};
({ prop: obj.longName } = {});
-const data = { "x": 1 }; // excused because of quotes
-data["y"] = 3; // excused because of calculated property access
+const data = { x: 1 }; // excused because of quotes
+data["y"] = 3; // excused because of calculated property access
```
## Configuration
@@ -141,9 +171,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "id-length": "error"
- }
+ "rules": {
+ "id-length": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/init-declarations.md b/src/docs/guide/usage/linter/rules/eslint/init-declarations.md
index 8d5ccea4766..02fa128b60e 100644
--- a/src/docs/guide/usage/linter/rules/eslint/init-declarations.md
+++ b/src/docs/guide/usage/linter/rules/eslint/init-declarations.md
@@ -34,8 +34,8 @@ Examples of incorrect code for the default "always" option:
```js
/*eslint init-declarations: ["error", "always"]*/
function foo() {
- var bar;
- let baz;
+ var bar;
+ let baz;
}
```
@@ -44,9 +44,9 @@ Examples of incorrect code for the "never" option:
```js
/*eslint init-declarations: ["error", "never"]*/
function foo() {
- var bar = 1;
- let baz = 2;
- for (var i = 0; i < 1; i++) {}
+ var bar = 1;
+ let baz = 2;
+ for (var i = 0; i < 1; i++) {}
}
```
@@ -56,9 +56,9 @@ Examples of correct code for the default "always" option:
/*eslint init-declarations: ["error", "always"]*/
function foo() {
- var bar = 1;
- let baz = 2;
- const qux = 3;
+ var bar = 1;
+ let baz = 2;
+ const qux = 3;
}
```
@@ -68,9 +68,9 @@ Examples of correct code for the "never" option:
/*eslint init-declarations: ["error", "never"]*/
function foo() {
- var bar;
- let baz;
- const buzz = 1;
+ var bar;
+ let baz;
+ const buzz = 1;
}
```
@@ -109,9 +109,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "init-declarations": "error"
- }
+ "rules": {
+ "init-declarations": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/max-classes-per-file.md b/src/docs/guide/usage/linter/rules/eslint/max-classes-per-file.md
index da4af371a9e..4ea509b5ea7 100644
--- a/src/docs/guide/usage/linter/rules/eslint/max-classes-per-file.md
+++ b/src/docs/guide/usage/linter/rules/eslint/max-classes-per-file.md
@@ -32,9 +32,9 @@ Examples of **correct** code for this rule:
```js
function foo() {
- var bar = 1;
- let baz = 2;
- const qux = 3;
+ var bar = 1;
+ let baz = 2;
+ const qux = 3;
}
```
@@ -66,9 +66,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "max-classes-per-file": "error"
- }
+ "rules": {
+ "max-classes-per-file": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/max-depth.md b/src/docs/guide/usage/linter/rules/eslint/max-depth.md
index 43653244fbf..095312a5f61 100644
--- a/src/docs/guide/usage/linter/rules/eslint/max-depth.md
+++ b/src/docs/guide/usage/linter/rules/eslint/max-depth.md
@@ -107,9 +107,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "max-depth": "error"
- }
+ "rules": {
+ "max-depth": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md b/src/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md
index fa84ccc0e45..887361e8e40 100644
--- a/src/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md
+++ b/src/docs/guide/usage/linter/rules/eslint/max-lines-per-function.md
@@ -30,14 +30,14 @@ Examples of **incorrect** code for this rule with a particular max value:
```js
/* { "eslint/max-lines-per-function": ["error", 2] } */
function foo() {
- const x = 0;
+ const x = 0;
}
/* { "eslint/max-lines-per-function": ["error", 4] } */
function foo() {
- // a comment followed by a blank line
+ // a comment followed by a blank line
- const x = 0;
+ const x = 0;
}
```
@@ -46,14 +46,14 @@ Examples of **correct** code for this rule with a particular max value:
```js
/* { "eslint/max-lines-per-function": ["error", 3] } */
function foo() {
- const x = 0;
+ const x = 0;
}
/* { "eslint/max-lines-per-function": ["error", 5] } */
function foo() {
- // a comment followed by a blank line
+ // a comment followed by a blank line
- const x = 0;
+ const x = 0;
}
```
@@ -103,9 +103,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "max-lines-per-function": "error"
- }
+ "rules": {
+ "max-lines-per-function": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/max-lines.md b/src/docs/guide/usage/linter/rules/eslint/max-lines.md
index f92a1d36dd8..138b6e0f766 100644
--- a/src/docs/guide/usage/linter/rules/eslint/max-lines.md
+++ b/src/docs/guide/usage/linter/rules/eslint/max-lines.md
@@ -58,9 +58,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "max-lines": "error"
- }
+ "rules": {
+ "max-lines": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/max-nested-callbacks.md b/src/docs/guide/usage/linter/rules/eslint/max-nested-callbacks.md
index ac4c404173f..6c9ea636394 100644
--- a/src/docs/guide/usage/linter/rules/eslint/max-nested-callbacks.md
+++ b/src/docs/guide/usage/linter/rules/eslint/max-nested-callbacks.md
@@ -28,14 +28,14 @@ nesting callbacks excessively, making code harder to read and understand.
Examples of **incorrect** code for this rule with the `{ "max": 3 }` option:
```js
-foo1(function() {
- foo2(function() {
- foo3(function() {
- foo4(function() {
- // ...
- });
- });
+foo1(function () {
+ foo2(function () {
+ foo3(function () {
+ foo4(function () {
+ // ...
+ });
});
+ });
});
```
@@ -45,19 +45,19 @@ Examples of **correct** code for this rule with the `{ "max": 3 }` option:
foo1(handleFoo1);
function handleFoo1() {
- foo2(handleFoo2);
+ foo2(handleFoo2);
}
function handleFoo2() {
- foo3(handleFoo3);
+ foo3(handleFoo3);
}
function handleFoo3() {
- foo4(handleFoo4);
+ foo4(handleFoo4);
}
function handleFoo4() {
- foo5();
+ foo5();
}
```
@@ -81,9 +81,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "max-nested-callbacks": "error"
- }
+ "rules": {
+ "max-nested-callbacks": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/max-params.md b/src/docs/guide/usage/linter/rules/eslint/max-params.md
index 433cf4acf0f..a9af99b08cd 100644
--- a/src/docs/guide/usage/linter/rules/eslint/max-params.md
+++ b/src/docs/guide/usage/linter/rules/eslint/max-params.md
@@ -28,28 +28,28 @@ can take.
Examples of **incorrect** code for this rule:
```javascript
-function foo (bar, baz, qux, qxx) {
- doSomething();
+function foo(bar, baz, qux, qxx) {
+ doSomething();
}
```
```javascript
let foo = (bar, baz, qux, qxx) => {
- doSomething();
+ doSomething();
};
```
Examples of **correct** code for this rule:
```javascript
-function foo (bar, baz, qux) {
- doSomething();
+function foo(bar, baz, qux) {
+ doSomething();
}
```
```javascript
let foo = (bar, baz, qux) => {
- doSomething();
+ doSomething();
};
```
@@ -84,9 +84,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "max-params": "error"
- }
+ "rules": {
+ "max-params": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/new-cap.md b/src/docs/guide/usage/linter/rules/eslint/new-cap.md
index e7829aac0f7..3551b76129e 100644
--- a/src/docs/guide/usage/linter/rules/eslint/new-cap.md
+++ b/src/docs/guide/usage/linter/rules/eslint/new-cap.md
@@ -39,7 +39,7 @@ Examples of **incorrect** code for this rule:
```js
function foo(arg) {
- return Boolean(arg);
+ return Boolean(arg);
}
```
@@ -96,7 +96,7 @@ Examples of additional **correct** code for this rule with the `{ "newIsCapExcep
```js
/*eslint new-cap: ["error", { "newIsCapExceptions": ["events"] }]*/
-var events = require('events');
+var events = require("events");
var emitter = new events();
```
@@ -125,7 +125,7 @@ Examples of additional **correct** code for this rule with the `{ "capIsNewExcep
/*eslint new-cap: ["error", { "capIsNewExceptions": ["Person"] }]*/
function foo(arg) {
- return Person(arg);
+ return Person(arg);
}
```
@@ -237,7 +237,7 @@ Examples of additional **correct** code for this rule with the `{ "newIsCapExcep
```js
/*eslint new-cap: ["error", { "newIsCapExceptions": ["events"] }]*/
-var events = require('events');
+var events = require("events");
var emitter = new events();
```
@@ -268,7 +268,7 @@ Examples of additional **correct** code for this rule with the `{ "capIsNewExcep
/*eslint new-cap: ["error", { "capIsNewExceptions": ["Person"] }]*/
function foo(arg) {
- return Person(arg);
+ return Person(arg);
}
```
@@ -389,9 +389,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "new-cap": "error"
- }
+ "rules": {
+ "new-cap": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-alert.md b/src/docs/guide/usage/linter/rules/eslint/no-alert.md
index 381a0617a37..5c0143cf4af 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-alert.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-alert.md
@@ -41,8 +41,8 @@ customConfirm("Are you sure?");
customPrompt("Who are you?");
function foo() {
- var alert = myCustomLib.customAlert;
- alert();
+ var alert = myCustomLib.customAlert;
+ alert();
}
```
@@ -54,9 +54,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-alert": "error"
- }
+ "rules": {
+ "no-alert": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-array-constructor.md b/src/docs/guide/usage/linter/rules/eslint/no-array-constructor.md
index e426cce0e1c..34b97298760 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-array-constructor.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-array-constructor.md
@@ -50,9 +50,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-array-constructor": "error"
- }
+ "rules": {
+ "no-array-constructor": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-async-promise-executor.md b/src/docs/guide/usage/linter/rules/eslint/no-async-promise-executor.md
index a9aaf72fcbd..d89f1fc5d82 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-async-promise-executor.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-async-promise-executor.md
@@ -25,7 +25,7 @@ created Promise. For example:
```javascript
const result = new Promise(function executor(resolve, reject) {
- readFile('foo.txt', function(err, result) {
+ readFile("foo.txt", function (err, result) {
if (err) {
reject(err);
} else {
@@ -49,7 +49,7 @@ Examples of **incorrect** code for this rule:
```javascript
const foo = new Promise(async (resolve, reject) => {
- readFile('foo.txt', function(err, result) {
+ readFile("foo.txt", function (err, result) {
if (err) {
reject(err);
} else {
@@ -67,7 +67,7 @@ Examples of **correct** code for this rule:
```javascript
const foo = new Promise((resolve, reject) => {
- readFile('foo.txt', function(err, result) {
+ readFile("foo.txt", function (err, result) {
if (err) {
reject(err);
} else {
@@ -87,9 +87,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-async-promise-executor": "error"
- }
+ "rules": {
+ "no-async-promise-executor": "error"
+ }
}
```
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 5caef80136d..329c68f2137 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
@@ -25,9 +25,9 @@ Examples of **incorrect** code for this rule:
```javascript
async function bad() {
- for (const user of users) {
- const userRecord = await getUserRecord(user);
- }
+ for (const user of users) {
+ const userRecord = await getUserRecord(user);
+ }
}
```
@@ -35,7 +35,7 @@ Examples of **correct** code for this rule:
```javascript
async function good() {
- await Promise.all(users.map(user => getUserRecord(user)));
+ await Promise.all(users.map((user) => getUserRecord(user)));
}
```
@@ -47,9 +47,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-await-in-loop": "error"
- }
+ "rules": {
+ "no-await-in-loop": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-bitwise.md b/src/docs/guide/usage/linter/rules/eslint/no-bitwise.md
index b7252e2abfb..ed8125894dd 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-bitwise.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-bitwise.md
@@ -66,7 +66,7 @@ For example `{ "allow": ["~"] }` would allow the use of the bitwise operator
`~` without restriction. Such as in the following:
```javascript
-~[1,2,3].indexOf(1) === -1;
+~[1, 2, 3].indexOf(1) === -1;
```
### int32Hint
@@ -81,7 +81,7 @@ pattern for type casting.
For example with `{ "int32Hint": true }` the following is permitted:
```javascript
-const b = a|0;
+const b = a | 0;
```
## How to use
@@ -92,9 +92,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-bitwise": "error"
- }
+ "rules": {
+ "no-bitwise": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-caller.md b/src/docs/guide/usage/linter/rules/eslint/no-caller.md
index 704f353bcba..e99cfbace5f 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-caller.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-caller.md
@@ -26,7 +26,7 @@ mode.
```js
function foo() {
-var callee = arguments.callee;
+ var callee = arguments.callee;
}
```
@@ -40,15 +40,15 @@ Examples of **incorrect** code for this rule:
```js
function foo(n) {
- if (n <= 0) {
- return;
- }
+ if (n <= 0) {
+ return;
+ }
- arguments.callee(n - 1);
+ arguments.callee(n - 1);
}
-[1,2,3,4,5].map(function(n) {
- return !(n > 1) ? 1 : arguments.callee(n - 1) * n;
+[1, 2, 3, 4, 5].map(function (n) {
+ return !(n > 1) ? 1 : arguments.callee(n - 1) * n;
});
```
@@ -56,15 +56,15 @@ Examples of **correct** code for this rule:
```js
function foo(n) {
- if (n <= 0) {
- return;
- }
+ if (n <= 0) {
+ return;
+ }
- foo(n - 1);
+ foo(n - 1);
}
-[1,2,3,4,5].map(function factorial(n) {
- return !(n > 1) ? 1 : factorial(n - 1) * n;
+[1, 2, 3, 4, 5].map(function factorial(n) {
+ return !(n > 1) ? 1 : factorial(n - 1) * n;
});
```
@@ -76,9 +76,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-caller": "error"
- }
+ "rules": {
+ "no-caller": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-case-declarations.md b/src/docs/guide/usage/linter/rules/eslint/no-case-declarations.md
index 9ccfe192810..07301b6d48b 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-case-declarations.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-case-declarations.md
@@ -27,16 +27,16 @@ Examples of **incorrect** code for this rule:
```javascript
switch (foo) {
case 1:
- let x = 1;
- break;
+ let x = 1;
+ break;
case 2:
- const y = 2;
- break;
+ const y = 2;
+ break;
case 3:
- function f() {}
- break;
+ function f() {}
+ break;
default:
- class C {}
+ class C {}
}
```
@@ -45,19 +45,19 @@ Examples of **correct** code for this rule:
```javascript
switch (foo) {
case 1: {
- let x = 1;
- break;
+ let x = 1;
+ break;
}
case 2: {
- const y = 2;
- break;
+ const y = 2;
+ break;
}
case 3: {
- function f() {}
- break;
+ function f() {}
+ break;
}
default: {
- class C {}
+ class C {}
}
}
```
@@ -70,9 +70,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-case-declarations": "error"
- }
+ "rules": {
+ "no-case-declarations": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-class-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-class-assign.md
index 71cc7891bfb..e907b63f96d 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-class-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-class-assign.md
@@ -30,13 +30,13 @@ mistake in most cases.
Examples of **incorrect** code for this rule:
```javascript
-class A { }
+class A {}
A = 0;
```
```javascript
A = 0;
-class A { }
+class A {}
```
```javascript
@@ -53,13 +53,13 @@ let A = class A {
A = 0;
// `let A` is shadowed by the class name.
}
-}
+};
```
Examples of **correct** code for this rule:
```javascript
-let A = class A { }
+let A = class A {};
A = 0; // A is a variable.
```
@@ -68,7 +68,7 @@ let A = class {
b() {
A = 0; // A is a variable.
}
-}
+};
```
```javascript
@@ -87,9 +87,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-class-assign": "error"
- }
+ "rules": {
+ "no-class-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-compare-neg-zero.md b/src/docs/guide/usage/linter/rules/eslint/no-compare-neg-zero.md
index 28494ec8732..0f5bc1c42d6 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-compare-neg-zero.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-compare-neg-zero.md
@@ -32,13 +32,13 @@ Examples of **incorrect** code for this rule:
```javascript
if (x === -0) {
- // doSomething()...
+ // doSomething()...
}
```
```javascript
if (-0 > x) {
- // doSomething()...
+ // doSomething()...
}
```
@@ -46,19 +46,19 @@ Examples of **correct** code for this rule:
```javascript
if (x === 0) {
- // doSomething()...
+ // doSomething()...
}
```
```javascript
if (Object.is(x, -0)) {
- // doSomething()...
+ // doSomething()...
}
```
```javascript
if (0 > x) {
- // doSomething()...
+ // doSomething()...
}
```
@@ -70,9 +70,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-compare-neg-zero": "error"
- }
+ "rules": {
+ "no-compare-neg-zero": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-cond-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-cond-assign.md
index 0c7516c7f80..68f554d1c12 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-cond-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-cond-assign.md
@@ -32,8 +32,8 @@ Examples of **incorrect** code for this rule:
```js
// Check the user's job title
-if (user.jobTitle = "manager") {
- // user.jobTitle is now incorrect
+if ((user.jobTitle = "manager")) {
+ // user.jobTitle is now incorrect
}
```
@@ -42,7 +42,7 @@ Examples of **correct** code for this rule:
```js
// Check the user's job title
if (user.jobTitle === "manager") {
- // correctly compared `jobTitle`
+ // correctly compared `jobTitle`
}
```
@@ -67,9 +67,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-cond-assign": "error"
- }
+ "rules": {
+ "no-cond-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-console.md b/src/docs/guide/usage/linter/rules/eslint/no-console.md
index 9a726b65bd4..81128f4b33d 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-console.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-console.md
@@ -61,13 +61,13 @@ follows:
Example of **incorrect** code for this option:
```javascript
-console.log('foo');
+console.log("foo");
```
Example of **correct** code for this option:
```javascript
-console.info('foo');
+console.info("foo");
```
## How to use
@@ -78,9 +78,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-console": "error"
- }
+ "rules": {
+ "no-console": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-const-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-const-assign.md
index c4c12c1a1bb..2c207c89a79 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-const-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-const-assign.md
@@ -55,9 +55,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-const-assign": "error"
- }
+ "rules": {
+ "no-const-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-constant-binary-expression.md b/src/docs/guide/usage/linter/rules/eslint/no-constant-binary-expression.md
index 7b1e6a9ac7f..65bb2f3bf2b 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-constant-binary-expression.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-constant-binary-expression.md
@@ -61,9 +61,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-constant-binary-expression": "error"
- }
+ "rules": {
+ "no-constant-binary-expression": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-constant-condition.md b/src/docs/guide/usage/linter/rules/eslint/no-constant-condition.md
index 121482c8881..b55589ad7fb 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-constant-condition.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-constant-condition.md
@@ -39,13 +39,13 @@ if (false) {
if (new Boolean(x)) {
doSomethingAlways();
}
-if (x ||= true) {
+if ((x ||= true)) {
doSomethingAlways();
}
do {
doSomethingForever();
-} while (x = -1);
+} while ((x = -1));
```
Examples of **correct** code for this rule:
@@ -84,9 +84,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-constant-condition": "error"
- }
+ "rules": {
+ "no-constant-condition": "error"
+ }
}
```
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 c70049b8c13..89756003295 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
@@ -25,7 +25,9 @@ Examples of **incorrect** code for this rule:
```js
class C {
- constructor() { return 42; }
+ constructor() {
+ return 42;
+ }
}
```
@@ -33,7 +35,9 @@ Examples of **correct** code for this rule:
```js
class C {
- constructor() { this.value = 42; }
+ constructor() {
+ this.value = 42;
+ }
}
```
@@ -45,9 +49,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-constructor-return": "error"
- }
+ "rules": {
+ "no-constructor-return": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-continue.md b/src/docs/guide/usage/linter/rules/eslint/no-continue.md
index 98784cac126..9ddf8756d7e 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-continue.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-continue.md
@@ -24,22 +24,23 @@ Examples of **incorrect** code for this rule:
```javascript
var sum = 0,
- i;
+ i;
-for(i = 0; i < 10; i++) {
- if(i >= 5) {
- continue;
- }
+for (i = 0; i < 10; i++) {
+ if (i >= 5) {
+ continue;
+ }
- sum += i;
+ sum += i;
}
```
Examples of **correct** code for this rule:
```javascript
-var sum = 0, i;
-for(i = 0; i < 10; i++) {
+var sum = 0,
+ i;
+for (i = 0; i < 10; i++) {
if (i < 5) {
sum += i;
}
@@ -54,9 +55,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-continue": "error"
- }
+ "rules": {
+ "no-continue": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-control-regex.md b/src/docs/guide/usage/linter/rules/eslint/no-control-regex.md
index 464ea861386..c3d3d81db60 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-control-regex.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-control-regex.md
@@ -60,9 +60,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-control-regex": "error"
- }
+ "rules": {
+ "no-control-regex": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-debugger.md b/src/docs/guide/usage/linter/rules/eslint/no-debugger.md
index 0f035a3b85f..9f2f2962f03 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-debugger.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-debugger.md
@@ -54,9 +54,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-debugger": "error"
- }
+ "rules": {
+ "no-debugger": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-delete-var.md b/src/docs/guide/usage/linter/rules/eslint/no-delete-var.md
index 90597b74616..aff250fc3f3 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-delete-var.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-delete-var.md
@@ -49,9 +49,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-delete-var": "error"
- }
+ "rules": {
+ "no-delete-var": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-div-regex.md b/src/docs/guide/usage/linter/rules/eslint/no-div-regex.md
index a66991e1056..0f4cc68c6cb 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-div-regex.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-div-regex.md
@@ -27,13 +27,17 @@ division assignment operator.
Examples of **incorrect** code for this rule:
```javascript
-function bar() { return /=foo/; }
+function bar() {
+ return /=foo/;
+}
```
Examples of **correct** code for this rule:
```javascript
-function bar() { return /[=]foo/; }
+function bar() {
+ return /[=]foo/;
+}
```
## How to use
@@ -44,9 +48,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-div-regex": "error"
- }
+ "rules": {
+ "no-div-regex": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-dupe-class-members.md b/src/docs/guide/usage/linter/rules/eslint/no-dupe-class-members.md
index 40b9348ec54..698f4da8046 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-dupe-class-members.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-dupe-class-members.md
@@ -31,18 +31,22 @@ Examples of **incorrect** code for this rule:
```javascript
class A {
- foo() { console.log("foo") }
+ foo() {
+ console.log("foo");
+ }
foo = 123;
}
let a = new A();
-a.foo() // Uncaught TypeError: a.foo is not a function
+a.foo(); // Uncaught TypeError: a.foo is not a function
```
Examples of **correct** code for this rule:
```javascript
class A {
- foo() { console.log("foo") }
+ foo() {
+ console.log("foo");
+ }
}
let a = new A();
a.foo();
@@ -56,9 +60,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-dupe-class-members": "error"
- }
+ "rules": {
+ "no-dupe-class-members": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-dupe-else-if.md b/src/docs/guide/usage/linter/rules/eslint/no-dupe-else-if.md
index 10c450bcc2c..a036008d391 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-dupe-else-if.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-dupe-else-if.md
@@ -29,33 +29,33 @@ Examples of **incorrect** code for this rule:
```javascript
if (a) {
- foo();
+ foo();
} else if (b) {
- bar();
+ bar();
} else if (b) {
- baz();
+ baz();
}
```
```javascript
if (a || b) {
- foo();
+ foo();
} else if (a) {
- bar();
+ bar();
}
```
```javascript
if (n === 1) {
- foo();
+ foo();
} else if (n === 2) {
- bar();
+ bar();
} else if (n === 3) {
- baz();
+ baz();
} else if (n === 2) {
- quux();
+ quux();
} else if (n === 5) {
- quuux();
+ quuux();
}
```
@@ -63,33 +63,33 @@ Examples of **correct** code for this rule:
```javascript
if (a) {
- foo();
+ foo();
} else if (b) {
- bar();
+ bar();
} else if (c) {
- baz();
+ baz();
}
```
```javascript
if (a || b) {
- foo();
+ foo();
} else if (c) {
- bar();
+ bar();
}
```
```javascript
if (n === 1) {
- foo();
+ foo();
} else if (n === 2) {
- bar();
+ bar();
} else if (n === 3) {
- baz();
+ baz();
} else if (n === 4) {
- quux();
+ quux();
} else if (n === 5) {
- quuux();
+ quuux();
}
```
@@ -101,9 +101,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-dupe-else-if": "error"
- }
+ "rules": {
+ "no-dupe-else-if": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-dupe-keys.md b/src/docs/guide/usage/linter/rules/eslint/no-dupe-keys.md
index b23996cbc5b..9eb2d58e4ca 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-dupe-keys.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-dupe-keys.md
@@ -31,18 +31,18 @@ Examples of **incorrect** code for this rule:
```js
var foo = {
- bar: "baz",
- bar: "qux"
+ bar: "baz",
+ bar: "qux",
};
var foo = {
- "bar": "baz",
- bar: "qux"
+ bar: "baz",
+ bar: "qux",
};
var foo = {
- 0x1: "baz",
- 1: "qux"
+ 0x1: "baz",
+ 1: "qux",
};
```
@@ -50,8 +50,8 @@ Examples of **correct** code for this rule:
```js
var foo = {
- bar: "baz",
- qux: "qux"
+ bar: "baz",
+ qux: "qux",
};
```
@@ -63,9 +63,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-dupe-keys": "error"
- }
+ "rules": {
+ "no-dupe-keys": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-duplicate-case.md b/src/docs/guide/usage/linter/rules/eslint/no-duplicate-case.md
index d99cab251e5..9d5b25cfb52 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-duplicate-case.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-duplicate-case.md
@@ -27,27 +27,28 @@ it is likely that a programmer copied a case clause but forgot to change the tes
Examples of **incorrect** code for this rule:
```js
-var a = 1, one = 1;
+var a = 1,
+ one = 1;
switch (a) {
- case 1:
- break;
- case 2:
- break;
- case 1: // duplicate test expression
- break;
- default:
- break;
+ case 1:
+ break;
+ case 2:
+ break;
+ case 1: // duplicate test expression
+ break;
+ default:
+ break;
}
switch (a) {
- case one:
- break;
- case 2:
- break;
- case one: // duplicate test expression
- break;
- default:
- break;
+ case one:
+ break;
+ case 2:
+ break;
+ case one: // duplicate test expression
+ break;
+ default:
+ break;
}
```
@@ -55,23 +56,23 @@ Examples of **correct** code for this rule:
```js
var a = 1,
- one = 1
+ one = 1;
switch (a) {
- case 1:
- break
- case 2:
- break
- default:
- break
+ case 1:
+ break;
+ case 2:
+ break;
+ default:
+ break;
}
switch (a) {
- case '1':
- break
- case '2':
- break
- default:
- break
+ case "1":
+ break;
+ case "2":
+ break;
+ default:
+ break;
}
```
@@ -83,9 +84,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-duplicate-case": "error"
- }
+ "rules": {
+ "no-duplicate-case": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-duplicate-imports.md b/src/docs/guide/usage/linter/rules/eslint/no-duplicate-imports.md
index 24577335aa0..c28c8b12da9 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-duplicate-imports.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-duplicate-imports.md
@@ -30,16 +30,16 @@ In the following example the module import on line 1 is repeated on line 3. Thes
combined to make the list of imports more succinct.
```js
-import { merge } from 'module';
-import something from 'another-module';
-import { find } from 'module';
+import { merge } from "module";
+import something from "another-module";
+import { find } from "module";
```
Examples of **correct** code for this rule:
```js
-import { merge, find } from 'module';
-import something from 'another-module';
+import { merge, find } from "module";
+import something from "another-module";
```
## Configuration
@@ -82,9 +82,9 @@ importing from the same module.
Examples of **incorrect** code when `includeExports` is set to `true`:
```js
-import { merge } from 'module';
+import { merge } from "module";
-export { find } from 'module'; // re-export which is an import and an export.
+export { find } from "module"; // re-export which is an import and an export.
```
Examples of **correct** code when `includeExports` is set to `true`:
@@ -94,17 +94,17 @@ If re-exporting from an imported module, you should add the imports to the
```js
import { merge } from "lodash-es";
-export { merge as lodashMerge }
+export { merge as lodashMerge };
```
```js
-import { merge, find } from 'module';
+import { merge, find } from "module";
// cannot be merged with the above import
-export * as something from 'module';
+export * as something from "module";
// cannot be written differently
-export * from 'module';
+export * from "module";
```
## How to use
@@ -115,9 +115,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-duplicate-imports": "error"
- }
+ "rules": {
+ "no-duplicate-imports": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-else-return.md b/src/docs/guide/usage/linter/rules/eslint/no-else-return.md
index 9b8c5302be7..c5b63168a48 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-else-return.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-else-return.md
@@ -45,54 +45,54 @@ Examples of **incorrect** code for this rule:
```javascript
function foo1() {
- if (x) {
- return y;
- } else {
- return z;
- }
+ if (x) {
+ return y;
+ } else {
+ return z;
+ }
}
function foo2() {
- if (x) {
- return y;
- } else if (z) {
- return w;
- } else {
- return t;
- }
+ if (x) {
+ return y;
+ } else if (z) {
+ return w;
+ } else {
+ return t;
+ }
}
function foo3() {
- if (x) {
- return y;
- } else {
- var t = "foo";
- }
+ if (x) {
+ return y;
+ } else {
+ var t = "foo";
+ }
- return t;
+ return t;
}
function foo4() {
- if (error) {
- return 'It failed';
- } else {
- if (loading) {
- return "It's still loading";
- }
+ if (error) {
+ return "It failed";
+ } else {
+ if (loading) {
+ return "It's still loading";
}
+ }
}
// Two warnings for nested occurrences
function foo5() {
- if (x) {
- if (y) {
- return y;
- } else {
- return x;
- }
+ if (x) {
+ if (y) {
+ return y;
} else {
- return z;
+ return x;
}
+ } else {
+ return z;
+ }
}
```
@@ -100,39 +100,39 @@ Examples of **correct** code for this rule:
```javascript
function foo1() {
- if (x) {
- return y;
- }
+ if (x) {
+ return y;
+ }
- return z;
+ return z;
}
function foo2() {
- if (x) {
- return y;
- } else if (z) {
- var t = "foo";
- } else {
- return w;
- }
+ if (x) {
+ return y;
+ } else if (z) {
+ var t = "foo";
+ } else {
+ return w;
+ }
}
function foo3() {
- if (x) {
- if (z) {
- return y;
- }
- } else {
- return z;
+ if (x) {
+ if (z) {
+ return y;
}
+ } else {
+ return z;
+ }
}
function foo4() {
- if (error) {
- return 'It failed';
- } else if (loading) {
- return "It's still loading";
- }
+ if (error) {
+ return "It failed";
+ } else if (loading) {
+ return "It's still loading";
+ }
}
```
@@ -152,11 +152,11 @@ Examples of **incorrect** code for this rule with `allowElseIf: false`:
```javascript
function foo() {
-if (error) {
-return 'It failed';
-} else if (loading) {
-return "It's still loading";
-}
+ if (error) {
+ return "It failed";
+ } else if (loading) {
+ return "It's still loading";
+ }
}
```
@@ -164,13 +164,13 @@ Examples of **correct** code for this rule with `allowElseIf: false`:
```javascript
function foo() {
-if (error) {
-return 'It failed';
-}
+ if (error) {
+ return "It failed";
+ }
-if (loading) {
-return "It's still loading";
-}
+ if (loading) {
+ return "It's still loading";
+ }
}
```
@@ -182,9 +182,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-else-return": "error"
- }
+ "rules": {
+ "no-else-return": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-empty-character-class.md b/src/docs/guide/usage/linter/rules/eslint/no-empty-character-class.md
index ad1fd86bd74..da437f9c4ea 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-empty-character-class.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-empty-character-class.md
@@ -44,9 +44,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-empty-character-class": "error"
- }
+ "rules": {
+ "no-empty-character-class": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-empty-function.md b/src/docs/guide/usage/linter/rules/eslint/no-empty-function.md
index 0a03131cb7e..8f30641e3e0 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-empty-function.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-empty-function.md
@@ -32,10 +32,7 @@ Example:
```json
{
- "no-empty-function": [
- "error",
- { "allow": ["functions"] }
- ]
+ "no-empty-function": ["error", { "allow": ["functions"] }]
}
```
@@ -61,13 +58,12 @@ Example:
Examples of **incorrect** code for this rule:
```typescript
-function foo() {
-}
+function foo() {}
const bar = () => {};
class Foo {
- constructor()
+ constructor();
someMethod() {}
set bar(value) {}
}
@@ -77,13 +73,13 @@ Examples of **correct** code for this rule:
```typescript
function foo() {
- // do nothing
+ // do nothing
}
function foo() {
return;
}
-const add = (a, b) => a + b
+const add = (a, b) => a + b;
class Foo {
// constructor body is empty, but it declares a private property named
@@ -104,9 +100,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-empty-function": "error"
- }
+ "rules": {
+ "no-empty-function": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-empty-pattern.md b/src/docs/guide/usage/linter/rules/eslint/no-empty-pattern.md
index 4a25d1b9608..d99d0886c82 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-empty-pattern.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-empty-pattern.md
@@ -77,9 +77,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-empty-pattern": "error"
- }
+ "rules": {
+ "no-empty-pattern": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-empty-static-block.md b/src/docs/guide/usage/linter/rules/eslint/no-empty-static-block.md
index 8afe6cea3f2..abdc55ab474 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-empty-static-block.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-empty-static-block.md
@@ -32,8 +32,7 @@ Examples of **incorrect** code for this rule:
```js
class Foo {
- static {
- }
+ static {}
}
```
@@ -41,14 +40,14 @@ Examples of **correct** code for this rule:
```js
class Foo {
- static {
- // blocks with comments are allowed
- }
+ static {
+ // blocks with comments are allowed
+ }
}
class Bar {
- static {
- doSomething();
- }
+ static {
+ doSomething();
+ }
}
```
@@ -60,9 +59,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-empty-static-block": "error"
- }
+ "rules": {
+ "no-empty-static-block": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-empty.md b/src/docs/guide/usage/linter/rules/eslint/no-empty.md
index 495938f200e..9210643e417 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-empty.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-empty.md
@@ -28,7 +28,6 @@ Examples of **incorrect** code for this rule:
```javascript
if (condition) {
-
}
```
@@ -36,7 +35,7 @@ Examples of **correct** code for this rule:
```javascript
if (condition) {
- throw new Error("condition should be false")
+ throw new Error("condition should be false");
}
```
@@ -60,9 +59,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-empty": "error"
- }
+ "rules": {
+ "no-empty": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-eq-null.md b/src/docs/guide/usage/linter/rules/eslint/no-eq-null.md
index 1be76685ec6..df709ad133b 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-eq-null.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-eq-null.md
@@ -29,10 +29,10 @@ Examples of **incorrect** code for this rule:
```js
if (foo == null) {
- bar();
+ bar();
}
if (baz != null) {
- bar();
+ bar();
}
```
@@ -40,15 +40,15 @@ Examples of **correct** code for this rule:
```js
if (foo === null) {
- bar();
+ bar();
}
if (baz !== null) {
- bar();
+ bar();
}
if (bang === undefined) {
- bar();
+ bar();
}
```
@@ -60,9 +60,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-eq-null": "error"
- }
+ "rules": {
+ "no-eq-null": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-eval.md b/src/docs/guide/usage/linter/rules/eslint/no-eval.md
index b083198e333..92b9d951f15 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-eval.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-eval.md
@@ -56,13 +56,13 @@ class A {
this.eval("const a = 0");
}
- eval() { }
+ eval() {}
static {
this.eval("const a = 0");
}
- static eval() { }
+ static eval() {}
}
```
@@ -91,9 +91,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-eval": "error"
- }
+ "rules": {
+ "no-eval": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-ex-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-ex-assign.md
index 2342b88b9c3..d037dddac52 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-ex-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-ex-assign.md
@@ -31,9 +31,9 @@ Examples of **incorrect** code for this rule:
```javascript
try {
- // code
+ // code
} catch (e) {
- e = 10;
+ e = 10;
}
```
@@ -41,9 +41,9 @@ Examples of **correct** code for this rule:
```javascript
try {
- // code
+ // code
} catch (e) {
- let val = 10;
+ let val = 10;
}
```
@@ -55,9 +55,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-ex-assign": "error"
- }
+ "rules": {
+ "no-ex-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-extend-native.md b/src/docs/guide/usage/linter/rules/eslint/no-extend-native.md
index 9bdc87167bb..89d3b9704aa 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-extend-native.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-extend-native.md
@@ -27,13 +27,13 @@ Object.prototype.extra = 55;
// Defining a user object
const users = {
- "1": "user1",
- "2": "user2",
+ 1: "user1",
+ 2: "user2",
};
for (const id in users) {
- // This will print "extra" as well as "1" and "2":
- console.log(id);
+ // This will print "extra" as well as "1" and "2":
+ console.log(id);
}
```
@@ -42,15 +42,15 @@ for (const id in users) {
Examples of **incorrect** code for this rule:
```js
-Object.prototype.p = 0
-Object.defineProperty(Array.prototype, 'p', {value: 0})
+Object.prototype.p = 0;
+Object.defineProperty(Array.prototype, "p", { value: 0 });
```
Examples of **correct** code for this rule:
```js
-x.prototype.p = 0
-Object.defineProperty(x.prototype, 'p', {value: 0})
+x.prototype.p = 0;
+Object.defineProperty(x.prototype, "p", { value: 0 });
```
## Configuration
@@ -73,9 +73,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-extend-native": "error"
- }
+ "rules": {
+ "no-extend-native": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-extra-bind.md b/src/docs/guide/usage/linter/rules/eslint/no-extra-bind.md
index f12f56353bb..d3b0aefa9f7 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-extra-bind.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-extra-bind.md
@@ -30,11 +30,11 @@ Examples of **incorrect** code for this rule:
```js
const x = function () {
-foo();
+ foo();
}.bind(bar);
const z = (() => {
- this.foo();
+ this.foo();
}).bind(this);
```
@@ -42,10 +42,10 @@ Examples of **correct** code for this rule:
```js
const x = function () {
- this.foo();
+ this.foo();
}.bind(bar);
const y = function (a) {
- return a + 1;
+ return a + 1;
}.bind(foo, bar);
```
@@ -57,9 +57,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-extra-bind": "error"
- }
+ "rules": {
+ "no-extra-bind": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-extra-boolean-cast.md b/src/docs/guide/usage/linter/rules/eslint/no-extra-boolean-cast.md
index 0d76965a1c2..c771a541021 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-extra-boolean-cast.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-extra-boolean-cast.md
@@ -33,11 +33,14 @@ Examples of **incorrect** code for this rule:
var foo = !!!bar;
var foo = Boolean(!!bar);
-if (!!foo) {}
-if (Boolean(foo)) {}
+if (!!foo) {
+}
+if (Boolean(foo)) {
+}
// with "enforceForInnerExpressions" option enabled
-if (!!foo || bar) {}
+if (!!foo || bar) {
+}
```
Examples of **correct** code for this rule:
@@ -46,11 +49,14 @@ Examples of **correct** code for this rule:
var foo = !bar;
var foo = Boolean(bar);
-if (foo) {}
-if (foo) {}
+if (foo) {
+}
+if (foo) {
+}
// with "enforceForInnerExpressions" option enabled
-if (foo || bar) {}
+if (foo || bar) {
+}
```
## Configuration
@@ -77,9 +83,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-extra-boolean-cast": "error"
- }
+ "rules": {
+ "no-extra-boolean-cast": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-extra-label.md b/src/docs/guide/usage/linter/rules/eslint/no-extra-label.md
index 02c184efb9b..9fb868a497d 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-extra-label.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-extra-label.md
@@ -23,7 +23,7 @@ If a loop contains no nested loops or switches, labeling the loop is unnecessary
```js
A: while (a) {
- break A;
+ break A;
}
```
@@ -36,16 +36,16 @@ Examples of **incorrect** code for this rule:
```js
A: while (a) {
- break A;
+ break A;
}
B: for (let i = 0; i < 10; ++i) {
- break B;
+ break B;
}
C: switch (a) {
- case 0:
- break C;
+ case 0:
+ break C;
}
```
@@ -53,34 +53,34 @@ Examples of **correct** code for this rule:
```js
while (a) {
- break;
+ break;
}
for (let i = 0; i < 10; ++i) {
- break;
+ break;
}
switch (a) {
- case 0:
- break;
+ case 0:
+ break;
}
A: {
- break A;
+ break A;
}
B: while (a) {
- while (b) {
- break B;
- }
+ while (b) {
+ break B;
+ }
}
C: switch (a) {
- case 0:
- while (b) {
- break C;
- }
- break;
+ case 0:
+ while (b) {
+ break C;
+ }
+ break;
}
```
@@ -92,9 +92,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-extra-label": "error"
- }
+ "rules": {
+ "no-extra-label": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-fallthrough.md b/src/docs/guide/usage/linter/rules/eslint/no-fallthrough.md
index a7025cccc45..3cb0981d934 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-fallthrough.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-fallthrough.md
@@ -28,12 +28,12 @@ constructs of the language thanks in part to the ability to “fall
through” from one case to the next. For example:
```js
-switch(foo) {
+switch (foo) {
case 1:
- doSomething();
+ doSomething();
-case 2:
- doSomethingElse();
+ case 2:
+ doSomethingElse();
}
```
@@ -42,7 +42,7 @@ cases, as the first falls through to the second. You can prevent this by
using `break`, as in this example:
```js
-switch(foo) {
+switch (foo) {
case 1:
doSomething();
break;
@@ -59,34 +59,34 @@ fallthrough is intentional using a comment which matches the
`/falls?\s?through/i`` regular expression but isn’t a directive:
```js
-switch(foo) {
+switch (foo) {
case 1:
doSomething();
- // falls through
+ // falls through
case 2:
doSomethingElse();
}
-switch(foo) {
+switch (foo) {
case 1:
doSomething();
- // fall through
+ // fall through
case 2:
doSomethingElse();
}
-switch(foo) {
+switch (foo) {
case 1:
doSomething();
- // fallsthrough
+ // fallsthrough
case 2:
doSomethingElse();
}
-switch(foo) {
+switch (foo) {
case 1: {
doSomething();
// falls through
@@ -107,7 +107,7 @@ case.
Examples of **incorrect** code for this rule:
```js
-switch(foo) {
+switch (foo) {
case 1:
doSomething();
@@ -119,7 +119,7 @@ switch(foo) {
Examples of **correct** code for this rule:
```js
-switch(foo) {
+switch (foo) {
case 1:
doSomething();
break;
@@ -129,7 +129,7 @@ switch(foo) {
}
function bar(foo) {
- switch(foo) {
+ switch (foo) {
case 1:
doSomething();
return;
@@ -139,7 +139,7 @@ function bar(foo) {
}
}
-switch(foo) {
+switch (foo) {
case 1:
doSomething();
throw new Error("Boo!");
@@ -148,27 +148,28 @@ switch(foo) {
doSomething();
}
-switch(foo) {
+switch (foo) {
case 1:
case 2:
doSomething();
}
-switch(foo) {
- case 1: case 2:
+switch (foo) {
+ case 1:
+ case 2:
doSomething();
}
-switch(foo) {
+switch (foo) {
case 1:
doSomething();
- // falls through
+ // falls through
case 2:
doSomething();
}
-switch(foo) {
+switch (foo) {
case 1: {
doSomething();
// falls through
@@ -217,9 +218,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-fallthrough": "error"
- }
+ "rules": {
+ "no-fallthrough": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-func-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-func-assign.md
index 8e34914e1e4..2074557e810 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-func-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-func-assign.md
@@ -49,12 +49,13 @@ let a = function hello() {
Examples of **correct** code for this rule:
```javascript
-let foo = function () {}
+let foo = function () {};
foo = bar;
```
```javascript
-function baz(baz) { // `baz` is shadowed.
+function baz(baz) {
+ // `baz` is shadowed.
baz = bar;
}
```
@@ -73,9 +74,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-func-assign": "error"
- }
+ "rules": {
+ "no-func-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-global-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-global-assign.md
index 216f8382919..3058c7456b2 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-global-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-global-assign.md
@@ -26,7 +26,7 @@ In almost all cases, you don't want to assign a value to these global variables
Examples of **incorrect** code for this rule:
```javascript
-Object = null
+Object = null;
```
## Configuration
@@ -50,9 +50,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-global-assign": "error"
- }
+ "rules": {
+ "no-global-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-implicit-coercion.md b/src/docs/guide/usage/linter/rules/eslint/no-implicit-coercion.md
index c93395c6a50..9b80fe620dd 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-implicit-coercion.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-implicit-coercion.md
@@ -95,9 +95,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-implicit-coercion": "error"
- }
+ "rules": {
+ "no-implicit-coercion": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-import-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-import-assign.md
index 7e02348c27a..239a44aa9b3 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-import-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-import-assign.md
@@ -31,15 +31,15 @@ TypeScript code in those cases.
Examples of **incorrect** code for this rule:
```javascript
-import mod, { named } from "./mod.mjs"
-import * as mod_ns from "./mod.mjs"
+import mod, { named } from "./mod.mjs";
+import * as mod_ns from "./mod.mjs";
-mod = 1 // ERROR: 'mod' is readonly.
-named = 2 // ERROR: 'named' is readonly.
-mod_ns.named = 3 // ERROR: The members of 'mod_ns' are readonly.
-mod_ns = {} // ERROR: 'mod_ns' is readonly.
+mod = 1; // ERROR: 'mod' is readonly.
+named = 2; // ERROR: 'named' is readonly.
+mod_ns.named = 3; // ERROR: The members of 'mod_ns' are readonly.
+mod_ns = {}; // ERROR: 'mod_ns' is readonly.
// Can't extend 'mod_ns'
-Object.assign(mod_ns, { foo: "foo" }) // ERROR: The members of 'mod_ns' are readonly.
+Object.assign(mod_ns, { foo: "foo" }); // ERROR: The members of 'mod_ns' are readonly.
```
## How to use
@@ -50,9 +50,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-import-assign": "error"
- }
+ "rules": {
+ "no-import-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-inner-declarations.md b/src/docs/guide/usage/linter/rules/eslint/no-inner-declarations.md
index 7141d72ed6b..355585380ae 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-inner-declarations.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-inner-declarations.md
@@ -26,14 +26,14 @@ Examples of **incorrect** code for this rule:
```javascript
if (test) {
- function doSomethingElse () { }
+ function doSomethingElse() {}
}
```
Examples of **correct** code for this rule:
```javascript
-function doSomethingElse () { }
+function doSomethingElse() {}
if (test) {
// your code here
}
@@ -83,9 +83,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-inner-declarations": "error"
- }
+ "rules": {
+ "no-inner-declarations": "error"
+ }
}
```
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
index f16bc67231a..571b2837694 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md
@@ -27,17 +27,17 @@ but an invalid string in RegExp constructors throws a SyntaxError only when the
Examples of **incorrect** code for this rule:
```js
-RegExp('[')
-RegExp('.', 'z')
-new RegExp('\\')
+RegExp("[");
+RegExp(".", "z");
+new RegExp("\\");
```
Examples of **correct** code for this rule:
```js
-RegExp('.')
-new RegExp
-this.RegExp('[')
+RegExp(".");
+new RegExp();
+this.RegExp("[");
```
## Configuration
@@ -60,9 +60,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-invalid-regexp": "error"
- }
+ "rules": {
+ "no-invalid-regexp": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.md b/src/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.md
index 6034dfffdf3..8704d2adcbc 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.md
@@ -30,7 +30,7 @@ Examples of **incorrect** code for this rule:
```javascript
// Contains irregular whitespace characters (invisible)
function example() {
- var foo = 'bar'; // irregular whitespace before 'bar'
+ var foo = "bar"; // irregular whitespace before 'bar'
}
```
@@ -38,7 +38,7 @@ Examples of **correct** code for this rule:
```javascript
function example() {
- var foo = 'bar'; // regular spaces only
+ var foo = "bar"; // regular spaces only
}
```
@@ -50,9 +50,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-irregular-whitespace": "error"
- }
+ "rules": {
+ "no-irregular-whitespace": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-iterator.md b/src/docs/guide/usage/linter/rules/eslint/no-iterator.md
index 1ae4ed99f39..20a24375fbe 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-iterator.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-iterator.md
@@ -26,9 +26,9 @@ now obsolete, so it should not be used. Here’s an example of how this
used to work:
```js
-Foo.prototype.__iterator__ = function() {
- return new FooIterator(this);
-}
+Foo.prototype.__iterator__ = function () {
+ return new FooIterator(this);
+};
```
### Examples
@@ -36,8 +36,8 @@ Foo.prototype.__iterator__ = function() {
Examples of **incorrect** code for this rule:
```javascript
-Foo.prototype.__iterator__ = function() {
- return new FooIterator(this);
+Foo.prototype.__iterator__ = function () {
+ return new FooIterator(this);
};
foo.__iterator__ = function () {};
@@ -50,8 +50,8 @@ Examples of **correct** code for this rule:
```js
const __iterator__ = 42; // not using the __iterator__ property
-Foo.prototype[Symbol.iterator] = function() {
- return new FooIterator(this);
+Foo.prototype[Symbol.iterator] = function () {
+ return new FooIterator(this);
};
```
@@ -63,9 +63,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-iterator": "error"
- }
+ "rules": {
+ "no-iterator": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-label-var.md b/src/docs/guide/usage/linter/rules/eslint/no-label-var.md
index cc10b12661f..e38c3d0e317 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-label-var.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-label-var.md
@@ -26,8 +26,7 @@ Examples of **incorrect** code for this rule:
```js
var x = foo;
function bar() {
-x:
- for (;;) {
+ x: for (;;) {
break x;
}
}
@@ -39,14 +38,13 @@ Examples of **correct** code for this rule:
// The variable that has the same name as the label is not in scope.
function foo() {
- var q = t;
+ var q = t;
}
function bar() {
-q:
- for(;;) {
- break q;
- }
+ q: for (;;) {
+ break q;
+ }
}
```
@@ -58,9 +56,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-label-var": "error"
- }
+ "rules": {
+ "no-label-var": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-labels.md b/src/docs/guide/usage/linter/rules/eslint/no-labels.md
index 689177b6cde..8bd7a7100c7 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-labels.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-labels.md
@@ -19,12 +19,11 @@ Disallow labeled statements.
Labeled statements in JavaScript are used in conjunction with `break` and `continue` to control flow around multiple loops. For example:
```js
-outer:
- while (true) {
- while (true) {
- break outer;
- }
- }
+outer: while (true) {
+ while (true) {
+ break outer;
+ }
+}
```
The `break outer` statement ensures that this code will not result in an infinite loop because control is returned to the next statement after the `outer` label was applied. If this statement was changed to be just `break`, control would flow back to the outer `while` statement and an infinite loop would result.
@@ -35,51 +34,45 @@ While convenient in some cases, labels tend to be used only rarely and are frown
Examples of **incorrect** code for this rule:
```js
-label:
- while(true) {
- // ...
- }
-
-label:
- while(true) {
- break label;
- }
-
-label:
- while(true) {
- continue label;
- }
-
-label:
- switch (a) {
- case 0:
- break label;
- }
-
-label:
- {
- break label;
- }
-
-label:
- if (a) {
- break label;
- }
+label: while (true) {
+ // ...
+}
+
+label: while (true) {
+ break label;
+}
+
+label: while (true) {
+ continue label;
+}
+
+label: switch (a) {
+ case 0:
+ break label;
+}
+
+label: {
+ break label;
+}
+
+label: if (a) {
+ break label;
+}
```
Examples of **correct** code for this rule:
```js
var f = {
- label: "foo"
+ label: "foo",
};
while (true) {
- break;
+ break;
}
while (true) {
- continue;
+ continue;
}
```
@@ -97,9 +90,8 @@ If set to `true`, this rule ignores labels which are sticking to loop statements
Examples of **correct** code with this option set to `true`:
```js
-label:
-while (true) {
-break label;
+label: while (true) {
+ break label;
}
```
@@ -113,10 +105,9 @@ If set to `true`, this rule ignores labels which are sticking to switch statemen
Examples of **correct** code with this option set to `true`:
```js
-label:
-switch (a) {
-case 0:
-break label;
+label: switch (a) {
+ case 0:
+ break label;
}
```
@@ -128,9 +119,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-labels": "error"
- }
+ "rules": {
+ "no-labels": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-lone-blocks.md b/src/docs/guide/usage/linter/rules/eslint/no-lone-blocks.md
index f051dfade13..26857a38f5d 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-lone-blocks.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-lone-blocks.md
@@ -49,9 +49,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-lone-blocks": "error"
- }
+ "rules": {
+ "no-lone-blocks": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-lonely-if.md b/src/docs/guide/usage/linter/rules/eslint/no-lonely-if.md
index dde7e4179da..67981d0e4e0 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-lonely-if.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-lonely-if.md
@@ -43,7 +43,7 @@ if (condition) {
if (anotherCondition) {
// ...
} else {
- // ...
+ // ...
}
}
```
@@ -87,9 +87,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-lonely-if": "error"
- }
+ "rules": {
+ "no-lonely-if": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-loop-func.md b/src/docs/guide/usage/linter/rules/eslint/no-loop-func.md
index 7a7fbda3e9e..a755d4210a2 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-loop-func.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-loop-func.md
@@ -29,9 +29,9 @@ Examples of **incorrect** code for this rule:
```js
for (var i = 0; i < 10; i++) {
- funcs[i] = function() {
- return i;
- };
+ funcs[i] = function () {
+ return i;
+ };
}
```
@@ -39,9 +39,9 @@ Examples of **correct** code for this rule:
```js
for (let i = 0; i < 10; i++) {
- funcs[i] = function() {
- return i;
- };
+ funcs[i] = function () {
+ return i;
+ };
}
```
@@ -53,9 +53,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-loop-func": "error"
- }
+ "rules": {
+ "no-loop-func": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-loss-of-precision.md b/src/docs/guide/usage/linter/rules/eslint/no-loss-of-precision.md
index 00e6c771e2e..7201790d4ee 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-loss-of-precision.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-loss-of-precision.md
@@ -49,7 +49,7 @@ var x = 1230000000000000000000000.0;
```
```javascript
-var x = 0X200000_0000000_1;
+var x = 0x200000_0000000_1;
```
Examples of **correct** code for this rule:
@@ -63,7 +63,7 @@ var x = 123.456;
```
```javascript
-var x = 123.0000000000000000000000;
+var x = 123.0;
```
```javascript
@@ -71,7 +71,7 @@ var x = 123e34;
```
```javascript
-var x = 0x1FFF_FFFF_FFF_FFF;
+var x = 0x1fff_ffff_fff_fff;
```
## How to use
@@ -82,9 +82,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-loss-of-precision": "error"
- }
+ "rules": {
+ "no-loss-of-precision": "error"
+ }
}
```
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
index af0f0bfd3e2..046a9ca66a9 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md
@@ -28,14 +28,14 @@ Examples of **incorrect** code for this rule:
```javascript
var dutyFreePrice = 100;
-var finalPrice = dutyFreePrice + (dutyFreePrice * 0.25);
+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 data = ["foo", "bar", "baz"];
var dataLast = data.length && data[data.length - 1];
```
@@ -47,7 +47,7 @@ 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[0xab];
a = data[5.6e1];
a = data[4294967294]; // max array index
```
@@ -57,7 +57,9 @@ 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) { /***/ }
+function mapParallel(concurrency = 3) {
+ /***/
+}
```
Examples of **correct** code for this rule with option "ignoreClassFieldInitialValues":
@@ -65,10 +67,10 @@ Examples of **correct** code for this rule with option "ignoreClassFieldInitialV
```javascript
/*typescript no-magic-numbers: ["error", { "ignoreClassFieldInitialValues": true }]*/
class C {
- foo = 2;
- bar = -3;
- #baz = 4;
- static qux = 5;
+ foo = 2;
+ bar = -3;
+ #baz = 4;
+ static qux = 5;
}
```
@@ -84,7 +86,7 @@ Examples of **incorrect** code for this rule with option "detectObjects":
```javascript
/*typescript no-magic-numbers: ["error", { "detectObjects": true }]*/
var magic = {
- tax: 0.25
+ tax: 0.25,
};
```
@@ -95,7 +97,7 @@ Examples of **correct** code for this rule with option "detectObjects":
var TAX = 0.25;
var magic = {
- tax: TAX
+ tax: TAX,
};
```
@@ -104,7 +106,7 @@ Examples of **correct** code for this rule with option "ignoreEnums":
```typescript
/*typescript no-magic-numbers: ["error", { "ignoreEnums": true }]*/
enum foo {
- SECOND = 1000,
+ SECOND = 1000,
}
```
@@ -120,10 +122,10 @@ Examples of **correct** code for this rule with option "ignoreReadonlyClassPrope
```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;
+ readonly A = 1;
+ readonly B = 2;
+ public static readonly C = 1;
+ static readonly D = 1;
}
```
@@ -229,9 +231,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-magic-numbers": "error"
- }
+ "rules": {
+ "no-magic-numbers": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md b/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md
index e0af021b04e..9d9f3a68761 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md
@@ -95,9 +95,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-misleading-character-class": "error"
- }
+ "rules": {
+ "no-misleading-character-class": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-multi-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-multi-assign.md
index fcd75e842be..8161dbf3cc6 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-multi-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-multi-assign.md
@@ -19,11 +19,11 @@ Disallow use of chained assignment expressions.
Chaining the assignment of variables can lead to unexpected results and be difficult to read.
```js
-(function() {
- const foo = bar = 0; // Did you mean `foo = bar == 0`?
- bar = 1; // This will not fail since `bar` is not constant.
+(function () {
+ const foo = (bar = 0); // Did you mean `foo = bar == 0`?
+ bar = 1; // This will not fail since `bar` is not constant.
})();
-console.log(bar); // This will output 1 since `bar` is not scoped.
+console.log(bar); // This will output 1 since `bar` is not scoped.
```
### Examples
@@ -31,16 +31,14 @@ console.log(bar); // This will output 1 since `bar` is not scoped.
Examples of **incorrect** code for this rule:
```js
-var a = b = c = 5;
+var a = (b = c = 5);
-const foo = bar = "baz";
+const foo = (bar = "baz");
-let d =
- e =
- f;
+let d = (e = f);
class Foo {
- a = b = 10;
+ a = (b = 10);
}
a = b = "quux";
@@ -60,8 +58,8 @@ let d = c;
let e = c;
class Foo {
- a = 10;
- b = 10;
+ a = 10;
+ b = 10;
}
a = "quux";
@@ -95,12 +93,12 @@ x.one = y.one = 1;
Examples of **incorrect** code for this option set to `true`:
```js
-let a = b = "baz";
+let a = (b = "baz");
-const foo = bar = 1;
+const foo = (bar = 1);
class Foo {
-a = b = 10;
+ a = (b = 10);
}
```
@@ -112,9 +110,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-multi-assign": "error"
- }
+ "rules": {
+ "no-multi-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-multi-str.md b/src/docs/guide/usage/linter/rules/eslint/no-multi-str.md
index 5e1de598a71..016730f6649 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-multi-str.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-multi-str.md
@@ -24,7 +24,8 @@ that was only formalized later.
Examples of **incorrect** code for this rule:
```javascript
-var x = "Line 1 \
+var x =
+ "Line 1 \
Line 2";
```
@@ -36,9 +37,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-multi-str": "error"
- }
+ "rules": {
+ "no-multi-str": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-negated-condition.md b/src/docs/guide/usage/linter/rules/eslint/no-negated-condition.md
index 6571c3e7072..0668b90f85b 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-negated-condition.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-negated-condition.md
@@ -27,24 +27,24 @@ Examples of **incorrect** code for this rule:
```javascript
if (!a) {
- doSomethingC();
+ doSomethingC();
} else {
- doSomethingB();
+ doSomethingB();
}
-!a ? doSomethingC() : doSomethingB()
+!a ? doSomethingC() : doSomethingB();
```
Examples of **correct** code for this rule:
```javascript
if (a) {
- doSomethingB();
+ doSomethingB();
} else {
- doSomethingC();
+ doSomethingC();
}
-a ? doSomethingB() : doSomethingC()
+a ? doSomethingB() : doSomethingC();
```
## How to use
@@ -55,9 +55,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-negated-condition": "error"
- }
+ "rules": {
+ "no-negated-condition": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-nested-ternary.md b/src/docs/guide/usage/linter/rules/eslint/no-nested-ternary.md
index 4a73bbffc2f..bca352b0809 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-nested-ternary.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-nested-ternary.md
@@ -45,9 +45,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-nested-ternary": "error"
- }
+ "rules": {
+ "no-nested-ternary": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-new-func.md b/src/docs/guide/usage/linter/rules/eslint/no-new-func.md
index 08c024b4ae6..8117a918ea0 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-new-func.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-new-func.md
@@ -35,7 +35,7 @@ Examples of **correct** code for this rule:
```js
let x = function (a, b) {
- return a + b;
+ return a + b;
};
```
@@ -47,9 +47,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-new-func": "error"
- }
+ "rules": {
+ "no-new-func": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-new-native-nonconstructor.md b/src/docs/guide/usage/linter/rules/eslint/no-new-native-nonconstructor.md
index db3fecfeb46..c722c1de652 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-new-native-nonconstructor.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-new-native-nonconstructor.md
@@ -54,9 +54,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-new-native-nonconstructor": "error"
- }
+ "rules": {
+ "no-new-native-nonconstructor": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-new-wrappers.md b/src/docs/guide/usage/linter/rules/eslint/no-new-wrappers.md
index cd4b310494d..cac5116b130 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-new-wrappers.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-new-wrappers.md
@@ -32,20 +32,20 @@ https://eslint.org/docs/latest/rules/no-new-wrappers
Examples of **incorrect** code for this rule:
```js
-var stringObject = new String('Hello world');
+var stringObject = new String("Hello world");
var numberObject = new Number(33);
var booleanObject = new Boolean(false);
-var symbolObject = new Symbol('foo'); // symbol is not a constructor
+var symbolObject = new Symbol("foo"); // symbol is not a constructor
```
Examples of **correct** code for this rule:
```js
-var stringObject = 'Hello world';
+var stringObject = "Hello world";
var stringObject2 = String(value);
var numberObject = Number(value);
var booleanObject = Boolean(value);
-var symbolObject = Symbol('foo');
+var symbolObject = Symbol("foo");
```
## How to use
@@ -56,9 +56,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-new-wrappers": "error"
- }
+ "rules": {
+ "no-new-wrappers": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-new.md b/src/docs/guide/usage/linter/rules/eslint/no-new.md
index 359473a766a..8f3e9612db3 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-new.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-new.md
@@ -26,15 +26,15 @@ Examples of **incorrect** code for this rule:
```javascript
new Person();
-(() => { new Date() })
+() => {
+ new Date();
+};
```
Examples of **correct** code for this rule:
```javascript
-var a = new Date()
-
-(() => new Date())
+var a = new Date()(() => new Date());
```
## How to use
@@ -45,9 +45,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-new": "error"
- }
+ "rules": {
+ "no-new": "error"
+ }
}
```
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 2f05caaae2a..a29daf9cbc5 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
@@ -29,15 +29,15 @@ ECMAScript specification treats \8 and \9 in string literals as a legacy feature
Examples of **incorrect** code for this rule:
```javascript
-let x = "\8"
-let y = "\9"
+let x = "\8";
+let y = "\9";
```
Examples of **correct** code for this rule:
```javascript
-let x = "8"
-let y = "\\9"
+let x = "8";
+let y = "\\9";
```
## How to use
@@ -48,9 +48,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-nonoctal-decimal-escape": "error"
- }
+ "rules": {
+ "no-nonoctal-decimal-escape": "error"
+ }
}
```
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 3d7ff603469..1e6c417912a 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
@@ -49,7 +49,7 @@ let newReflect = new Reflect();
Examples of **correct** code for this rule:
```javascript
-let area = r => 2 * Math.PI * r * r;
+let area = (r) => 2 * Math.PI * r * r;
let object = JSON.parse("{}");
let first = Atomics.load(sharedArray, 0);
let segmenterFrom = Intl.Segmenter("fr", { granularity: "word" });
@@ -63,9 +63,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-obj-calls": "error"
- }
+ "rules": {
+ "no-obj-calls": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-object-constructor.md b/src/docs/guide/usage/linter/rules/eslint/no-object-constructor.md
index f7ad9cabad4..f867638d0ba 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-object-constructor.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-object-constructor.md
@@ -35,8 +35,8 @@ Examples of **correct** code for this rule:
```js
Object("foo");
const obj = { a: 1, b: 2 };
-const isObject = value => value === Object(value);
-const createObject = Object => new Object();
+const isObject = (value) => value === Object(value);
+const createObject = (Object) => new Object();
```
## How to use
@@ -47,9 +47,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-object-constructor": "error"
- }
+ "rules": {
+ "no-object-constructor": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md b/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md
index 19b4125b4da..4959b59eaff 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md
@@ -68,9 +68,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-param-reassign": "error"
- }
+ "rules": {
+ "no-param-reassign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md b/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md
index dd52ad0825a..a4e65013579 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md
@@ -26,8 +26,8 @@ can change the semantics of source code. For example, these two code blocks are
var i = 10;
var j = 20;
-i ++
-j
+i++;
+j;
// => i = 11, j = 20
```
@@ -35,9 +35,8 @@ j
var i = 10;
var j = 20;
-i
-++
-j
+i;
+++j;
// => i = 10, j = 21
```
@@ -46,20 +45,24 @@ j
Examples of **incorrect** code for this rule:
```js
-var x = 0; x++;
-var y = 0; y--;
+var x = 0;
+x++;
+var y = 0;
+y--;
for (let i = 0; i < l; i++) {
- doSomething(i);
+ doSomething(i);
}
```
Examples of **correct** code for this rule:
```js
-var x = 0; x += 1;
-var y = 0; y -= 1;
+var x = 0;
+x += 1;
+var y = 0;
+y -= 1;
for (let i = 0; i < l; i += 1) {
- doSomething(i);
+ doSomething(i);
}
```
@@ -83,9 +86,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-plusplus": "error"
- }
+ "rules": {
+ "no-plusplus": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.md b/src/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.md
index 87a8aa3e9d4..7f92d95121f 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-promise-executor-return.md
@@ -30,28 +30,30 @@ Examples of **incorrect** code for this rule:
```javascript
new Promise((resolve, reject) => {
- if (someCondition) {
- return defaultResult;
+ if (someCondition) {
+ return defaultResult;
+ }
+ getSomething((err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
}
- getSomething((err, result) => {
- if (err) {
- reject(err);
- } else {
- resolve(result);
- }
- });
+ });
});
-new Promise((resolve, reject) => getSomething((err, data) => {
+new Promise((resolve, reject) =>
+ getSomething((err, data) => {
if (err) {
- reject(err);
+ reject(err);
} else {
- resolve(data);
+ resolve(data);
}
-}));
+ }),
+);
new Promise(() => {
- return 1;
+ return 1;
});
```
@@ -59,30 +61,32 @@ Examples of **correct** code for this rule:
```javascript
new Promise((resolve, reject) => {
- if (someCondition) {
- resolve(defaultResult);
- return;
+ if (someCondition) {
+ resolve(defaultResult);
+ return;
+ }
+ getSomething((err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
}
- getSomething((err, result) => {
- if (err) {
- reject(err);
- } else {
- resolve(result);
- }
- });
+ });
});
new Promise((resolve, reject) => {
- getSomething((err, data) => {
- if (err) {
- reject(err);
- } else {
- resolve(data);
- }
- });
+ getSomething((err, data) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(data);
+ }
+ });
});
-new Promise(r => { r(1) });
+new Promise((r) => {
+ r(1);
+});
```
## Configuration
@@ -105,9 +109,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-promise-executor-return": "error"
- }
+ "rules": {
+ "no-promise-executor-return": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-proto.md b/src/docs/guide/usage/linter/rules/eslint/no-proto.md
index 2912d4055ea..12f9e9af32a 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-proto.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-proto.md
@@ -50,9 +50,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-proto": "error"
- }
+ "rules": {
+ "no-proto": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.md b/src/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.md
index d7ce86d1810..260ec9c1108 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-prototype-builtins.md
@@ -42,9 +42,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-prototype-builtins": "error"
- }
+ "rules": {
+ "no-prototype-builtins": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-redeclare.md b/src/docs/guide/usage/linter/rules/eslint/no-redeclare.md
index 53a8b79ff7f..5e015b8ef78 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-redeclare.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-redeclare.md
@@ -56,9 +56,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-redeclare": "error"
- }
+ "rules": {
+ "no-redeclare": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-regex-spaces.md b/src/docs/guide/usage/linter/rules/eslint/no-regex-spaces.md
index d1a09721f22..f15c0e33730 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-regex-spaces.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-regex-spaces.md
@@ -43,9 +43,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-regex-spaces": "error"
- }
+ "rules": {
+ "no-regex-spaces": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-restricted-globals.md b/src/docs/guide/usage/linter/rules/eslint/no-restricted-globals.md
index e0e4ee7e60f..75abadede80 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-restricted-globals.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-restricted-globals.md
@@ -35,7 +35,7 @@ The following patterns are considered problems:
```javascript
function onClick() {
- console.log(event); // Unexpected global variable 'event'. Use local parameter instead.
+ console.log(event); // Unexpected global variable 'event'. Use local parameter instead.
}
```
@@ -61,9 +61,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-restricted-globals": "error"
- }
+ "rules": {
+ "no-restricted-globals": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-restricted-imports.md b/src/docs/guide/usage/linter/rules/eslint/no-restricted-imports.md
index fa3262f1e4b..4663adb6004 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-restricted-imports.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-restricted-imports.md
@@ -31,8 +31,8 @@ Examples of **incorrect** code for this rule:
```js
/*eslint no-restricted-imports: ["error", "disallowed-import"]"*/
-import foo from 'disallowed-import';
-export * from 'disallowed-import';
+import foo from "disallowed-import";
+export * from "disallowed-import";
```
Examples of **correct** code for this rule:
@@ -40,7 +40,7 @@ Examples of **correct** code for this rule:
```js
/*eslint no-restricted-imports: ["error", "fs"]*/
-import crypto from 'crypto';
+import crypto from "crypto";
export * from "bar";
```
@@ -58,7 +58,7 @@ Examples of **incorrect** code for this rule:
"message": "Please use 'allowed-import' instead"
}]*/
-import foo from 'disallowed-import';
+import foo from "disallowed-import";
```
#### paths
@@ -74,7 +74,7 @@ Examples of **incorrect** code for `paths`:
```js
/*eslint no-restricted-imports: ["error", { "paths": ["cluster"] }]*/
-import cluster from 'cluster';
+import cluster from "cluster";
```
Custom messages for a particular module can also be specified in `paths` array using objects with `name` and `message`.
@@ -111,7 +111,7 @@ Examples of **incorrect** code for this rule:
}]}]*/
import DisallowedObject from "foo";
-import {Baz} from "far";
+import { Baz } from "far";
```
##### allowImportNames
@@ -145,8 +145,8 @@ Examples of **incorrect** code for this rule:
"allowTypeImports": true
}]}]*/
-import foo from 'import-foo';
-export { Foo } from 'import-foo';
+import foo from "import-foo";
+export { Foo } from "import-foo";
```
Examples of **correct** code for this rule:
@@ -157,8 +157,8 @@ Examples of **correct** code for this rule:
"allowTypeImports": true
}]}]*/
-import type foo from 'import-foo';
-export type { Foo } from 'import-foo';
+import type foo from "import-foo";
+export type { Foo } from "import-foo";
```
#### patterns
@@ -201,7 +201,7 @@ Examples of **incorrect** code for `patterns` option:
```js
/*eslint no-restricted-imports: ["error", { "patterns": ["lodash/*"] }]*/
-import pick from 'lodash/pick';
+import pick from "lodash/pick";
```
Examples of **correct** code for `patterns` option:
@@ -209,7 +209,7 @@ Examples of **correct** code for `patterns` option:
```js
/*eslint no-restricted-imports: ["error", { "patterns": ["crypto/*"] }]*/
-import crypto from 'crypto';
+import crypto from "crypto";
```
##### group
@@ -227,7 +227,7 @@ Examples of **incorrect** code for `group` option:
message: "Please use the default import from 'lodash' instead."
}]}]*/
-import pick from 'lodash/pick';
+import pick from "lodash/pick";
```
##### regex
@@ -246,10 +246,10 @@ Examples of **incorrect** code for `regex` option:
regex: "@app/(api|enums).*",
}]}]*/
-import Foo from '@app/api';
-import Bar from '@app/api/bar';
-import Baz from '@app/api/baz';
-import Bux from '@app/api/enums/foo';
+import Foo from "@app/api";
+import Bar from "@app/api/bar";
+import Baz from "@app/api/baz";
+import Bux from "@app/api/enums/foo";
```
##### caseSensitive
@@ -272,7 +272,7 @@ Examples of **incorrect** code for `importNames` in `patterns`:
message: "Use 'isEmpty' from lodash instead."
}]}]*/
-import { isEmpty } from 'utils/collection-utils';
+import { isEmpty } from "utils/collection-utils";
```
##### allowImportNames
@@ -295,7 +295,7 @@ Examples of **incorrect** code for `importNamePattern` option:
message: "Use 'is*' and 'has*' functions from baz/bar instead"
}]}]*/
-import { isSomething, hasSomething } from 'foo/bar';
+import { isSomething, hasSomething } from "foo/bar";
```
##### allowImportNamePattern
@@ -322,7 +322,7 @@ Examples of **incorrect** code for `allowImportNamePattern` option:
allowImportNamePattern: '^has'
}]}]*/
-import { isEmpty } from 'utils/collection-utils';
+import { isEmpty } from "utils/collection-utils";
```
Examples of **correct** code for `allowImportNamePattern` option:
@@ -333,7 +333,7 @@ Examples of **correct** code for `allowImportNamePattern` option:
allowImportNamePattern: '^is'
}]}]*/
-import { isEmpty } from 'utils/collection-utils';
+import { isEmpty } from "utils/collection-utils";
```
## How to use
@@ -344,9 +344,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-restricted-imports": "error"
- }
+ "rules": {
+ "no-restricted-imports": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-return-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-return-assign.md
index f01339a9f9f..458ea07e895 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-return-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-return-assign.md
@@ -28,15 +28,20 @@ Because of this ambiguity, it’s considered a best practice to not use assignme
Examples of **incorrect** code for this rule:
```js
-() => a = b;
-function x() { return a = b; }
+() => (a = b);
+function x() {
+ return (a = b);
+}
```
Examples of **correct** code for this rule:
```js
-() => (a = b)
-function x() { var result = a = b; return result; }
+() => (a = b);
+function x() {
+ var result = (a = b);
+ return result;
+}
```
## Configuration
@@ -60,9 +65,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-return-assign": "error"
- }
+ "rules": {
+ "no-return-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-script-url.md b/src/docs/guide/usage/linter/rules/eslint/no-script-url.md
index b05fc410b18..f0bdeccfb1d 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-script-url.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-script-url.md
@@ -41,9 +41,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-script-url": "error"
- }
+ "rules": {
+ "no-script-url": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-self-assign.md b/src/docs/guide/usage/linter/rules/eslint/no-self-assign.md
index d96af2be3e5..b7122cb84de 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-self-assign.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-self-assign.md
@@ -32,7 +32,7 @@ foo = foo;
[a, b] = [a, b];
[a, ...b] = [x, ...b];
-({a, b} = {a, x});
+({ a, b } = { a, x });
foo &&= foo;
foo ||= foo;
@@ -96,9 +96,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-self-assign": "error"
- }
+ "rules": {
+ "no-self-assign": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-self-compare.md b/src/docs/guide/usage/linter/rules/eslint/no-self-compare.md
index b88d8126ab7..9ec8be0a7eb 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-self-compare.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-self-compare.md
@@ -38,9 +38,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-self-compare": "error"
- }
+ "rules": {
+ "no-self-compare": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-sequences.md b/src/docs/guide/usage/linter/rules/eslint/no-sequences.md
index 64cbb8d1161..ca6f12a6022 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-sequences.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-sequences.md
@@ -30,9 +30,9 @@ obscures side effects, and its use is often an accident.
Examples of **incorrect** code for this rule:
```javascript
-foo = doSomething(), val;
+((foo = doSomething()), val);
-0, eval("doSomething();");
+(0, eval("doSomething();"));
// Arrow function body needs double parentheses
const fn = () => (doSomething(), val);
@@ -54,7 +54,7 @@ do {} while ((doSomething(), !!test));
for (i = 0, j = 10; i < j; i++, j--) {}
// Arrow function body needs double parentheses
-const fn = () => ((doSomething(), val));
+const fn = () => (doSomething(), val);
```
## Configuration
@@ -79,9 +79,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-sequences": "error"
- }
+ "rules": {
+ "no-sequences": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-setter-return.md b/src/docs/guide/usage/linter/rules/eslint/no-setter-return.md
index 544ded9c129..311f34013ba 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-setter-return.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-setter-return.md
@@ -46,9 +46,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-setter-return": "error"
- }
+ "rules": {
+ "no-setter-return": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-shadow-restricted-names.md b/src/docs/guide/usage/linter/rules/eslint/no-shadow-restricted-names.md
index ab8999e0d02..3aa59d0221e 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-shadow-restricted-names.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-shadow-restricted-names.md
@@ -38,13 +38,14 @@ local version with a very different meaning.
Examples of **incorrect** code for this rule:
```javascript
-function NaN(){}
+function NaN() {}
-!function(Infinity){};
+!function (Infinity) {};
var undefined = 5;
-try {} catch(eval){}
+try {
+} catch (eval) {}
```
```javascript
@@ -60,7 +61,7 @@ Examples of **correct** code for this rule:
```javascript
var Object;
-function f(a, b){}
+function f(a, b) {}
// Exception: `undefined` may be shadowed if the variable is never assigned a value.
var undefined;
@@ -90,9 +91,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-shadow-restricted-names": "error"
- }
+ "rules": {
+ "no-shadow-restricted-names": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-sparse-arrays.md b/src/docs/guide/usage/linter/rules/eslint/no-sparse-arrays.md
index 2aa4dd40c3a..56277db177c 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-sparse-arrays.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-sparse-arrays.md
@@ -22,7 +22,7 @@ Disallow sparse arrays.
Take the following example:
```javascript
-const items = [,,];
+const items = [, ,];
```
While the items array in this example has a length of 2, there are actually
@@ -40,11 +40,11 @@ code.
Examples of **incorrect** code for this rule:
```javascript
-var items = [,,];
+var items = [, ,];
```
```javascript
-var colors = [ "red",, "blue" ];
+var colors = ["red", , "blue"];
```
Examples of **correct** code for this rule:
@@ -56,7 +56,7 @@ var items = [];
// trailing comma (after the last element) is not a problem
```javascript
-var colors = [ "red", "blue", ];
+var colors = ["red", "blue"];
```
## How to use
@@ -67,9 +67,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-sparse-arrays": "error"
- }
+ "rules": {
+ "no-sparse-arrays": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-template-curly-in-string.md b/src/docs/guide/usage/linter/rules/eslint/no-template-curly-in-string.md
index c98bf740466..61605e23249 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-template-curly-in-string.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-template-curly-in-string.md
@@ -30,7 +30,7 @@ Examples of **incorrect** code for this rule:
```javascript
"Hello ${name}!";
-'Hello ${name}!';
+"Hello ${name}!";
"Time: ${12 * 60 * 60 * 1000}";
```
@@ -50,9 +50,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-template-curly-in-string": "error"
- }
+ "rules": {
+ "no-template-curly-in-string": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-ternary.md b/src/docs/guide/usage/linter/rules/eslint/no-ternary.md
index b3809bf321e..8d7726631f2 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-ternary.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-ternary.md
@@ -40,19 +40,19 @@ Examples of **correct** code for this rule:
let foo;
if (isBar) {
- foo = baz;
+ foo = baz;
} else {
- foo = qux;
+ foo = qux;
}
```
```javascript
function quux() {
- if (foo) {
- return bar();
- } else {
- return baz();
- }
+ if (foo) {
+ return bar();
+ } else {
+ return baz();
+ }
}
```
@@ -64,9 +64,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-ternary": "error"
- }
+ "rules": {
+ "no-ternary": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-this-before-super.md b/src/docs/guide/usage/linter/rules/eslint/no-this-before-super.md
index 47b740174c9..fd9e5ef5873 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-this-before-super.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-this-before-super.md
@@ -31,11 +31,11 @@ Examples of **incorrect** code for this rule:
```javascript
class A1 extends B {
- constructor() {
- // super() needs to be called first
- this.a = 0;
- super();
- }
+ constructor() {
+ // super() needs to be called first
+ this.a = 0;
+ super();
+ }
}
```
@@ -47,9 +47,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-this-before-super": "error"
- }
+ "rules": {
+ "no-this-before-super": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-throw-literal.md b/src/docs/guide/usage/linter/rules/eslint/no-throw-literal.md
index 1fefd3e06b8..174faf25a8f 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-throw-literal.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-throw-literal.md
@@ -41,7 +41,7 @@ throw "an " + err;
// err is recast to a string literal
var err = new Error();
-throw `${err}`
+throw `${err}`;
```
Examples of **correct** code for this rule:
@@ -55,9 +55,9 @@ var e = new Error("error");
throw e;
try {
- throw new Error("error");
+ throw new Error("error");
} catch (e) {
- throw e;
+ throw e;
}
```
@@ -69,9 +69,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-throw-literal": "error"
- }
+ "rules": {
+ "no-throw-literal": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unassigned-vars.md b/src/docs/guide/usage/linter/rules/eslint/no-unassigned-vars.md
index 4cf8d0d4a8f..9ce6bf482fc 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unassigned-vars.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unassigned-vars.md
@@ -28,8 +28,8 @@ Examples of **incorrect** code for this rule:
```js
let status;
-if (status === 'ready') {
- console.log('Ready!');
+if (status === "ready") {
+ console.log("Ready!");
}
```
@@ -52,9 +52,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unassigned-vars": "error"
- }
+ "rules": {
+ "no-unassigned-vars": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-undef.md b/src/docs/guide/usage/linter/rules/eslint/no-undef.md
index 5b741e50bb8..6855d2f9c0b 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-undef.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-undef.md
@@ -51,9 +51,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-undef": "error"
- }
+ "rules": {
+ "no-undef": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-undefined.md b/src/docs/guide/usage/linter/rules/eslint/no-undefined.md
index bf4ac24cd40..48fd3f9d24a 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-undefined.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-undefined.md
@@ -29,11 +29,11 @@ var foo = undefined;
var undefined = "foo";
if (foo === undefined) {
- // ...
+ // ...
}
function baz(undefined) {
- // ...
+ // ...
}
bar(undefined, "lorem");
@@ -47,7 +47,7 @@ var foo = void 0;
var Undefined = "foo";
if (typeof foo === "undefined") {
- // ...
+ // ...
}
global.undefined = "foo";
@@ -63,9 +63,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-undefined": "error"
- }
+ "rules": {
+ "no-undefined": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unexpected-multiline.md b/src/docs/guide/usage/linter/rules/eslint/no-unexpected-multiline.md
index 46b659c5706..f64f602a5c7 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unexpected-multiline.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unexpected-multiline.md
@@ -30,33 +30,29 @@ developer intended. This can lead to bugs that are difficult to track down.
Examples of **incorrect** code for this rule:
```js
-var a = b
-(x || y).doSomething()
+var a = b(x || y).doSomething();
-var a = b
-[a, b, c].forEach(doSomething)
+var a = b[(a, b, c)].forEach(doSomething);
-let x = function() {}
- `hello`
+let x = (function () {})`hello`;
- foo
- /bar/g.test(baz)
+foo / bar / g.test(baz);
```
Examples of **correct** code for this rule:
```js
var a = b;
-(x || y).doSomething()
+(x || y).doSomething();
var a = b;
-[a, b, c].forEach(doSomething)
+[a, b, c].forEach(doSomething);
-let x = function() {};
-`hello`
+let x = function () {};
+`hello`;
foo;
-/bar/g.test(baz)
+/bar/g.test(baz);
```
## How to use
@@ -67,9 +63,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unexpected-multiline": "error"
- }
+ "rules": {
+ "no-unexpected-multiline": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unneeded-ternary.md b/src/docs/guide/usage/linter/rules/eslint/no-unneeded-ternary.md
index 4af53950239..56fcc0c317f 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unneeded-ternary.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unneeded-ternary.md
@@ -69,9 +69,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unneeded-ternary": "error"
- }
+ "rules": {
+ "no-unneeded-ternary": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unreachable.md b/src/docs/guide/usage/linter/rules/eslint/no-unreachable.md
index 3477f71aad0..97c60563630 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unreachable.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unreachable.md
@@ -27,8 +27,8 @@ Examples of **incorrect** code for this rule:
```ts
function foo() {
- return 2;
- console.log("this will never be executed");
+ return 2;
+ console.log("this will never be executed");
}
```
@@ -36,8 +36,8 @@ Examples of **correct** code for this rule:
```ts
function foo() {
- console.log("this will be executed");
- return 2;
+ console.log("this will be executed");
+ return 2;
}
```
@@ -49,9 +49,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unreachable": "error"
- }
+ "rules": {
+ "no-unreachable": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-finally.md b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-finally.md
index ed1cd042be8..6c8f397631b 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-finally.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-finally.md
@@ -29,13 +29,13 @@ Examples of **incorrect** code for this rule:
```javascript
// We expect this function to return 1;
(() => {
- try {
- return 1; // 1 is returned but suspended until finally block ends
- } catch(err) {
- return 2;
- } finally {
- return 3; // 3 is returned before 1, which we did not expect
- }
+ try {
+ return 1; // 1 is returned but suspended until finally block ends
+ } catch (err) {
+ return 2;
+ } finally {
+ return 3; // 3 is returned before 1, which we did not expect
+ }
})();
// > 3
@@ -49,9 +49,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unsafe-finally": "error"
- }
+ "rules": {
+ "no-unsafe-finally": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.md b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.md
index dd5557a3099..8f5ad4744e9 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.md
@@ -35,17 +35,21 @@ as `(!a) in b` instead of `!(a in b)`, which is not the intended logic.
Examples of **incorrect** code for this rule:
```javascript
-if (!key in object) {}
+if ((!key) in object) {
+}
-if (!obj instanceof Ctor) {}
+if ((!obj) instanceof Ctor) {
+}
```
Examples of **correct** code for this rule:
```javascript
-if (!(key in object)) {}
+if (!(key in object)) {
+}
-if (!(obj instanceof Ctor)) {}
+if (!(obj instanceof Ctor)) {
+}
```
## Configuration
@@ -72,9 +76,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unsafe-negation": "error"
- }
+ "rules": {
+ "no-unsafe-negation": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.md b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.md
index b32c7301689..03a1216111b 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.md
@@ -29,11 +29,11 @@ Examples of **incorrect** code for this rule:
```javascript
var obj = undefined;
-1 in obj?.foo; // TypeError
-with (obj?.foo); // TypeError
-for (bar of obj?.foo); // TypeError
-bar instanceof obj?.foo; // TypeError
-const { bar } = obj?.foo; // TypeError
+1 in obj?.foo; // TypeError
+with (obj?.foo); // TypeError
+for (bar of obj?.foo); // TypeError
+bar instanceof obj?.foo; // TypeError
+const { bar } = obj?.foo; // TypeError
```
## Configuration
@@ -57,9 +57,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unsafe-optional-chaining": "error"
- }
+ "rules": {
+ "no-unsafe-optional-chaining": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unused-expressions.md b/src/docs/guide/usage/linter/rules/eslint/no-unused-expressions.md
index 3e6a89c3a29..993407b070a 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unused-expressions.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unused-expressions.md
@@ -81,9 +81,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unused-expressions": "error"
- }
+ "rules": {
+ "no-unused-expressions": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unused-labels.md b/src/docs/guide/usage/linter/rules/eslint/no-unused-labels.md
index b9771092579..40ea464dc95 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unused-labels.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unused-labels.md
@@ -29,12 +29,11 @@ Labels that are declared and not used anywhere in the code are most likely an er
Examples of **incorrect** code for this rule:
```javascript
-OUTER_LOOP:
-for (const student of students) {
- if (checkScores(student.scores)) {
- continue;
- }
- doSomething(student);
+OUTER_LOOP: for (const student of students) {
+ if (checkScores(student.scores)) {
+ continue;
+ }
+ doSomething(student);
}
```
@@ -42,10 +41,10 @@ Examples of **correct** code for this rule:
```javascript
for (const student of students) {
- if (checkScores(student.scores)) {
- continue;
- }
- doSomething(student);
+ if (checkScores(student.scores)) {
+ continue;
+ }
+ doSomething(student);
}
```
@@ -57,9 +56,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unused-labels": "error"
- }
+ "rules": {
+ "no-unused-labels": "error"
+ }
}
```
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 8d8c831108e..fe6992ca80d 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
@@ -27,60 +27,60 @@ Examples of **incorrect** code for this rule:
```javascript
class A {
- #unusedMember = 5;
- }
-
- class B {
- #usedOnlyInWrite = 5;
- method() {
- this.#usedOnlyInWrite = 42;
- }
- }
-
- class C {
- #usedOnlyToUpdateItself = 5;
- method() {
- this.#usedOnlyToUpdateItself++;
- }
- }
-
- class D {
- #unusedMethod() {}
- }
-
- class E {
- get #unusedAccessor() {}
- set #unusedAccessor(value) {}
- }
+ #unusedMember = 5;
+}
+
+class B {
+ #usedOnlyInWrite = 5;
+ method() {
+ this.#usedOnlyInWrite = 42;
+ }
+}
+
+class C {
+ #usedOnlyToUpdateItself = 5;
+ method() {
+ this.#usedOnlyToUpdateItself++;
+ }
+}
+
+class D {
+ #unusedMethod() {}
+}
+
+class E {
+ get #unusedAccessor() {}
+ set #unusedAccessor(value) {}
+}
```
Examples of **correct** code for this rule:
```javascript
class A {
- #usedMember = 42;
- method() {
- return this.#usedMember;
- }
- }
-
- class B {
- #usedMethod() {
- return 42;
- }
- anotherMethod() {
- return this.#usedMethod();
- }
- }
-
- class C {
- get #usedAccessor() {}
- set #usedAccessor(value) {}
-
- method() {
- this.#usedAccessor = 42;
- }
- }
+ #usedMember = 42;
+ method() {
+ return this.#usedMember;
+ }
+}
+
+class B {
+ #usedMethod() {
+ return 42;
+ }
+ anotherMethod() {
+ return this.#usedMethod();
+ }
+}
+
+class C {
+ get #usedAccessor() {}
+ set #usedAccessor(value) {}
+
+ method() {
+ this.#usedAccessor = 42;
+ }
+}
```
## How to use
@@ -91,9 +91,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
```json [Config (.oxlintrc.json)]
{
- "rules": {
- "no-unused-private-class-members": "error"
- }
+ "rules": {
+ "no-unused-private-class-members": "error"
+ }
}
```
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md b/src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md
index 01838669f01..244989350bd 100644
--- a/src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md
+++ b/src/docs/guide/usage/linter/rules/eslint/no-unused-vars.md
@@ -30,7 +30,7 @@ space in the code and can lead to confusion by readers.
```ts
// `b` is unused; this indicates a bug.
function add(a: number, b: number) {
- return a;
+ return a;
}
console.log(add(1, 2));
```
@@ -105,20 +105,20 @@ var z = 0;
z = z + 1;
// By default, unused arguments cause warnings.
-(function(foo) {
- return 5;
+(function (foo) {
+ return 5;
})();
// Unused recursive functions also cause warnings.
function fact(n) {
- if (n < 2) return 1;
- return n * fact(n - 1);
+ if (n < 2) return 1;
+ return n * fact(n - 1);
}
// When a function definition destructures an array, unused entries from
// the array also cause warnings.
function getY([x, y]) {
- return y;
+ return y;
}
```
@@ -126,9 +126,9 @@ function getY([x, y]) {
type A = Array;
enum Color {
- Red,
- Green,
- Blue
+ Red,
+ Green,
+ Blue,
}
```
@@ -141,23 +141,25 @@ var x = 10;
alert(x);
// foo is considered used here
-myFunc(function foo() {
+myFunc(
+ function foo() {
// ...
-}.bind(this));
+ }.bind(this),
+);
-(function(foo) {
- return foo;
+(function (foo) {
+ return foo;
})();
var myFunc;
-myFunc = setTimeout(function() {
- // myFunc is considered used
- myFunc();
+myFunc = setTimeout(function () {
+ // myFunc is considered used
+ myFunc();
}, 50);
// Only the second argument from the destructured array is used.
function getY([, y]) {
- return y;
+ return y;
}
```
@@ -168,7 +170,7 @@ export { y };
type A = Record