Skip to content

feat(blog): oxlint v0.10.0 migration guide #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ build/
!.vitepress/
.vitepress/cache
pnpm-lock.yaml
# Prettier keeps breaking // `[code ++]` comments in code snippets
src/blog/2024-10-18-oxlint-v0.10-release.md
# auto-generated
public/sponsors.svg
4 changes: 4 additions & 0 deletions .vitepress/sidebar.blog.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[
{
"text": "Oxlint v0.10 Release and Migration Guide",
"link": "/blog/2024-10-18-oxlint-v0.10-release"
},
{
"text": "Oxc Transformer Alpha",
"link": "/blog/2024-09-29-transformer-alpha"
Expand Down
152 changes: 152 additions & 0 deletions src/blog/2024-10-18-oxlint-v0.10-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
title: Oxlint v0.10 Migration Guide
outline: deep
authors:
- don
editLink: false
---

<AppBlogPostHeader />

Oxlint v0.10.0 is here! This release includes several exciting features,
including many improvements to configuration files.

## New Features

<!-- todo: other features -->
### New Rules

This release includes the following new rules:
- `promise/no-callback-in-promise`
- `react/iframe-missing-sandbox`
- `node/no-new-require`

And adds auto fixes/suggestions for:
- `eslint/no-plusplus`

### Enable/Disable Rules by Category

You can now enable or disable entire categories of rules with the `categories`
field inside of your configuration file.

Now, instead of running this command:

```sh
oxlint -D correctness -W suspicious -c oxlint.json
```

You can add a `categories` field to your `oxlint.json`:

::: code-group

```jsonc [oxlintrc.json]
{
"categories": { // [!code ++]
"correctness": "deny", // [!code ++]
"suspicious": "warn", // [!code ++]
}, // [!code ++]
"rules": {
"no-const-assign": "error",
"import/no-cycle": "error",
},
}
```

:::

and drop the `-D` and `-W` flags.

### `plugins` Are Now Supported in Configuration Files

Configuration files now support the `plugins` array from ESLint v8 configs.
This allows you to enable plugins without CLI arguments, making it possible to
use plugins in VSCode.

::: code-group

```jsonc [oxlintrc.json]
{
"plugins": ["import"], // [!code ++]
"categories": {
"correctness": "deny",
"suspicious": "warn",
},
"rules": {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
},
}
```

:::

This plays nicely with `categories`, as enabled/disabled categories affect plugins as well.

::: code-group

```jsonc [oxlintrc.json]
{
"plugins": ["import"],
// `categories` affects all enabled plugins
"categories": {
"correctness": "allow",
"suspicious": "warn",
},
"rules": {
"no-const-assign": "error",
"import/no-cycle": "error",
},
}
```

:::

## Breaking Changes and Migration Guide

### CLI vs Config File Rule Priority

Before, config files would override rules set in CLI arguments. For example, running this command:

```sh
oxlint -A correctness -c oxlintrc.json
```

With this config file

::: code-group

```jsonc [oxlintrc.json]
{
"rules": {
"no-const-assign": "error",
},
}
```

:::

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").

Now, **CLI arguments will override config files**. That same command with the
same config file will result with **all rules being disabled**. To get the same
behavior as before, enable and disable categories in your config file instead of
with CLI arguments.

```sh
oxlint -c oxlint.json
```

::: code-group

```jsonc [oxlintrc.json]
{
"categories": { // [!code ++]
"correctness": "allow", // [!code ++]
}, // [!code ++]
"rules": {
"no-const-assign": "error",
},
}
```

:::
80 changes: 80 additions & 0 deletions tmp/2024-10-10-oxlint-v1-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: Oxlint v1 Release
outline: deep
authors:
- don
editLink: false
---

<AppBlogPostHeader />

We're thrilled to announce the release of Oxlint v1! This release includes
several exciting features, including many improvements to configuration files.

<!-- todo: other features -->

## Configuration Features

Configuration files now support the `plugins` array from ESLint v8 configs.
This allows you to enable plugins without CLI arguments, making it possible to
use plugins in VSCode.

::: code-group

```jsonc [oxlintrc.json]
{
"plugins": ["@typescript-eslint", "react", "next"], // [!code ++]
"rules": {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
},
}
```

:::

# Breaking Changes and Migration Guide

## CLI vs Config File Rule Priority

Before, config files would override rules set in CLI arguments. For example, running this command:

```sh
oxlint -A correctness -c oxlintrc.json
```

With this config file

::: code-group

```jsonc [oxlintrc.json]
{
"rules": {
"no-const-assign": "error",
},
}
```

:::

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").

Now, **CLI arguments will override config files**. That same command with the
same config file will result with **all rules being disabled**. To get the same
behavior as before, enable and disable categories in your config file.

::: code-group

```jsonc [oxlintrc.json]
{
"categories": {
// [!code ++]
"correctness": "allow", // [!code ++]
}, // [!code ++]
"rules": {
"no-const-assign": "error",
},
}
```

:::