@rsbuild/plugin-eslint 1.2.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -13
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -2
- package/package.json +59 -62
- package/dist/index.cjs +0 -90
package/README.md
CHANGED
|
@@ -14,10 +14,15 @@ The plugin has integrated [eslint-rspack-plugin](https://www.npmjs.com/package/e
|
|
|
14
14
|
<a href="https://npmcharts.com/compare/@rsbuild/plugin-eslint?minimal=true"><img src="https://img.shields.io/npm/dm/@rsbuild/plugin-eslint.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
|
-
<img width="1496"
|
|
17
|
+
<img width="1496" src="https://github.com/user-attachments/assets/ee4b1915-92ce-4032-834d-b2321f02f1d2" />
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
+
Requirements:
|
|
22
|
+
|
|
23
|
+
- Node.js >= 20.19.0
|
|
24
|
+
- ESLint >= 9
|
|
25
|
+
|
|
21
26
|
Install:
|
|
22
27
|
|
|
23
28
|
```bash
|
|
@@ -28,7 +33,7 @@ Add plugin to your `rsbuild.config.ts`:
|
|
|
28
33
|
|
|
29
34
|
```ts
|
|
30
35
|
// rsbuild.config.ts
|
|
31
|
-
import { pluginEslint } from
|
|
36
|
+
import { pluginEslint } from '@rsbuild/plugin-eslint';
|
|
32
37
|
|
|
33
38
|
export default {
|
|
34
39
|
plugins: [pluginEslint()],
|
|
@@ -62,7 +67,7 @@ Enable ESLint checking only during production builds:
|
|
|
62
67
|
|
|
63
68
|
```js
|
|
64
69
|
pluginEslint({
|
|
65
|
-
enable: process.env.NODE_ENV ===
|
|
70
|
+
enable: process.env.NODE_ENV === 'production',
|
|
66
71
|
});
|
|
67
72
|
```
|
|
68
73
|
|
|
@@ -70,7 +75,7 @@ Enable ESLint checking only during development builds:
|
|
|
70
75
|
|
|
71
76
|
```js
|
|
72
77
|
pluginEslint({
|
|
73
|
-
enable: process.env.NODE_ENV ===
|
|
78
|
+
enable: process.env.NODE_ENV === 'development',
|
|
74
79
|
});
|
|
75
80
|
```
|
|
76
81
|
|
|
@@ -86,7 +91,7 @@ By default, ESLint only runs on the first environment to avoid running multiple
|
|
|
86
91
|
|
|
87
92
|
```js
|
|
88
93
|
pluginEslint({
|
|
89
|
-
environments: false // (default)
|
|
94
|
+
environments: false, // (default)
|
|
90
95
|
});
|
|
91
96
|
```
|
|
92
97
|
|
|
@@ -114,28 +119,28 @@ This is useful when different environments have different entry points and you w
|
|
|
114
119
|
|
|
115
120
|
To modify the options of `eslint-rspack-plugin`, please refer to [eslint-rspack-plugin - README](https://github.com/rstackjs/eslint-rspack-plugin#readme) to learn about available options.
|
|
116
121
|
|
|
117
|
-
- **Type:** [Options](https://github.com/rstackjs/eslint-rspack-plugin
|
|
122
|
+
- **Type:** [Options](https://github.com/rstackjs/eslint-rspack-plugin#options)
|
|
118
123
|
- **Default:**
|
|
119
124
|
|
|
120
125
|
```ts
|
|
121
126
|
const defaultOptions = {
|
|
122
|
-
extensions: [
|
|
127
|
+
extensions: ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx', 'mts', 'cts'],
|
|
123
128
|
exclude: [
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
'node_modules',
|
|
130
|
+
'dist', // -> rsbuildConfig.output.distPath.root
|
|
126
131
|
],
|
|
127
132
|
};
|
|
128
133
|
```
|
|
129
134
|
|
|
130
135
|
The `eslintPluginOptions` object will be shallowly merged with the default configuration object.
|
|
131
136
|
|
|
132
|
-
-
|
|
137
|
+
- `eslint-rspack-plugin` v5 uses flat config by default. For legacy `.eslintrc` config, set `configType: 'eslintrc'`:
|
|
133
138
|
|
|
134
139
|
```ts
|
|
135
140
|
pluginEslint({
|
|
136
141
|
eslintPluginOptions: {
|
|
137
142
|
cwd: __dirname,
|
|
138
|
-
configType:
|
|
143
|
+
configType: 'eslintrc',
|
|
139
144
|
},
|
|
140
145
|
});
|
|
141
146
|
```
|
|
@@ -145,7 +150,7 @@ pluginEslint({
|
|
|
145
150
|
```ts
|
|
146
151
|
pluginEslint({
|
|
147
152
|
eslintPluginOptions: {
|
|
148
|
-
exclude: [
|
|
153
|
+
exclude: ['node_modules', 'dist', './src/foo.js'],
|
|
149
154
|
},
|
|
150
155
|
});
|
|
151
156
|
```
|
|
@@ -155,7 +160,7 @@ pluginEslint({
|
|
|
155
160
|
```ts
|
|
156
161
|
pluginEslint({
|
|
157
162
|
eslintPluginOptions: {
|
|
158
|
-
extensions: [
|
|
163
|
+
extensions: ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx', 'mts', 'cts', 'vue'],
|
|
159
164
|
},
|
|
160
165
|
});
|
|
161
166
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
import type
|
|
2
|
+
import type ESLintPlugin from 'eslint-rspack-plugin';
|
|
3
|
+
type ESLintPluginOptions = ConstructorParameters<typeof ESLintPlugin>[0];
|
|
3
4
|
export type PluginEslintOptions = {
|
|
4
5
|
/**
|
|
5
6
|
* Whether to enable ESLint checking.
|
|
@@ -10,7 +11,7 @@ export type PluginEslintOptions = {
|
|
|
10
11
|
* To modify the options of `eslint-rspack-plugin`.
|
|
11
12
|
* @see https://github.com/rstackjs/eslint-rspack-plugin
|
|
12
13
|
*/
|
|
13
|
-
eslintPluginOptions?:
|
|
14
|
+
eslintPluginOptions?: ESLintPluginOptions;
|
|
14
15
|
/**
|
|
15
16
|
* Control which environments to run ESLint on.
|
|
16
17
|
* - `false` or `undefined`: Only run on the first environment (default)
|
|
@@ -22,3 +23,4 @@ export type PluginEslintOptions = {
|
|
|
22
23
|
};
|
|
23
24
|
export declare const PLUGIN_ESLINT_NAME = "rsbuild:eslint";
|
|
24
25
|
export declare const pluginEslint: (options?: PluginEslintOptions) => RsbuildPlugin;
|
|
26
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -13,8 +13,7 @@ const pluginEslint = (options = {})=>({
|
|
|
13
13
|
return 0 === environment.index;
|
|
14
14
|
};
|
|
15
15
|
if (!shouldRun()) return;
|
|
16
|
-
const
|
|
17
|
-
const ESLintPlugin = ESLintPluginModule.default || ESLintPluginModule;
|
|
16
|
+
const { default: ESLintPlugin } = await import("eslint-rspack-plugin");
|
|
18
17
|
const defaultOptions = {
|
|
19
18
|
extensions: [
|
|
20
19
|
'js',
|
package/package.json
CHANGED
|
@@ -1,64 +1,61 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"access": "public",
|
|
62
|
-
"registry": "https://registry.npmjs.org/"
|
|
63
|
-
}
|
|
2
|
+
"name": "@rsbuild/plugin-eslint",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"repository": "https://github.com/rstackjs/rsbuild-plugin-eslint",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20.19.0"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rslib",
|
|
22
|
+
"dev": "rslib -w",
|
|
23
|
+
"lint": "rslint && prettier -c .",
|
|
24
|
+
"lint:write": "rslint --fix && prettier -w .",
|
|
25
|
+
"prepare": "simple-git-hooks && pnpm run build",
|
|
26
|
+
"test": "playwright test",
|
|
27
|
+
"bump": "pnpx bumpp"
|
|
28
|
+
},
|
|
29
|
+
"simple-git-hooks": {
|
|
30
|
+
"pre-commit": "pnpm run lint:write"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"eslint-rspack-plugin": "5.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@playwright/test": "^1.59.1",
|
|
37
|
+
"@rsbuild/core": "^2.0.5",
|
|
38
|
+
"@rslib/core": "^0.21.4",
|
|
39
|
+
"@rslint/core": "^0.5.2",
|
|
40
|
+
"@types/node": "^24.12.3",
|
|
41
|
+
"eslint": "^10.3.0",
|
|
42
|
+
"playwright": "^1.59.1",
|
|
43
|
+
"prettier": "^3.8.3",
|
|
44
|
+
"simple-git-hooks": "^2.13.1",
|
|
45
|
+
"typescript": "6.0.3"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@rsbuild/core": "^1.0.0 || ^2.0.0-0",
|
|
49
|
+
"eslint": "^9.0.0 || ^10.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"@rsbuild/core": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"packageManager": "pnpm@10.33.4",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public",
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
}
|
|
64
61
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
pluginEslint: ()=>pluginEslint,
|
|
37
|
-
PLUGIN_ESLINT_NAME: ()=>PLUGIN_ESLINT_NAME
|
|
38
|
-
});
|
|
39
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
40
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
41
|
-
const PLUGIN_ESLINT_NAME = 'rsbuild:eslint';
|
|
42
|
-
const pluginEslint = (options = {})=>({
|
|
43
|
-
name: PLUGIN_ESLINT_NAME,
|
|
44
|
-
setup (api) {
|
|
45
|
-
const { enable = true, eslintPluginOptions, environments = false } = options;
|
|
46
|
-
if (!enable) return;
|
|
47
|
-
api.modifyBundlerChain(async (chain, { environment })=>{
|
|
48
|
-
const { distPath } = environment;
|
|
49
|
-
const shouldRun = ()=>{
|
|
50
|
-
if (Array.isArray(environments)) return environments.includes(environment.name);
|
|
51
|
-
if (true === environments || 'all' === environments) return true;
|
|
52
|
-
return 0 === environment.index;
|
|
53
|
-
};
|
|
54
|
-
if (!shouldRun()) return;
|
|
55
|
-
const ESLintPluginModule = await import("eslint-rspack-plugin");
|
|
56
|
-
const ESLintPlugin = ESLintPluginModule.default || ESLintPluginModule;
|
|
57
|
-
const defaultOptions = {
|
|
58
|
-
extensions: [
|
|
59
|
-
'js',
|
|
60
|
-
'jsx',
|
|
61
|
-
'mjs',
|
|
62
|
-
'cjs',
|
|
63
|
-
'ts',
|
|
64
|
-
'tsx',
|
|
65
|
-
'mts',
|
|
66
|
-
'cts'
|
|
67
|
-
],
|
|
68
|
-
exclude: [
|
|
69
|
-
'node_modules',
|
|
70
|
-
external_node_path_default().relative(api.context.rootPath, distPath)
|
|
71
|
-
]
|
|
72
|
-
};
|
|
73
|
-
chain.plugin('eslint').use(ESLintPlugin, [
|
|
74
|
-
{
|
|
75
|
-
...defaultOptions,
|
|
76
|
-
...eslintPluginOptions
|
|
77
|
-
}
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
exports.PLUGIN_ESLINT_NAME = __webpack_exports__.PLUGIN_ESLINT_NAME;
|
|
83
|
-
exports.pluginEslint = __webpack_exports__.pluginEslint;
|
|
84
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
85
|
-
"PLUGIN_ESLINT_NAME",
|
|
86
|
-
"pluginEslint"
|
|
87
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
88
|
-
Object.defineProperty(exports, '__esModule', {
|
|
89
|
-
value: true
|
|
90
|
-
});
|