@rsbuild/plugin-eslint 1.1.1 → 1.2.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 +36 -0
- package/dist/index.cjs +60 -73
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -4
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -74,6 +74,42 @@ pluginEslint({
|
|
|
74
74
|
});
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
### environments
|
|
78
|
+
|
|
79
|
+
Control which environments to run ESLint on when using [Rsbuild's multi-environment builds](https://rsbuild.dev/guide/advanced/environments).
|
|
80
|
+
|
|
81
|
+
- **Type:** `'all' | boolean | string[]`
|
|
82
|
+
- **Default:** `false`
|
|
83
|
+
- **Example:**
|
|
84
|
+
|
|
85
|
+
By default, ESLint only runs on the first environment to avoid running multiple times:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
pluginEslint({
|
|
89
|
+
environments: false // (default)
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Run ESLint on all environments:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
pluginEslint({
|
|
97
|
+
environments: 'all',
|
|
98
|
+
// or
|
|
99
|
+
environments: true,
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Run ESLint on specific environments by name:
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
pluginEslint({
|
|
107
|
+
environments: ['web', 'node'],
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This is useful when different environments have different entry points and you want to ensure all files are linted. Note that when set to `'all'` or `true`, ESLint will run separately for each environment, which may increase build time.
|
|
112
|
+
|
|
77
113
|
### eslintPluginOptions
|
|
78
114
|
|
|
79
115
|
To modify the options of `eslint-rspack-plugin`, please refer to [eslint-rspack-plugin - README](https://github.com/rspack-contrib/eslint-rspack-plugin#readme) to learn about available options.
|
package/dist/index.cjs
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
"eslint-rspack-plugin": function(module) {
|
|
4
|
-
module.exports = import("eslint-rspack-plugin");
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
var __webpack_module_cache__ = {};
|
|
8
|
-
function __webpack_require__(moduleId) {
|
|
9
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
-
exports: {}
|
|
13
|
-
};
|
|
14
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
-
return module.exports;
|
|
16
|
-
}
|
|
2
|
+
var __webpack_require__ = {};
|
|
17
3
|
(()=>{
|
|
18
|
-
__webpack_require__.n =
|
|
19
|
-
var getter = module && module.__esModule ?
|
|
20
|
-
return module['default'];
|
|
21
|
-
} : function() {
|
|
22
|
-
return module;
|
|
23
|
-
};
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
24
6
|
__webpack_require__.d(getter, {
|
|
25
7
|
a: getter
|
|
26
8
|
});
|
|
@@ -28,7 +10,7 @@ function __webpack_require__(moduleId) {
|
|
|
28
10
|
};
|
|
29
11
|
})();
|
|
30
12
|
(()=>{
|
|
31
|
-
__webpack_require__.d =
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
32
14
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
33
15
|
enumerable: true,
|
|
34
16
|
get: definition[key]
|
|
@@ -36,12 +18,10 @@ function __webpack_require__(moduleId) {
|
|
|
36
18
|
};
|
|
37
19
|
})();
|
|
38
20
|
(()=>{
|
|
39
|
-
__webpack_require__.o =
|
|
40
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
41
|
-
};
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
42
22
|
})();
|
|
43
23
|
(()=>{
|
|
44
|
-
__webpack_require__.r =
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
45
25
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
46
26
|
value: 'Module'
|
|
47
27
|
});
|
|
@@ -51,53 +31,60 @@ function __webpack_require__(moduleId) {
|
|
|
51
31
|
};
|
|
52
32
|
})();
|
|
53
33
|
var __webpack_exports__ = {};
|
|
54
|
-
(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
}
|
|
59
81
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (!enable) return;
|
|
68
|
-
api.modifyBundlerChain(async (chain, { environment })=>{
|
|
69
|
-
const { distPath } = environment;
|
|
70
|
-
if (0 !== environment.index) return;
|
|
71
|
-
const ESLintPluginModule = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "eslint-rspack-plugin"));
|
|
72
|
-
const ESLintPlugin = ESLintPluginModule.default || ESLintPluginModule;
|
|
73
|
-
const defaultOptions = {
|
|
74
|
-
extensions: [
|
|
75
|
-
'js',
|
|
76
|
-
'jsx',
|
|
77
|
-
'mjs',
|
|
78
|
-
'cjs',
|
|
79
|
-
'ts',
|
|
80
|
-
'tsx',
|
|
81
|
-
'mts',
|
|
82
|
-
'cts'
|
|
83
|
-
],
|
|
84
|
-
exclude: [
|
|
85
|
-
'node_modules',
|
|
86
|
-
external_node_path_default().relative(api.context.rootPath, distPath)
|
|
87
|
-
]
|
|
88
|
-
};
|
|
89
|
-
chain.plugin('eslint').use(ESLintPlugin, [
|
|
90
|
-
{
|
|
91
|
-
...defaultOptions,
|
|
92
|
-
...eslintPluginOptions
|
|
93
|
-
}
|
|
94
|
-
]);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
})();
|
|
99
|
-
var __webpack_export_target__ = exports;
|
|
100
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
101
|
-
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
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', {
|
|
102
89
|
value: true
|
|
103
90
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export type PluginEslintOptions = {
|
|
|
11
11
|
* @see https://github.com/rspack-contrib/eslint-rspack-plugin
|
|
12
12
|
*/
|
|
13
13
|
eslintPluginOptions?: Options;
|
|
14
|
+
/**
|
|
15
|
+
* Control which environments to run ESLint on.
|
|
16
|
+
* - `false` or `undefined`: Only run on the first environment (default)
|
|
17
|
+
* - `true` or `'all'`: Run on all environments
|
|
18
|
+
* - `string[]`: Run on specific environments by name (e.g., ['web', 'node'])
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
environments?: 'all' | boolean | string[];
|
|
14
22
|
};
|
|
15
23
|
export declare const PLUGIN_ESLINT_NAME = "rsbuild:eslint";
|
|
16
24
|
export declare const pluginEslint: (options?: PluginEslintOptions) => RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import node_path from "node:path";
|
|
2
2
|
const PLUGIN_ESLINT_NAME = 'rsbuild:eslint';
|
|
3
3
|
const pluginEslint = (options = {})=>({
|
|
4
4
|
name: PLUGIN_ESLINT_NAME,
|
|
5
5
|
setup (api) {
|
|
6
|
-
const { enable = true, eslintPluginOptions } = options;
|
|
6
|
+
const { enable = true, eslintPluginOptions, environments = false } = options;
|
|
7
7
|
if (!enable) return;
|
|
8
8
|
api.modifyBundlerChain(async (chain, { environment })=>{
|
|
9
9
|
const { distPath } = environment;
|
|
10
|
-
|
|
10
|
+
const shouldRun = ()=>{
|
|
11
|
+
if (Array.isArray(environments)) return environments.includes(environment.name);
|
|
12
|
+
if (true === environments || 'all' === environments) return true;
|
|
13
|
+
return 0 === environment.index;
|
|
14
|
+
};
|
|
15
|
+
if (!shouldRun()) return;
|
|
11
16
|
const ESLintPluginModule = await import("eslint-rspack-plugin");
|
|
12
17
|
const ESLintPlugin = ESLintPluginModule.default || ESLintPluginModule;
|
|
13
18
|
const defaultOptions = {
|
|
@@ -23,7 +28,7 @@ const pluginEslint = (options = {})=>({
|
|
|
23
28
|
],
|
|
24
29
|
exclude: [
|
|
25
30
|
'node_modules',
|
|
26
|
-
|
|
31
|
+
node_path.relative(api.context.rootPath, distPath)
|
|
27
32
|
]
|
|
28
33
|
};
|
|
29
34
|
chain.plugin('eslint').use(ESLintPlugin, [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-eslint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"repository": "https://github.com/rspack-contrib/rsbuild-plugin-eslint",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"eslint-rspack-plugin": "^4.
|
|
36
|
+
"eslint-rspack-plugin": "^4.3.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@biomejs/biome": "^1.9.4",
|
|
40
|
-
"@playwright/test": "^1.
|
|
41
|
-
"@rsbuild/core": "^1.
|
|
42
|
-
"@rslib/core": "^0.
|
|
43
|
-
"@types/node": "^
|
|
44
|
-
"eslint": "^9.
|
|
45
|
-
"nano-staged": "^0.
|
|
46
|
-
"playwright": "^1.
|
|
47
|
-
"simple-git-hooks": "^2.
|
|
48
|
-
"typescript": "^5.
|
|
40
|
+
"@playwright/test": "^1.57.0",
|
|
41
|
+
"@rsbuild/core": "^1.6.10",
|
|
42
|
+
"@rslib/core": "^0.18.2",
|
|
43
|
+
"@types/node": "^24.10.1",
|
|
44
|
+
"eslint": "^9.39.1",
|
|
45
|
+
"nano-staged": "^0.9.0",
|
|
46
|
+
"playwright": "^1.57.0",
|
|
47
|
+
"simple-git-hooks": "^2.13.1",
|
|
48
|
+
"typescript": "^5.9.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@rsbuild/core": "1.x",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"optional": true
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"packageManager": "pnpm@
|
|
59
|
+
"packageManager": "pnpm@10.24.0",
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public",
|
|
62
62
|
"registry": "https://registry.npmjs.org/"
|