Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vite-plugin-eslint2

ModyQyW133.4kMIT5.0.3TypeScript support: included

ESLint plugin for Vite.

eslint, vite-plugin

readme

vite-plugin-eslint2

English | 简体中文

介绍

Vite ESLint 插件。支持 Vite v2 ~ v6 和 ESLint v7 ~ v9。要求 node>=18

👇 请查看文档了解具体用法和示例。

Cloudflare Pages

你也可能想要 Vite Stylelint 插件

安装

npm install vite-plugin-eslint2 -D

vite-plugin-eslint2 不会为你安装和配置 ESLint。你应该自己处理这些。

<summary>ESLint v9</summary>
npm install eslint@^9 @types/eslint@^9 -D

如果你使用 v9.10.0 或更高版本,你不需要安装 @types/eslint

<summary>ESLint v8</summary>
npm install eslint@^8 @types/eslint@^8 -D
<summary>ESLint v7</summary>
npm install eslint@^7 @types/eslint@^7 -D

使用

// vite.config.ts
import { defineConfig } from "vite";
import eslint from "vite-plugin-eslint2";

export default defineConfig({
  plugins: [eslint()],
});

👇 请查看文档了解具体用法和示例。

Cloudflare Pages

致谢

最初从 gxmari007/vite-plugin-eslint 分叉出来。

贡献者们

该项目由 ModyQyW 创建。

感谢 所有贡献者 的付出!

赞助

如果这个包对你有所帮助,请考虑 赞助 支持,这将有利于项目持续开发和维护。

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

5.0.3 (2024-11-26)

Note: Version bump only for package monorepo

5.0.2 (2024-11-08)

Bug Fixes

  • correct id & filePath params (1ac2b85) - by @

5.0.1 (2024-10-19)

Note: Version bump only for package monorepo

5.0.0 (2024-10-01)

⚠ BREAKING CHANGES

  • remove chokidar option

Features

  • remove chokidar option (e33e7f0) - by @ModyQyW

Bug Fixes

  • fix wrong colorize (cc20565) - by @ModyQyW
  • remove extra parsing (495b39f) - by @ModyQyW
  • terminate worker if possible (3304fb4) - by @ModyQyW

4.4.2 (2024-09-25)

Bug Fixes

  • eslintInstance may not be initialized when calling lintFiles in the worker (#40) (afc7bee) - by @fuxichen
  • fix types (654c4bc) - by @ModyQyW

4.4.1 (2024-09-11)

  • fix: make @types/eslint optional

4.4.0 (2024-02-24)

  • feat: support eslint@9
  • feat: try loadESLint first, fallback to read explicit classes

4.3.1 (2023-11-17)

  • chore: update peerDependencies

4.3.0 (2023-10-23)

  • feat: support rollup@4 and vite@5, ATTENTION: rollup@4 is supported since `vite@5.0.0-beta.10`

4.2.0 (2023-10-19)

  • feat: try to support flat config system

4.1.0 (2023-08-21)

  • feat: add test option

4.0.3 (2023-08-17)

  • revert: revert "fix: transform errors ↔ warnings for real emitErrorAsWarning and emitWarningAsError"

4.0.2 (2023-08-16)

  • fix: transform errors ↔ warnings for real emitErrorAsWarning and emitWarningAsError

4.0.1 (2023-08-16)

  • fix: fix internal function shouldIgnoreModule judgement

4.0.0 (2023-08-15)

I completely rewrote the plugin. It's still backward compatible, but there is still a possibility that the changes may affect some projects. So I bumped a major version.

  • feat: add lintDirtyOnly option
  • feat: add debug
  • types: add descriptions
  • docs: update README
  • feat!: update internal functions

3.3.0 (2023-03-09)

  • build: switch to unbuild
  • feat: export more types

3.2.1 (2023-01-31)

  • fix: fix eslint initial params

3.2.0 (2023-01-31)

This project is named vite-plugin-eslint2 now.

  • feat: add chokidar option
  • fix: use __dirname directly by accident
  • fix: maybe lint files should be ignored
  • build: update minify and generate sourcemap

3.1.6 (2023-01-04)

  • perf: better emit handling

3.1.5 (2023-01-04)

  • build: switch to rollup
  • refactor: shouldIgnore function

3.1.4 (2022-12-28)

  • fix: fix judge order

3.1.3 (2022-12-27)

  • fix: fix judge order

3.1.2 (2022-12-20)

  • perf: avoid empty log

3.1.1 (2022-12-20)

  • perf: avoid logging twice for one file

3.1.0 (2022-12-16)

  • feat: add lintInWorker option
  • perf: initialESLint params

3.0.1 (2022-12-15)

  • fix: fix build

3.0.0 (2022-12-09)

  • feat: support vite@4
  • feat!: require node>=14.18
  • feat!: build option defaults to false
  • feat!: cacheLocation option defaults to .eslintcache
  • feat: esm by default
    • don't be afraid as commonjs is also supported

2.1.1 (2022-12-04)

  • fix: fix ESLint options lost

2.1.0 (2022-11-28)

  • feat: add dev and build option

2.0.14 (2022-11-25)

  • perf: improve types

2.0.13 (2022-11-25)

  • refactor

2.0.12 (2022-11-25)

  • revert: revert perf: reduce dependencies, which breaks vite@2

2.0.11 (2022-11-24)

  • perf: reduce dependencies

2.0.10

  • fix: fix build

2.0.9

  • perf: use config.cacheDir to get default cacheLocation

2.0.8

  • fix: pass ctx to lintFiles method

2.0.7

  • fix: warning styles

2.0.6

  • fix: fix typo

2.0.5

  • perf: warn when lintOnStart is true

2.0.4

  • perf: import path from node:path instead of path
  • fix: fix type: "module" support

2.0.3

Just update peerDependencies in package.json.

2.0.2

  • fix: omit keys to avoid new ESLint error

2.0.1

  • fix: fix type

2.0.0

This version supports vite@2 and vite@3. The breaking changes are caused by aligning behaviors with ESLint Node.js API.

  • feat!: remove throwOnError and throwOnWarning options (marked as deprecated before)
  • feat!: include and exclude options now accept string | string[] only to align with eslint.lintFiles
  • feat: add lintOnStart option
  • feat: exclude virtual: by default

1.4.1

  • fix: show error message when importing eslint if possible
  • fix: include shims into dist

1.4.0

  • feat: support vite@3
  • feat: ignore virtual modules
  • perf: not to add build.outDir into exclude
  • fix: fix then handling

1.3.2

  • fix: remove allowSyntheticDefaultImports and esModuleInterop in tsconfig.json

1.3.1

  • fix: fix regressions

1.3.0

  • feat: include .svelte files by default

1.2.0

  • perf: better output format
  • feat: add emitErrorAsWarning and emitWarningAsError options

1.1.0

  • fix: fix index.html dealing

1.1.0-beta.1

  • feat: support ESLint options
  • feat: recommend throwOnError -> emitError and throwOnWarning -> emitWarning

The plugin recommends emitError / emitWarning instead of throwOnError / throwOnWarning now. However, you can stay with throwOnError / throwOnWarning safely. This is a backward-compatible version update.

1.1.0-beta.0

  • feat: add eslintPath option

1.0.0

Initial release.