diff --git a/docs/guide/options.md b/docs/guide/options.md index e2ac02a..a0efd00 100644 --- a/docs/guide/options.md +++ b/docs/guide/options.md @@ -19,7 +19,7 @@ Whether to automatically fix. - ESLint default: `false` - Plugin default: `true` -Whether to enable the cache. The cache is enabled by default to improve speed. +Whether to enable the cache. This is disabled in ESLint by default and enabled in plugin by default to improve speed. ### `cacheLocation` @@ -62,9 +62,11 @@ This option specifies the files you want to lint. You don't need to change it in If you're using the plugin defaults, the plugin will only call [eslint.lintFiles](https://eslint.org/docs/latest/integrate/nodejs-api#-eslintlintfilespatterns) in the `transform` hook. The option value will be used to [create a filter](https://github.com/rollup/plugins/blob/master/packages/pluginutils/README.md#createfilter) to determine if the call should be made and the parameter of the call, which means that the option value needs to fulfill the requirements of [picomatch@2.3.1](https://github.com/micromatch/picomatch/tree/2.3.1). -If you enable the `lintOnStart` option, the plugin will also call `eslint.lintFiles` in the `buildStart` hook. The option value will not be used to create a filter, but will be used directly as the call parameter, which means that the option value also needs to fulfill the [minimatch@3.1.2](https://github.com/isaacs/minimatch/tree/3.1.2) requirement. +If you enable the `lintOnStart` option, the plugin will also call [eslint.lintFiles](https://eslint.org/docs/latest/integrate/nodejs-api#-eslintlintfilespatterns) in the `buildStart` hook. The option value will not be used to create a filter, but will be used directly as the call parameter, which means that the option value also needs to fulfill the [minimatch@3.1.2](https://github.com/isaacs/minimatch/tree/3.1.2) requirement. -If you disable the `lintDirtyOnly` option, the plugin will use the option value as the call parameter every time it calls `eslint.lintFiles`, which means that the option value also needs to fulfill the requirements of `minimatch@3.1.2`. +If you disable the `lintDirtyOnly` option, the plugin will use the option value as the call parameter every time it calls [eslint.lintFiles](https://eslint.org/docs/latest/integrate/nodejs-api#-eslintlintfilespatterns), which means that the option value also needs to fulfill the requirements of [minimatch@3.1.2](https://github.com/isaacs/minimatch/tree/3.1.2). + +If you disable the `lintDirtyOnly` option, the plugin will use the option value as the call parameter when it calls [eslint.lintFiles](https://eslint.org/docs/latest/integrate/nodejs-api#-eslintlintfilespatterns) outside of the `buildStart` lifecycle. This means that this option value also needs to fulfill the requirements of [minimatch@3.1.2](https://github.com/isaacs/minimatch/tree/3.1.2). ### `exclude` @@ -82,20 +84,20 @@ If you enable the `lintOnStart` option or disable the `lintDirtyOnly` option, th ### `eslintPath` - Type: `string` -- Default: `'eslint'` +- Default: `"eslint"` Path to ESLint that will be used for linting. Use [dynamic import](https://javascript.info/modules-dynamic-imports) under the hood. Read [server.fs](https://vitejs.dev/guide/#command-line-interface) first. -If you want to use the flat config system in ESLint v8, set the value to `'eslint/use-at-your-own-risk'`. Place a flat config file in the root of your project or set the `ESLINT_USE_FLAT_CONFIG` environment variable to true and pass the option `overrideConfigFile` to the plugin if you are using other config files. You can learn more from [Flat config rollout plans](https://eslint.org/blog/2023/10/flat-config-rollout-plans/) and [Configuration Files (New)](https://eslint.org/docs/latest/use/configure/configuration-files-new). +If you want to use the flat config system in ESLint v8, set the value to `'eslint/use-at-your-own-risk'`. Place a flat config file in the root of your project or set the `ESLINT_USE_FLAT_CONFIG` environment variable to true and pass the option `overrideConfigFile` to the plugin if you are using other config files. + +You can learn more from [Flat config rollout plans](https://eslint.org/blog/2023/10/flat-config-rollout-plans/) and [Configuration Files (New)](https://eslint.org/docs/latest/use/configure/configuration-files-new). ### `formatter` - Type: `string` -- Default: `'stylish'` - -The name or the path of a formatter. +- Default: `"stylish"` -This is used to [load a formatter](https://eslint.org/docs/developer-guide/nodejs-api#-eslintloadformatternameorpath) in order to convert lint results to a human- or machine-readable string. +The name or the path of a formatter. This is used to [load a formatter](https://eslint.org/docs/developer-guide/nodejs-api#-eslintloadformatternameorpath) in order to convert lint results to a human- or machine-readable string. ### `lintInWorker` @@ -122,24 +124,9 @@ This will significantly slow down Vite first starting if you have no caches and - Type: `boolean` - Default: `true` -Lint changed files only when running ESLint except from `buildStart` hook. This is enabled by default. - -This plugin will lint `include` option specified files when disabled. - -### `chokidar` (deprecate soon) - -::: warning - -Deprecate soon. Do not use. - -::: - -- Type: `boolean` -- Default: `false` - -Run ESLint in Chokidar `change` event instead of `transform` hook. +Whether or not to checkout only modified files that are not included in the `exclude` option value when running ESLint outside of the `buildStart` lifecycle. Enabled by default. -If you enable this one, it is recommended to also enable `lintOnStart`. +When disabled, files are checked against the `include` and `exclude` option values. ### `emitError` diff --git a/docs/zh-Hans/guide/options.md b/docs/zh-Hans/guide/options.md index 37cc74c..db47035 100644 --- a/docs/zh-Hans/guide/options.md +++ b/docs/zh-Hans/guide/options.md @@ -19,7 +19,7 @@ - ESLint 默认值:`false` - 插件默认值:`true` -是否启用缓存。插件默认启用以提高速度。 +是否启用缓存。ESLint 默认禁用,插件默认启用以提高速度。 ### `cacheLocation` @@ -62,9 +62,9 @@ 如果你正在使用插件默认设置,插件只会在 `transform` 生命周期中调用 [eslint.lintFiles](https://eslint.org/docs/latest/integrate/nodejs-api#-eslintlintfilespatterns)。这个选项值会被用于 [创建一个过滤器](https://github.com/rollup/plugins/blob/master/packages/pluginutils/README.md#createfilter) 来确定是否该调用以及调用参数。这意味着选项值需要满足 [picomatch@2.3.1](https://github.com/micromatch/picomatch/tree/2.3.1) 的要求。 -如果你启用了 `lintOnStart` 选项,插件还会在 `buildStart` 生命周期中调用 `eslint.lintFiles`。这个选项值不会用于创建过滤器,而是直接用作调用参数。这意味着这个选项值还需要满足 [minimatch@3.1.2](https://github.com/isaacs/minimatch/tree/3.1.2) 的要求。 +如果你启用了 `lintOnStart` 选项,插件还会在 `buildStart` 生命周期中调用 [eslint.lintFiles](https://eslint.org/docs/latest/integrate/nodejs-api#-eslintlintfilespatterns)。这个选项值不会用于创建过滤器,而是直接用作调用参数。这意味着这个选项值还需要满足 [minimatch@3.1.2](https://github.com/isaacs/minimatch/tree/3.1.2) 的要求。 -如果你禁用了 `lintDirtyOnly` 选项,插件每次调用 `eslint.lintFiles` 时都会将该选项值作为调用参数。这意味着这个选项值也需要满足 [minimatch@3.1.2](https://github.com/isaacs/minimatch/tree/3.1.2) 的要求。 +如果你禁用了 `lintDirtyOnly` 选项,插件在 `buildStart` 生命周期外调用 [eslint.lintFiles](https://eslint.org/docs/latest/integrate/nodejs-api#-eslintlintfilespatterns) 时都会将该选项值作为调用参数。这意味着这个选项值也需要满足 [minimatch@3.1.2](https://github.com/isaacs/minimatch/tree/3.1.2) 的要求。 ### `exclude` @@ -77,21 +77,23 @@ 如果你正在使用插件默认设置,插件只会在 `transform` 生命周期中调用 [eslint.lintFiles](https://eslint.org/docs/latest/integrate/nodejs-api#-eslintlintfilespatterns)。这个选项值会被用于 [创建一个过滤器](https://github.com/rollup/plugins/blob/master/packages/pluginutils/README.md#createfilter) 来确定是否该调用以及调用参数。这意味着选项值需要满足 [picomatch@2.3.1](https://github.com/micromatch/picomatch/tree/2.3.1) 的要求。 -如果你启用了 `lintOnStart` 选项,这个选项值不会生效。你需要调整 `include` 值以包含该选项值。 +如果你启用了 `lintOnStart` 选项或禁用了 `lintDirtyOnly` 选项,这个选项值不会生效。你需要调整 `include` 值以包含该选项值。 ### `eslintPath` - 类型:`string` -- 默认值:`'eslint'` +- 默认值:`"eslint"` ESLint 路径,用于校验文件。底层使用使用 [dynamic import](https://javascript.info/modules-dynamic-imports)。请先查看 [server.fs](https://cn.vitejs.dev/guide/#command-line-interface)。 -如果你想在 ESLint v8 中使用平面配置,将值设置为 `'eslint/use-at-your-own-risk'`。在你的项目根放置一个 平面配置文件,或者设置 `ESLINT_USE_FLAT_CONFIG` 环境变量。如果你在使用其它位置的配置文件,请传递选项 `overrideConfigFile` 给插件。查看 [Flat config rollout plans](https://eslint.org/blog/2023/10/flat-config-rollout-plans/) 和 [Configuration Files (New)](https://eslint.org/docs/latest/use/configure/configuration-files-new) 了解更多。 +如果你想在 ESLint v8 中使用平面配置,将值设置为 `'eslint/use-at-your-own-risk'`。在你的项目根放置一个平面配置文件,或者设置 `ESLINT_USE_FLAT_CONFIG` 环境变量。如果你在使用其它位置的配置文件,请传递选项 `overrideConfigFile` 给插件。 + +查看 [Flat config rollout plans](https://eslint.org/blog/2023/10/flat-config-rollout-plans/) 和 [Configuration Files (New)](https://eslint.org/docs/latest/use/configure/configuration-files-new) 了解更多。 ### `formatter` - 类型:`string` -- 默认值:`'stylish'` +- 默认值:`"stylish"` 格式化器的名称或路径。用于 [读取格式化器](https://eslint.org/docs/developer-guide/nodejs-api#-eslintloadformatternameorpath),以便将校验结果转换为人类或机器可读的字符串。 @@ -104,7 +106,7 @@ ESLint 路径,用于校验文件。底层使用使用 [dynamic import](https:/ 在 worker 中校验时,Vite 的构建过程会更快。即使终端显示了 ESLint 校验错误,你也不会看到 Vite 错误遮罩层,Vite 构建也不会停止。 -这与 [@nabla/vite-plugin-eslint](https://github.com/nabla)、[vite-plugin-checker](https://github.com/fi3ework/vite-plugin-checker) 类似。不同的是,@nabla/vite-plugin-eslint 只支持在 worker 中校验, vite-plugin-checker 可以在浏览器中显示错误和警告。 +这与 [@nabla/vite-plugin-eslint](https://github.com/nabla)、[vite-plugin-checker](https://github.com/fi3ework/vite-plugin-checker) 类似。不同的是,@nabla/vite-plugin-eslint 只支持在 worker 中校验,vite-plugin-checker 可以在浏览器中显示错误和警告。 ### `lintOnStart` @@ -124,21 +126,6 @@ ESLint 路径,用于校验文件。底层使用使用 [dynamic import](https:/ 禁用时,会根据 `include` 和 `exclude` 选项值确定需要校验文件。 -### `chokidar`(即将废弃) - -::: warning - -即将废弃,请勿使用。 - -::: - -- 类型:`boolean` -- 默认值:`false` - -在 Chokidar `change` 事件中而不是在 `transform` 生命周期中运行 ESLint。默认禁用。 - -如果你启用这个选项,建议也启用 `lintOnStart`。 - ### `emitError` - 类型:`boolean`