@rsbuild/plugin-eslint 1.3.0 → 2.0.1
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 +19 -12
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -2
- package/package.json +58 -63
- package/dist/index.cjs +0 -90
package/README.md
CHANGED
|
@@ -24,11 +24,18 @@ Install:
|
|
|
24
24
|
npm add @rsbuild/plugin-eslint -D
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
The latest version of this plugin only supports ESLint >= 9.0 and Node.js 20+.
|
|
28
|
+
If you need to use ESLint v8 or Node.js 18, install the `1.x` version instead:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm add @rsbuild/plugin-eslint@1 -D
|
|
32
|
+
```
|
|
33
|
+
|
|
27
34
|
Add plugin to your `rsbuild.config.ts`:
|
|
28
35
|
|
|
29
36
|
```ts
|
|
30
37
|
// rsbuild.config.ts
|
|
31
|
-
import { pluginEslint } from
|
|
38
|
+
import { pluginEslint } from '@rsbuild/plugin-eslint';
|
|
32
39
|
|
|
33
40
|
export default {
|
|
34
41
|
plugins: [pluginEslint()],
|
|
@@ -62,7 +69,7 @@ Enable ESLint checking only during production builds:
|
|
|
62
69
|
|
|
63
70
|
```js
|
|
64
71
|
pluginEslint({
|
|
65
|
-
enable: process.env.NODE_ENV ===
|
|
72
|
+
enable: process.env.NODE_ENV === 'production',
|
|
66
73
|
});
|
|
67
74
|
```
|
|
68
75
|
|
|
@@ -70,7 +77,7 @@ Enable ESLint checking only during development builds:
|
|
|
70
77
|
|
|
71
78
|
```js
|
|
72
79
|
pluginEslint({
|
|
73
|
-
enable: process.env.NODE_ENV ===
|
|
80
|
+
enable: process.env.NODE_ENV === 'development',
|
|
74
81
|
});
|
|
75
82
|
```
|
|
76
83
|
|
|
@@ -86,7 +93,7 @@ By default, ESLint only runs on the first environment to avoid running multiple
|
|
|
86
93
|
|
|
87
94
|
```js
|
|
88
95
|
pluginEslint({
|
|
89
|
-
environments: false // (default)
|
|
96
|
+
environments: false, // (default)
|
|
90
97
|
});
|
|
91
98
|
```
|
|
92
99
|
|
|
@@ -114,28 +121,28 @@ This is useful when different environments have different entry points and you w
|
|
|
114
121
|
|
|
115
122
|
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
123
|
|
|
117
|
-
- **Type:** [Options](https://github.com/rstackjs/eslint-rspack-plugin
|
|
124
|
+
- **Type:** [Options](https://github.com/rstackjs/eslint-rspack-plugin#options)
|
|
118
125
|
- **Default:**
|
|
119
126
|
|
|
120
127
|
```ts
|
|
121
128
|
const defaultOptions = {
|
|
122
|
-
extensions: [
|
|
129
|
+
extensions: ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx', 'mts', 'cts'],
|
|
123
130
|
exclude: [
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
'node_modules',
|
|
132
|
+
'dist', // -> rsbuildConfig.output.distPath.root
|
|
126
133
|
],
|
|
127
134
|
};
|
|
128
135
|
```
|
|
129
136
|
|
|
130
137
|
The `eslintPluginOptions` object will be shallowly merged with the default configuration object.
|
|
131
138
|
|
|
132
|
-
- For
|
|
139
|
+
- `eslint-rspack-plugin` v5 uses flat config by default. For legacy `.eslintrc` config, set `configType: 'eslintrc'`:
|
|
133
140
|
|
|
134
141
|
```ts
|
|
135
142
|
pluginEslint({
|
|
136
143
|
eslintPluginOptions: {
|
|
137
144
|
cwd: __dirname,
|
|
138
|
-
configType:
|
|
145
|
+
configType: 'eslintrc',
|
|
139
146
|
},
|
|
140
147
|
});
|
|
141
148
|
```
|
|
@@ -145,7 +152,7 @@ pluginEslint({
|
|
|
145
152
|
```ts
|
|
146
153
|
pluginEslint({
|
|
147
154
|
eslintPluginOptions: {
|
|
148
|
-
exclude: [
|
|
155
|
+
exclude: ['node_modules', 'dist', './src/foo.js'],
|
|
149
156
|
},
|
|
150
157
|
});
|
|
151
158
|
```
|
|
@@ -155,7 +162,7 @@ pluginEslint({
|
|
|
155
162
|
```ts
|
|
156
163
|
pluginEslint({
|
|
157
164
|
eslintPluginOptions: {
|
|
158
|
-
extensions: [
|
|
165
|
+
extensions: ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx', 'mts', 'cts', 'vue'],
|
|
159
166
|
},
|
|
160
167
|
});
|
|
161
168
|
```
|
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,59 @@
|
|
|
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
|
-
"publishConfig": {
|
|
61
|
-
"access": "public",
|
|
62
|
-
"registry": "https://registry.npmjs.org/"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
2
|
+
"name": "@rsbuild/plugin-eslint",
|
|
3
|
+
"version": "2.0.1",
|
|
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.20.2"
|
|
19
|
+
},
|
|
20
|
+
"simple-git-hooks": {
|
|
21
|
+
"pre-commit": "pnpm run lint:write"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"eslint-rspack-plugin": "5.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@playwright/test": "^1.60.0",
|
|
28
|
+
"@rsbuild/core": "^2.0.7",
|
|
29
|
+
"@rslib/core": "^0.21.5",
|
|
30
|
+
"@rslint/core": "^0.5.3",
|
|
31
|
+
"@types/node": "^24.12.4",
|
|
32
|
+
"eslint": "^10.4.0",
|
|
33
|
+
"playwright": "^1.60.0",
|
|
34
|
+
"prettier": "^3.8.3",
|
|
35
|
+
"simple-git-hooks": "^2.13.1",
|
|
36
|
+
"typescript": "6.0.3"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@rsbuild/core": "^1.0.0 || ^2.0.0-0",
|
|
40
|
+
"eslint": "^9.0.0 || ^10.0.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"@rsbuild/core": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public",
|
|
49
|
+
"registry": "https://registry.npmjs.org/"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "rslib",
|
|
53
|
+
"dev": "rslib -w",
|
|
54
|
+
"lint": "rslint && prettier -c .",
|
|
55
|
+
"lint:write": "rslint --fix && prettier -w .",
|
|
56
|
+
"test": "playwright test",
|
|
57
|
+
"bump": "pnpx bumpp"
|
|
58
|
+
}
|
|
59
|
+
}
|
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 ("u" > 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 __rspack_i in __webpack_exports__)if (-1 === [
|
|
85
|
-
"PLUGIN_ESLINT_NAME",
|
|
86
|
-
"pluginEslint"
|
|
87
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
88
|
-
Object.defineProperty(exports, '__esModule', {
|
|
89
|
-
value: true
|
|
90
|
-
});
|