Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": [],
"embeddedLanguageFormatting": "auto"
}
11 changes: 7 additions & 4 deletions .vitepress/theme/components/AppBlogPostHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
);
}
});
});
Expand All @@ -52,7 +55,7 @@ onMounted(() => {
<time :datetime="isoDatetime">{{ datetime }}</time>
</p>
<ul class="authors">
<li v-for="({ avatar, link, name, title }) in authors" :key="name" class="author">
<li v-for="{ avatar, link, name, title } in authors" :key="name" class="author">
<img :src="avatar" :alt="name" class="author-avatar" />
<p class="author-text">
<a v-if="link" :href="link" target="_blank" class="author-name">{{ name }}</a>
Expand Down
6 changes: 4 additions & 2 deletions src/blog/2024-10-18-oxlint-v0.10-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ++]
Expand Down Expand Up @@ -149,7 +150,8 @@ oxlint -c oxlint.json

```jsonc [oxlintrc.json]
{
"categories": { // [!code ++]
"categories": {
// [!code ++]
"correctness": "allow", // [!code ++]
}, // [!code ++]
"rules": {
Expand Down
87 changes: 40 additions & 47 deletions src/docs/guide/usage/linter/generated-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ Example
```json
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": [
"import",
"typescript",
"unicorn"
],
"plugins": ["import", "typescript", "unicorn"],
"env": {
"browser": true
},
Expand All @@ -45,10 +41,7 @@ Example
},
"overrides": [
{
"files": [
"*.test.ts",
"*.spec.ts"
],
"files": ["*.test.ts", "*.spec.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
Expand Down Expand Up @@ -355,13 +348,13 @@ Example:

```json
{
"settings": {
"jsx-a11y": {
"attributes": {
"for": ["htmlFor", "for"]
}
}
}
"settings": {
"jsx-a11y": {
"attributes": {
"for": ["htmlFor", "for"]
}
}
}
}
```

Expand All @@ -378,14 +371,14 @@ Example:

```json
{
"settings": {
"jsx-a11y": {
"components": {
"Link": "a",
"IconButton": "button"
}
}
}
"settings": {
"jsx-a11y": {
"components": {
"Link": "a",
"IconButton": "button"
}
}
}
}
```

Expand Down Expand Up @@ -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"] },
],
},
},
}
```

Expand Down Expand Up @@ -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"] },
],
},
},
}
```

Expand Down
9 changes: 4 additions & 5 deletions src/docs/guide/usage/linter/js-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 */
},
};
},
});
Expand Down
42 changes: 21 additions & 21 deletions src/docs/guide/usage/linter/rules/eslint/accessor-pairs.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,37 @@ 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;
}
}
```

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;
}
}
```

Expand Down Expand Up @@ -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"
}
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
```

Expand All @@ -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;
});
```

Expand Down Expand Up @@ -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"
}
}
```

Expand Down
24 changes: 13 additions & 11 deletions src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Example configuration:

```json
{
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
}
```

Expand All @@ -67,7 +67,7 @@ Examples of **incorrect** code for this rule with the `never` option:

/* ✘ Bad: */
const foo = () => {
return 0;
return 0;
};
```

Expand Down Expand Up @@ -99,7 +99,7 @@ Examples of **correct** code for this rule with the `always` option:

/* ✔ Good: */
const foo = () => {
return 0;
return 0;
};
```

Expand All @@ -112,7 +112,7 @@ Examples of **incorrect** code for this rule with the `as-needed` option:

/* ✘ Bad: */
const foo = () => {
return 0;
return 0;
};
```

Expand All @@ -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();
};
```

Expand All @@ -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
Expand All @@ -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"
}
}
```

Expand Down
Loading