Skip to content

Commit

Permalink
docs: add linter/oxlint
Browse files Browse the repository at this point in the history
  • Loading branch information
ModyQyW committed Jan 4, 2024
1 parent 59d4926 commit 7f3b79d
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default defineConfig({
items: [
{ link: 'overview', text: 'Overview' },
{ link: 'eslint', text: 'ESLint' },
{ link: 'oxlint', text: 'oxlint' },
{ link: 'stylelint', text: 'Stylelint' },
{ link: 'markdownlint', text: 'markdownlint' },
],
Expand Down Expand Up @@ -186,6 +187,7 @@ export default defineConfig({
items: [
{ link: 'overview', text: '概述' },
{ link: 'eslint', text: 'ESLint' },
{ link: 'oxlint', text: 'oxlint' },
{ link: 'stylelint', text: 'Stylelint' },
{ link: 'markdownlint', text: 'markdownlint' },
],
Expand Down
63 changes: 63 additions & 0 deletions docs/guide/linter/oxlint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# oxlint

oxlint is an emerging linter that requires no configuration by default and is mainly used for script files.

::: Positioning of tip oxlint
oxlint is not a complete replacement for ESLint; rather, oxlint complements ESLint because oxlint is very fast. You can run oxlint before running ESLint to get a faster feedback loop.
:::

## Installation

You have to install oxlint first. Currently oxlint v0.0 is supported.

::: code-group

```shell [npm]
npm install oxlint -D
```

```shell [yarn]
yarn add oxlint -D
```

```shell [pnpm]
pnpm install oxlint -D
```

```shell [bun]
bun install oxlint -d
```

:::

## Configuration

### CLI

Update your `package.json` and add `lint:oxlint` script.

```json
{
"scripts": {
"lint:oxlint": "oxlint --deny=correctness --deny=perf --fix"
}
}
```

## Integration

### How to integrate with lint-staged?

If you are using the lint-staged configuration provided by the package, see the [lint-staged chapter](../git/lint-staged.md).

If you are not, you can refer to the following configuration.

```javascript
// lint-staged.config.cjs
module.exports = {
'*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,vue}': [
'oxlint --deny=correctness --deny=perf --fix'
'eslint --fix --cache --no-error-on-unmatched-pattern',
],
};
```
63 changes: 63 additions & 0 deletions docs/zh-CN/guide/linter/oxlint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# oxlint

oxlint 是一个新兴的代码检查工具,默认情况下不需要任何配置,主要用于脚本文件。

::: tip oxlint 的定位
oxlint 不能完全取代 ESLint。相反地,因为 oxlint 非常快,所以 oxlint 可以作为 ESLint 的补充。你可以在运行 ESLint 前运行 oxlint,获取更快的反馈循环。
:::

## 安装

首先你需要安装 oxlint。目前支持 oxlint v0.0。

::: code-group

```shell [npm]
npm install oxlint -D
```

```shell [yarn]
yarn add oxlint -D
```

```shell [pnpm]
pnpm install oxlint -D
```

```shell [bun]
bun install oxlint -d
```

:::

## 配置

### CLI

更新你的 `package.json`,增加 `lint:oxlint` 命令。

```json
{
"scripts": {
"lint:oxlint": "oxlint --deny=correctness --deny=perf --fix"
}
}
```

## 整合

### 如何和 lint-staged 整合使用?

如果你使用该库提供的 lint-staged 配置,请查看 [lint-staged 章节](../git/lint-staged.md)

如果你没有使用该库提供的 lint-staged 配置,可以参考以下配置。

```javascript
// lint-staged.config.cjs
module.exports = {
'*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,vue}': [
'oxlint --deny=correctness --deny=perf --fix'
'eslint --fix --cache --no-error-on-unmatched-pattern',
],
};
```

0 comments on commit 7f3b79d

Please sign in to comment.