diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index e7d5f9c2..5bbd5642 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -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' }, ], @@ -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' }, ], diff --git a/docs/guide/linter/oxlint.md b/docs/guide/linter/oxlint.md new file mode 100644 index 00000000..a0405d2a --- /dev/null +++ b/docs/guide/linter/oxlint.md @@ -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', + ], +}; +``` diff --git a/docs/zh-CN/guide/linter/oxlint.md b/docs/zh-CN/guide/linter/oxlint.md new file mode 100644 index 00000000..2023d7ea --- /dev/null +++ b/docs/zh-CN/guide/linter/oxlint.md @@ -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', + ], +}; +```