Skip to content

Commit 811cc2c

Browse files
authored
enable embedded formatting (#711)
1 parent 53bdcac commit 811cc2c

File tree

642 files changed

+5794
-5593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

642 files changed

+5794
-5593
lines changed

.oxfmtrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": [],
4+
"embeddedLanguageFormatting": "auto"
5+
}

.vitepress/theme/components/AppBlogPostHeader.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ const authors = computed(() =>
1313
1414
if (member) {
1515
const { avatar, links, name, title } = member;
16-
const { link = "" } = links?.find((link) => link.link.startsWith("https://github.com/")) ?? {};
16+
const { link = "" } =
17+
links?.find((link) => link.link.startsWith("https://github.com/")) ?? {};
1718
1819
return [{ avatar, link, name, title }];
1920
}
2021
2122
return [];
22-
})
23+
}),
2324
);
2425
const date = computed(() => {
2526
const filePath = vitePressData.page.value.filePath;
@@ -39,7 +40,9 @@ const datetime = ref("");
3940
onMounted(() => {
4041
watchEffect(() => {
4142
if (date.value) {
42-
datetime.value = new Intl.DateTimeFormat(lang.value, { dateStyle: "long" }).format(date.value);
43+
datetime.value = new Intl.DateTimeFormat(lang.value, { dateStyle: "long" }).format(
44+
date.value,
45+
);
4346
}
4447
});
4548
});
@@ -52,7 +55,7 @@ onMounted(() => {
5255
<time :datetime="isoDatetime">{{ datetime }}</time>
5356
</p>
5457
<ul class="authors">
55-
<li v-for="({ avatar, link, name, title }) in authors" :key="name" class="author">
58+
<li v-for="{ avatar, link, name, title } in authors" :key="name" class="author">
5659
<img :src="avatar" :alt="name" class="author-avatar" />
5760
<p class="author-text">
5861
<a v-if="link" :href="link" target="_blank" class="author-name">{{ name }}</a>

src/blog/2024-10-18-oxlint-v0.10-release.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ You can add a `categories` field to your `oxlint.json`:
5050

5151
```jsonc [oxlintrc.json]
5252
{
53-
"categories": { // [!code ++]
53+
"categories": {
54+
// [!code ++]
5455
"correctness": "deny", // [!code ++]
5556
"suspicious": "warn", // [!code ++]
5657
}, // [!code ++]
@@ -149,7 +150,8 @@ oxlint -c oxlint.json
149150

150151
```jsonc [oxlintrc.json]
151152
{
152-
"categories": { // [!code ++]
153+
"categories": {
154+
// [!code ++]
153155
"correctness": "allow", // [!code ++]
154156
}, // [!code ++]
155157
"rules": {

src/docs/guide/usage/linter/generated-config.md

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ Example
2121
```json
2222
{
2323
"$schema": "./node_modules/oxlint/configuration_schema.json",
24-
"plugins": [
25-
"import",
26-
"typescript",
27-
"unicorn"
28-
],
24+
"plugins": ["import", "typescript", "unicorn"],
2925
"env": {
3026
"browser": true
3127
},
@@ -45,10 +41,7 @@ Example
4541
},
4642
"overrides": [
4743
{
48-
"files": [
49-
"*.test.ts",
50-
"*.spec.ts"
51-
],
44+
"files": ["*.test.ts", "*.spec.ts"],
5245
"rules": {
5346
"@typescript-eslint/no-explicit-any": "off"
5447
}
@@ -355,13 +348,13 @@ Example:
355348

356349
```json
357350
{
358-
"settings": {
359-
"jsx-a11y": {
360-
"attributes": {
361-
"for": ["htmlFor", "for"]
362-
}
363-
}
364-
}
351+
"settings": {
352+
"jsx-a11y": {
353+
"attributes": {
354+
"for": ["htmlFor", "for"]
355+
}
356+
}
357+
}
365358
}
366359
```
367360

@@ -378,14 +371,14 @@ Example:
378371

379372
```json
380373
{
381-
"settings": {
382-
"jsx-a11y": {
383-
"components": {
384-
"Link": "a",
385-
"IconButton": "button"
386-
}
387-
}
388-
}
374+
"settings": {
375+
"jsx-a11y": {
376+
"components": {
377+
"Link": "a",
378+
"IconButton": "button"
379+
}
380+
}
381+
}
389382
}
390383
```
391384

@@ -440,17 +433,17 @@ Example:
440433

441434
```jsonc
442435
{
443-
"settings": {
444-
"react": {
445-
"formComponents": [
446-
"CustomForm",
447-
// OtherForm is considered a form component and has an endpoint attribute
448-
{ "name": "OtherForm", "formAttribute": "endpoint" },
449-
// allows specifying multiple properties if necessary
450-
{ "name": "Form", "formAttribute": ["registerEndpoint", "loginEndpoint"] }
451-
]
452-
}
453-
}
436+
"settings": {
437+
"react": {
438+
"formComponents": [
439+
"CustomForm",
440+
// OtherForm is considered a form component and has an endpoint attribute
441+
{ "name": "OtherForm", "formAttribute": "endpoint" },
442+
// allows specifying multiple properties if necessary
443+
{ "name": "Form", "formAttribute": ["registerEndpoint", "loginEndpoint"] },
444+
],
445+
},
446+
},
454447
}
455448
```
456449

@@ -478,18 +471,18 @@ Example:
478471

479472
```jsonc
480473
{
481-
"settings": {
482-
"react": {
483-
"linkComponents": [
484-
"HyperLink",
485-
// Use `linkAttribute` for components that use a different prop name
486-
// than `href`.
487-
{ "name": "MyLink", "linkAttribute": "to" },
488-
// allows specifying multiple properties if necessary
489-
{ "name": "Link", "linkAttribute": ["to", "href"] }
490-
]
491-
}
492-
}
474+
"settings": {
475+
"react": {
476+
"linkComponents": [
477+
"HyperLink",
478+
// Use `linkAttribute` for components that use a different prop name
479+
// than `href`.
480+
{ "name": "MyLink", "linkAttribute": "to" },
481+
// allows specifying multiple properties if necessary
482+
{ "name": "Link", "linkAttribute": ["to", "href"] },
483+
],
484+
},
485+
},
493486
}
494487
```
495488

src/docs/guide/usage/linter/js-plugins.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ Paths are resolved relative to the config file itself.
3939
```json
4040
// .oxlintrc.json
4141
{
42-
"jsPlugins": [
43-
"./path/to/my-plugin.js",
44-
"eslint-plugin-whatever"
45-
],
42+
"jsPlugins": ["./path/to/my-plugin.js", "eslint-plugin-whatever"],
4643
"rules": {
4744
"my-plugin/rule1": "error",
4845
"my-plugin/rule2": "warn",
@@ -262,7 +259,9 @@ const rule = defineRule({
262259
// This always runs for every file, even if
263260
// it doesn't contain any `FunctionDeclaration`s
264261
},
265-
FunctionDeclaration(node) {/* do stuff */},
262+
FunctionDeclaration(node) {
263+
/* do stuff */
264+
},
266265
};
267266
},
268267
});

src/docs/guide/usage/linter/rules/eslint/accessor-pairs.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,37 @@ Examples of **incorrect** code for this rule:
2626

2727
```js
2828
var o = {
29-
set a(value) {
30-
this.val = value;
31-
}
29+
set a(value) {
30+
this.val = value;
31+
},
3232
};
3333

3434
class C {
35-
set a(value) {
36-
this.val = value;
37-
}
35+
set a(value) {
36+
this.val = value;
37+
}
3838
}
3939
```
4040

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

4343
```js
4444
var o = {
45-
set a(value) {
46-
this.val = value;
47-
},
48-
get a() {
49-
return this.val;
50-
}
45+
set a(value) {
46+
this.val = value;
47+
},
48+
get a() {
49+
return this.val;
50+
},
5151
};
5252

5353
class C {
54-
set a(value) {
55-
this.val = value;
56-
}
57-
get a() {
58-
return this.val;
59-
}
54+
set a(value) {
55+
this.val = value;
56+
}
57+
get a() {
58+
return this.val;
59+
}
6060
}
6161
```
6262

@@ -104,9 +104,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
104104

105105
```json [Config (.oxlintrc.json)]
106106
{
107-
"rules": {
108-
"accessor-pairs": "error"
109-
}
107+
"rules": {
108+
"accessor-pairs": "error"
109+
}
110110
}
111111
```
112112

src/docs/guide/usage/linter/rules/eslint/array-callback-return.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Examples of **incorrect** code for this rule:
2828
```javascript
2929
let foo = [1, 2, 3, 4];
3030
foo.map((a) => {
31-
console.log(a)
31+
console.log(a);
3232
});
3333
```
3434

@@ -37,8 +37,8 @@ Examples of **correct** code for this rule:
3737
```javascript
3838
let foo = [1, 2, 3, 4];
3939
foo.map((a) => {
40-
console.log(a)
41-
return a
40+
console.log(a);
41+
return a;
4242
});
4343
```
4444

@@ -71,9 +71,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
7171

7272
```json [Config (.oxlintrc.json)]
7373
{
74-
"rules": {
75-
"array-callback-return": "error"
76-
}
74+
"rules": {
75+
"array-callback-return": "error"
76+
}
7777
}
7878
```
7979

src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Example configuration:
5252

5353
```json
5454
{
55-
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
55+
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
5656
}
5757
```
5858

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

6868
/* ✘ Bad: */
6969
const foo = () => {
70-
return 0;
70+
return 0;
7171
};
7272
```
7373

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

100100
/* ✔ Good: */
101101
const foo = () => {
102-
return 0;
102+
return 0;
103103
};
104104
```
105105

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

113113
/* ✘ Bad: */
114114
const foo = () => {
115-
return 0;
115+
return 0;
116116
};
117117
```
118118

@@ -125,12 +125,12 @@ Examples of **correct** code for this rule with the `as-needed` option:
125125
const foo1 = () => 0;
126126

127127
const foo2 = (retv, name) => {
128-
retv[name] = true;
129-
return retv;
128+
retv[name] = true;
129+
return retv;
130130
};
131131

132132
const foo3 = () => {
133-
bar();
133+
bar();
134134
};
135135
```
136136

@@ -153,7 +153,9 @@ Examples of **correct** code for this rule with the `{ "requireReturnForObjectLi
153153

154154
/* ✔ Good: */
155155
const foo = () => {};
156-
const bar = () => { return { bar: 0 }; };
156+
const bar = () => {
157+
return { bar: 0 };
158+
};
157159
```
158160

159161
## How to use
@@ -164,9 +166,9 @@ To **enable** this rule using the config file or in the CLI, you can use:
164166

165167
```json [Config (.oxlintrc.json)]
166168
{
167-
"rules": {
168-
"arrow-body-style": "error"
169-
}
169+
"rules": {
170+
"arrow-body-style": "error"
171+
}
170172
}
171173
```
172174

0 commit comments

Comments
 (0)