Skip to content

Commit

Permalink
v2: Flat config support, formatter function & ESM [publish]
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Nov 18, 2023
1 parent d2312d5 commit 4105adb
Show file tree
Hide file tree
Showing 17 changed files with 1,087 additions and 63 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog

## 2.0.0

- Support ESLint flat config (fixes [#23](https://github.com/nabla/vite-plugin-eslint/issues/23))
- Support passing a function to formatter
- Switch to ESM. This removes the CJS warning when using the plugin with Vite 5. A CJS wrapper is still provided but [migrating](https://vitejs.dev/guide/migration.html#deprecate-cjs-node-api) to running Vite in ESM is encouraged
- Drop support for Vite 2 & 3 & node<18 (aligns with Vite 5)

## 1.6.0

- Add vite@5 to peer dependency range
Expand Down
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -44,6 +44,7 @@ You can use `DEBUG=eslint node_modules/.bin/vite` to debug this option (availabl

### formatter

- Type: `string`
- Type: `string | ((result: ESLint.LintResult) => void)`
- Default: Custom format with one line per warning/error.

If provided, the value is passed to `eslint.loadFormatter`. Default to a custom format with one line per warning/error. Use `stylish` to get a CRA like output. Async formatters are supported in `1.5.0`.
If provided, the value is passed to `eslint.loadFormatter`. Use `stylish` to get a CRA like output. Async formatters are supported in `1.5.0`. Function support was added in `1.7.0`.
20 changes: 15 additions & 5 deletions package.json
@@ -1,10 +1,20 @@
{
"name": "@nabla/vite-plugin-eslint",
"description": "Plugs ESLint into Vite dev server",
"version": "1.6.0",
"version": "2.0.1",
"license": "MIT",
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
"main": "src/index.js",
"type": "module",
"main": "src/index.cjs",
"types": "src/index.d.ts",
"module": "src/index.mjs",
"exports": {
".": {
"types": "./src/index.d.ts",
"require": "./src/index.cjs",
"import": "./src/index.mjs"
}
},
"files": [
"src"
],
Expand All @@ -22,11 +32,11 @@
"chalk": "^4"
},
"peerDependencies": {
"vite": "^2 || ^3 || ^4 || ^5",
"eslint": "*"
"eslint": "*",
"vite": "^4 || ^5"
},
"devDependencies": {
"eslint": "^8.53.0",
"eslint": "^8.54.0",
"prettier": "3.0.3",
"vite": "^5.0.0"
}
Expand Down
9 changes: 9 additions & 0 deletions playground/.eslintrc.cjs
@@ -0,0 +1,9 @@
module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
rules: {
"prefer-const": "error",
},
};
7 changes: 7 additions & 0 deletions playground/eslint.config.js
@@ -0,0 +1,7 @@
export default [
{
rules: {
"prefer-const": "error",
},
},
];
13 changes: 13 additions & 0 deletions playground/index.html
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions playground/package.json
@@ -0,0 +1,13 @@
{
"name": "playground",
"private": true,
"type": "module",
"scripts": {
"dev": "vite --open",
"dev:cjs": "vite --open --config vite.config.cjs"
},
"devDependencies": {
"eslint": "^8.54.0",
"vite": "^5.0.0"
}
}
2 changes: 2 additions & 0 deletions playground/src/main.js
@@ -0,0 +1,2 @@
console.log("Hello");
let a = 4;
5 changes: 5 additions & 0 deletions playground/vite.config.cjs
@@ -0,0 +1,5 @@
const eslint = require("..");

module.exports = {
plugins: [eslint()],
};
9 changes: 9 additions & 0 deletions playground/vite.config.js
@@ -0,0 +1,9 @@
import eslint from "..";

export default {
plugins: [
eslint({
formatter: console.log,
}),
],
};

0 comments on commit 4105adb

Please sign in to comment.