@rsbuild/plugin-eslint 1.1.0 → 1.1.2
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 +4 -0
- package/dist/index.cjs +60 -73
- package/dist/index.js +4 -5
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ An Rsbuild plugin to run ESLint checks during the compilation.
|
|
|
4
4
|
|
|
5
5
|
The plugin has integrated [eslint-rspack-plugin](https://www.npmjs.com/package/eslint-rspack-plugin) internally.
|
|
6
6
|
|
|
7
|
+
> We do not recommend using the `@rsbuild/plugin-eslint` plugin, as running ESLint during the build process will significantly increase the build time. Instead, we recommend using a separate `lint` command to run ESLint checks.
|
|
8
|
+
|
|
7
9
|
<p>
|
|
8
10
|
<a href="https://npmjs.com/package/@rsbuild/plugin-eslint">
|
|
9
11
|
<img src="https://img.shields.io/npm/v/@rsbuild/plugin-eslint?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
|
|
@@ -12,6 +14,8 @@ The plugin has integrated [eslint-rspack-plugin](https://www.npmjs.com/package/e
|
|
|
12
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>
|
|
13
15
|
</p>
|
|
14
16
|
|
|
17
|
+
<img width="1496" alt="Screenshot 2025-02-16 at 18 56 32" src="https://github.com/user-attachments/assets/ee4b1915-92ce-4032-834d-b2321f02f1d2" />
|
|
18
|
+
|
|
15
19
|
## Usage
|
|
16
20
|
|
|
17
21
|
Install:
|
package/dist/index.cjs
CHANGED
|
@@ -1,59 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
3
|
"eslint-rspack-plugin": function(module) {
|
|
4
|
-
module.exports = import("eslint-rspack-plugin")
|
|
4
|
+
module.exports = import("eslint-rspack-plugin").then(function(module) {
|
|
5
|
+
return module;
|
|
6
|
+
});
|
|
5
7
|
}
|
|
6
8
|
};
|
|
7
|
-
/************************************************************************/ // The module cache
|
|
8
9
|
var __webpack_module_cache__ = {};
|
|
9
|
-
// The require function
|
|
10
10
|
function __webpack_require__(moduleId) {
|
|
11
|
-
// Check if module is in cache
|
|
12
11
|
var cachedModule = __webpack_module_cache__[moduleId];
|
|
13
12
|
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
14
|
-
// Create a new module (and put it into the cache)
|
|
15
13
|
var module = __webpack_module_cache__[moduleId] = {
|
|
16
14
|
exports: {}
|
|
17
15
|
};
|
|
18
|
-
// Execute the module function
|
|
19
16
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
20
|
-
// Return the exports of the module
|
|
21
17
|
return module.exports;
|
|
22
18
|
}
|
|
23
|
-
/************************************************************************/ // webpack/runtime/compat_get_default_export
|
|
24
19
|
(()=>{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var getter = module && module.__esModule ? function() {
|
|
28
|
-
return module['default'];
|
|
29
|
-
} : function() {
|
|
30
|
-
return module;
|
|
31
|
-
};
|
|
20
|
+
__webpack_require__.n = (module)=>{
|
|
21
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
32
22
|
__webpack_require__.d(getter, {
|
|
33
23
|
a: getter
|
|
34
24
|
});
|
|
35
25
|
return getter;
|
|
36
26
|
};
|
|
37
27
|
})();
|
|
38
|
-
// webpack/runtime/define_property_getters
|
|
39
28
|
(()=>{
|
|
40
|
-
__webpack_require__.d =
|
|
29
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
41
30
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
42
31
|
enumerable: true,
|
|
43
32
|
get: definition[key]
|
|
44
33
|
});
|
|
45
34
|
};
|
|
46
35
|
})();
|
|
47
|
-
// webpack/runtime/has_own_property
|
|
48
36
|
(()=>{
|
|
49
|
-
__webpack_require__.o =
|
|
50
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
51
|
-
};
|
|
37
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
52
38
|
})();
|
|
53
|
-
// webpack/runtime/make_namespace_object
|
|
54
39
|
(()=>{
|
|
55
|
-
|
|
56
|
-
__webpack_require__.r = function(exports1) {
|
|
40
|
+
__webpack_require__.r = (exports1)=>{
|
|
57
41
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
58
42
|
value: 'Module'
|
|
59
43
|
});
|
|
@@ -62,55 +46,58 @@ function __webpack_require__(moduleId) {
|
|
|
62
46
|
});
|
|
63
47
|
};
|
|
64
48
|
})();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
__webpack_require__.r(__webpack_exports__);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
PLUGIN_ESLINT_NAME: ()=>/* binding */ PLUGIN_ESLINT_NAME
|
|
72
|
-
});
|
|
73
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
74
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
75
|
-
const PLUGIN_ESLINT_NAME = 'rsbuild:eslint';
|
|
76
|
-
const pluginEslint = (options = {})=>({
|
|
77
|
-
name: PLUGIN_ESLINT_NAME,
|
|
78
|
-
setup (api) {
|
|
79
|
-
const { enable = true, eslintPluginOptions } = options;
|
|
80
|
-
if (!enable) return;
|
|
81
|
-
api.modifyBundlerChain(async (chain, { environment })=>{
|
|
82
|
-
const { distPath } = environment;
|
|
83
|
-
// If there is multiple environment, only apply eslint plugin to the first target
|
|
84
|
-
// to avoid multiple eslint running at the same time
|
|
85
|
-
if (0 !== environment.index) return;
|
|
86
|
-
const { default: ESLintPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "eslint-rspack-plugin"));
|
|
87
|
-
const defaultOptions = {
|
|
88
|
-
extensions: [
|
|
89
|
-
'js',
|
|
90
|
-
'jsx',
|
|
91
|
-
'mjs',
|
|
92
|
-
'cjs',
|
|
93
|
-
'ts',
|
|
94
|
-
'tsx',
|
|
95
|
-
'mts',
|
|
96
|
-
'cts'
|
|
97
|
-
],
|
|
98
|
-
exclude: [
|
|
99
|
-
'node_modules',
|
|
100
|
-
external_node_path_default().relative(api.context.rootPath, distPath)
|
|
101
|
-
]
|
|
102
|
-
};
|
|
103
|
-
chain.plugin('eslint').use(ESLintPlugin, [
|
|
104
|
-
{
|
|
105
|
-
...defaultOptions,
|
|
106
|
-
...eslintPluginOptions
|
|
107
|
-
}
|
|
108
|
-
]);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
49
|
+
var __webpack_exports__ = {};
|
|
50
|
+
(()=>{
|
|
51
|
+
__webpack_require__.r(__webpack_exports__);
|
|
52
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
53
|
+
pluginEslint: ()=>pluginEslint,
|
|
54
|
+
PLUGIN_ESLINT_NAME: ()=>PLUGIN_ESLINT_NAME
|
|
111
55
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
56
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
57
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
58
|
+
const PLUGIN_ESLINT_NAME = 'rsbuild:eslint';
|
|
59
|
+
const pluginEslint = (options = {})=>({
|
|
60
|
+
name: PLUGIN_ESLINT_NAME,
|
|
61
|
+
setup (api) {
|
|
62
|
+
const { enable = true, eslintPluginOptions } = options;
|
|
63
|
+
if (!enable) return;
|
|
64
|
+
api.modifyBundlerChain(async (chain, { environment })=>{
|
|
65
|
+
const { distPath } = environment;
|
|
66
|
+
if (0 !== environment.index) return;
|
|
67
|
+
const ESLintPluginModule = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "eslint-rspack-plugin"));
|
|
68
|
+
const ESLintPlugin = ESLintPluginModule.default || ESLintPluginModule;
|
|
69
|
+
const defaultOptions = {
|
|
70
|
+
extensions: [
|
|
71
|
+
'js',
|
|
72
|
+
'jsx',
|
|
73
|
+
'mjs',
|
|
74
|
+
'cjs',
|
|
75
|
+
'ts',
|
|
76
|
+
'tsx',
|
|
77
|
+
'mts',
|
|
78
|
+
'cts'
|
|
79
|
+
],
|
|
80
|
+
exclude: [
|
|
81
|
+
'node_modules',
|
|
82
|
+
external_node_path_default().relative(api.context.rootPath, distPath)
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
chain.plugin('eslint').use(ESLintPlugin, [
|
|
86
|
+
{
|
|
87
|
+
...defaultOptions,
|
|
88
|
+
...eslintPluginOptions
|
|
89
|
+
}
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
})();
|
|
95
|
+
exports.PLUGIN_ESLINT_NAME = __webpack_exports__.PLUGIN_ESLINT_NAME;
|
|
96
|
+
exports.pluginEslint = __webpack_exports__.pluginEslint;
|
|
97
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
98
|
+
"PLUGIN_ESLINT_NAME",
|
|
99
|
+
"pluginEslint"
|
|
100
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
101
|
+
Object.defineProperty(exports, '__esModule', {
|
|
115
102
|
value: true
|
|
116
103
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
@@ -7,10 +7,9 @@ const pluginEslint = (options = {})=>({
|
|
|
7
7
|
if (!enable) return;
|
|
8
8
|
api.modifyBundlerChain(async (chain, { environment })=>{
|
|
9
9
|
const { distPath } = environment;
|
|
10
|
-
// If there is multiple environment, only apply eslint plugin to the first target
|
|
11
|
-
// to avoid multiple eslint running at the same time
|
|
12
10
|
if (0 !== environment.index) return;
|
|
13
|
-
const
|
|
11
|
+
const ESLintPluginModule = await import("eslint-rspack-plugin");
|
|
12
|
+
const ESLintPlugin = ESLintPluginModule.default || ESLintPluginModule;
|
|
14
13
|
const defaultOptions = {
|
|
15
14
|
extensions: [
|
|
16
15
|
'js',
|
|
@@ -24,7 +23,7 @@ const pluginEslint = (options = {})=>({
|
|
|
24
23
|
],
|
|
25
24
|
exclude: [
|
|
26
25
|
'node_modules',
|
|
27
|
-
|
|
26
|
+
node_path.relative(api.context.rootPath, distPath)
|
|
28
27
|
]
|
|
29
28
|
};
|
|
30
29
|
chain.plugin('eslint').use(ESLintPlugin, [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-eslint",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"repository": "https://github.com/rspack-contrib/rsbuild-plugin-eslint",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,15 +37,15 @@
|
|
|
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": "^22.
|
|
44
|
-
"eslint": "^9.
|
|
40
|
+
"@playwright/test": "^1.54.1",
|
|
41
|
+
"@rsbuild/core": "^1.4.12",
|
|
42
|
+
"@rslib/core": "^0.11.0",
|
|
43
|
+
"@types/node": "^22.17.0",
|
|
44
|
+
"eslint": "^9.32.0",
|
|
45
45
|
"nano-staged": "^0.8.0",
|
|
46
|
-
"playwright": "^1.
|
|
47
|
-
"simple-git-hooks": "^2.
|
|
48
|
-
"typescript": "^5.
|
|
46
|
+
"playwright": "^1.54.1",
|
|
47
|
+
"simple-git-hooks": "^2.13.1",
|
|
48
|
+
"typescript": "^5.9.2"
|
|
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.14.0",
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public",
|
|
62
62
|
"registry": "https://registry.npmjs.org/"
|