Skip to content

Commit 7386ad5

Browse files
authored
feat(blog): oxlint v0.10.0 migration guide (oxc-project#228)
1 parent 37a29e6 commit 7386ad5

File tree

4 files changed

+238
-0
lines changed

4 files changed

+238
-0
lines changed

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ build/
22
!.vitepress/
33
.vitepress/cache
44
pnpm-lock.yaml
5+
# Prettier keeps breaking // `[code ++]` comments in code snippets
6+
src/blog/2024-10-18-oxlint-v0.10-release.md
57
# auto-generated
68
public/sponsors.svg

.vitepress/sidebar.blog.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
{
3+
"text": "Oxlint v0.10 Release and Migration Guide",
4+
"link": "/blog/2024-10-18-oxlint-v0.10-release"
5+
},
26
{
37
"text": "Oxc Transformer Alpha",
48
"link": "/blog/2024-09-29-transformer-alpha"
+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
---
2+
title: Oxlint v0.10 Migration Guide
3+
outline: deep
4+
authors:
5+
- don
6+
editLink: false
7+
---
8+
9+
<AppBlogPostHeader />
10+
11+
Oxlint v0.10.0 is here! This release includes several exciting features,
12+
including many improvements to configuration files.
13+
14+
## New Features
15+
16+
<!-- todo: other features -->
17+
### New Rules
18+
19+
This release includes the following new rules:
20+
- `promise/no-callback-in-promise`
21+
- `react/iframe-missing-sandbox`
22+
- `node/no-new-require`
23+
24+
And adds auto fixes/suggestions for:
25+
- `eslint/no-plusplus`
26+
27+
### Enable/Disable Rules by Category
28+
29+
You can now enable or disable entire categories of rules with the `categories`
30+
field inside of your configuration file.
31+
32+
Now, instead of running this command:
33+
34+
```sh
35+
oxlint -D correctness -W suspicious -c oxlint.json
36+
```
37+
38+
You can add a `categories` field to your `oxlint.json`:
39+
40+
::: code-group
41+
42+
```jsonc [oxlintrc.json]
43+
{
44+
"categories": { // [!code ++]
45+
"correctness": "deny", // [!code ++]
46+
"suspicious": "warn", // [!code ++]
47+
}, // [!code ++]
48+
"rules": {
49+
"no-const-assign": "error",
50+
"import/no-cycle": "error",
51+
},
52+
}
53+
```
54+
55+
:::
56+
57+
and drop the `-D` and `-W` flags.
58+
59+
### `plugins` Are Now Supported in Configuration Files
60+
61+
Configuration files now support the `plugins` array from ESLint v8 configs.
62+
This allows you to enable plugins without CLI arguments, making it possible to
63+
use plugins in VSCode.
64+
65+
::: code-group
66+
67+
```jsonc [oxlintrc.json]
68+
{
69+
"plugins": ["import"], // [!code ++]
70+
"categories": {
71+
"correctness": "deny",
72+
"suspicious": "warn",
73+
},
74+
"rules": {
75+
"react/jsx-uses-react": "off",
76+
"react/react-in-jsx-scope": "off",
77+
},
78+
}
79+
```
80+
81+
:::
82+
83+
This plays nicely with `categories`, as enabled/disabled categories affect plugins as well.
84+
85+
::: code-group
86+
87+
```jsonc [oxlintrc.json]
88+
{
89+
"plugins": ["import"],
90+
// `categories` affects all enabled plugins
91+
"categories": {
92+
"correctness": "allow",
93+
"suspicious": "warn",
94+
},
95+
"rules": {
96+
"no-const-assign": "error",
97+
"import/no-cycle": "error",
98+
},
99+
}
100+
```
101+
102+
:::
103+
104+
## Breaking Changes and Migration Guide
105+
106+
### CLI vs Config File Rule Priority
107+
108+
Before, config files would override rules set in CLI arguments. For example, running this command:
109+
110+
```sh
111+
oxlint -A correctness -c oxlintrc.json
112+
```
113+
114+
With this config file
115+
116+
::: code-group
117+
118+
```jsonc [oxlintrc.json]
119+
{
120+
"rules": {
121+
"no-const-assign": "error",
122+
},
123+
}
124+
```
125+
126+
:::
127+
128+
Would result in a single rule, `no-const-assign` being turned on at an error level with all other rules disabled (i.e. set to "allow").
129+
130+
Now, **CLI arguments will override config files**. That same command with the
131+
same config file will result with **all rules being disabled**. To get the same
132+
behavior as before, enable and disable categories in your config file instead of
133+
with CLI arguments.
134+
135+
```sh
136+
oxlint -c oxlint.json
137+
```
138+
139+
::: code-group
140+
141+
```jsonc [oxlintrc.json]
142+
{
143+
"categories": { // [!code ++]
144+
"correctness": "allow", // [!code ++]
145+
}, // [!code ++]
146+
"rules": {
147+
"no-const-assign": "error",
148+
},
149+
}
150+
```
151+
152+
:::

tmp/2024-10-10-oxlint-v1-release.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Oxlint v1 Release
3+
outline: deep
4+
authors:
5+
- don
6+
editLink: false
7+
---
8+
9+
<AppBlogPostHeader />
10+
11+
We're thrilled to announce the release of Oxlint v1! This release includes
12+
several exciting features, including many improvements to configuration files.
13+
14+
<!-- todo: other features -->
15+
16+
## Configuration Features
17+
18+
Configuration files now support the `plugins` array from ESLint v8 configs.
19+
This allows you to enable plugins without CLI arguments, making it possible to
20+
use plugins in VSCode.
21+
22+
::: code-group
23+
24+
```jsonc [oxlintrc.json]
25+
{
26+
"plugins": ["@typescript-eslint", "react", "next"], // [!code ++]
27+
"rules": {
28+
"react/jsx-uses-react": "off",
29+
"react/react-in-jsx-scope": "off",
30+
},
31+
}
32+
```
33+
34+
:::
35+
36+
# Breaking Changes and Migration Guide
37+
38+
## CLI vs Config File Rule Priority
39+
40+
Before, config files would override rules set in CLI arguments. For example, running this command:
41+
42+
```sh
43+
oxlint -A correctness -c oxlintrc.json
44+
```
45+
46+
With this config file
47+
48+
::: code-group
49+
50+
```jsonc [oxlintrc.json]
51+
{
52+
"rules": {
53+
"no-const-assign": "error",
54+
},
55+
}
56+
```
57+
58+
:::
59+
60+
Would result in a single rule, `no-const-assign` being turned on at an error level with all other rules disabled (i.e. set to "allow").
61+
62+
Now, **CLI arguments will override config files**. That same command with the
63+
same config file will result with **all rules being disabled**. To get the same
64+
behavior as before, enable and disable categories in your config file.
65+
66+
::: code-group
67+
68+
```jsonc [oxlintrc.json]
69+
{
70+
"categories": {
71+
// [!code ++]
72+
"correctness": "allow", // [!code ++]
73+
}, // [!code ++]
74+
"rules": {
75+
"no-const-assign": "error",
76+
},
77+
}
78+
```
79+
80+
:::

0 commit comments

Comments
 (0)