@rsbuild/plugin-eslint 1.0.4 → 1.1.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 CHANGED
@@ -4,13 +4,18 @@ 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" />
10
12
  </a>
11
13
  <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
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>
12
15
  </p>
13
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
+
14
19
  ## Usage
15
20
 
16
21
  Install:
package/dist/index.cjs CHANGED
@@ -1,72 +1,103 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- PLUGIN_ESLINT_NAME: () => PLUGIN_ESLINT_NAME,
34
- pluginEslint: () => pluginEslint
35
- });
36
- module.exports = __toCommonJS(src_exports);
37
- var import_node_path = __toESM(require("path"), 1);
38
- var PLUGIN_ESLINT_NAME = "rsbuild:eslint";
39
- var pluginEslint = (options = {}) => ({
40
- name: PLUGIN_ESLINT_NAME,
41
- setup(api) {
42
- const { enable = true, eslintPluginOptions } = options;
43
- if (!enable) {
44
- return;
2
+ var __webpack_modules__ = {
3
+ "eslint-rspack-plugin": function(module) {
4
+ module.exports = import("eslint-rspack-plugin");
45
5
  }
46
- api.modifyBundlerChain(async (chain, { environment }) => {
47
- const { distPath } = environment;
48
- if (environment.index !== 0) {
49
- return;
50
- }
51
- const { default: ESLintPlugin } = await import("eslint-rspack-plugin");
52
- const defaultOptions = {
53
- extensions: ["js", "jsx", "mjs", "cjs", "ts", "tsx", "mts", "cts"],
54
- exclude: [
55
- "node_modules",
56
- import_node_path.default.relative(api.context.rootPath, distPath)
57
- ]
58
- };
59
- chain.plugin("eslint").use(ESLintPlugin, [
60
- {
61
- ...defaultOptions,
62
- ...eslintPluginOptions
63
- }
64
- ]);
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
+ }
17
+ (()=>{
18
+ __webpack_require__.n = function(module) {
19
+ var getter = module && module.__esModule ? function() {
20
+ return module['default'];
21
+ } : function() {
22
+ return module;
23
+ };
24
+ __webpack_require__.d(getter, {
25
+ a: getter
26
+ });
27
+ return getter;
28
+ };
29
+ })();
30
+ (()=>{
31
+ __webpack_require__.d = function(exports1, definition) {
32
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
33
+ enumerable: true,
34
+ get: definition[key]
35
+ });
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.o = function(obj, prop) {
40
+ return Object.prototype.hasOwnProperty.call(obj, prop);
41
+ };
42
+ })();
43
+ (()=>{
44
+ __webpack_require__.r = function(exports1) {
45
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
46
+ value: 'Module'
47
+ });
48
+ Object.defineProperty(exports1, '__esModule', {
49
+ value: true
50
+ });
51
+ };
52
+ })();
53
+ var __webpack_exports__ = {};
54
+ (()=>{
55
+ __webpack_require__.r(__webpack_exports__);
56
+ __webpack_require__.d(__webpack_exports__, {
57
+ PLUGIN_ESLINT_NAME: ()=>PLUGIN_ESLINT_NAME,
58
+ pluginEslint: ()=>pluginEslint
65
59
  });
66
- }
67
- });
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- PLUGIN_ESLINT_NAME,
71
- pluginEslint
60
+ const external_node_path_namespaceObject = require("node:path");
61
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
62
+ const PLUGIN_ESLINT_NAME = 'rsbuild:eslint';
63
+ const pluginEslint = (options = {})=>({
64
+ name: PLUGIN_ESLINT_NAME,
65
+ setup (api) {
66
+ const { enable = true, eslintPluginOptions } = options;
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', {
102
+ value: true
72
103
  });
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
- import { Options } from 'eslint-rspack-plugin';
3
-
4
- type PluginEslintOptions = {
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import type { Options } from 'eslint-rspack-plugin';
3
+ export type PluginEslintOptions = {
5
4
  /**
6
5
  * Whether to enable ESLint checking.
7
6
  * @default true
@@ -13,7 +12,5 @@ type PluginEslintOptions = {
13
12
  */
14
13
  eslintPluginOptions?: Options;
15
14
  };
16
- declare const PLUGIN_ESLINT_NAME = "rsbuild:eslint";
17
- declare const pluginEslint: (options?: PluginEslintOptions) => RsbuildPlugin;
18
-
19
- export { PLUGIN_ESLINT_NAME, type PluginEslintOptions, pluginEslint };
15
+ export declare const PLUGIN_ESLINT_NAME = "rsbuild:eslint";
16
+ export declare const pluginEslint: (options?: PluginEslintOptions) => RsbuildPlugin;
package/dist/index.js CHANGED
@@ -1,36 +1,38 @@
1
- // src/index.ts
2
- import path from "node:path";
3
- var PLUGIN_ESLINT_NAME = "rsbuild:eslint";
4
- var pluginEslint = (options = {}) => ({
5
- name: PLUGIN_ESLINT_NAME,
6
- setup(api) {
7
- const { enable = true, eslintPluginOptions } = options;
8
- if (!enable) {
9
- return;
10
- }
11
- api.modifyBundlerChain(async (chain, { environment }) => {
12
- const { distPath } = environment;
13
- if (environment.index !== 0) {
14
- return;
15
- }
16
- const { default: ESLintPlugin } = await import("eslint-rspack-plugin");
17
- const defaultOptions = {
18
- extensions: ["js", "jsx", "mjs", "cjs", "ts", "tsx", "mts", "cts"],
19
- exclude: [
20
- "node_modules",
21
- path.relative(api.context.rootPath, distPath)
22
- ]
23
- };
24
- chain.plugin("eslint").use(ESLintPlugin, [
25
- {
26
- ...defaultOptions,
27
- ...eslintPluginOptions
1
+ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
2
+ const PLUGIN_ESLINT_NAME = 'rsbuild:eslint';
3
+ const pluginEslint = (options = {})=>({
4
+ name: PLUGIN_ESLINT_NAME,
5
+ setup (api) {
6
+ const { enable = true, eslintPluginOptions } = options;
7
+ if (!enable) return;
8
+ api.modifyBundlerChain(async (chain, { environment })=>{
9
+ const { distPath } = environment;
10
+ if (0 !== environment.index) return;
11
+ const ESLintPluginModule = await import("eslint-rspack-plugin");
12
+ const ESLintPlugin = ESLintPluginModule.default || ESLintPluginModule;
13
+ const defaultOptions = {
14
+ extensions: [
15
+ 'js',
16
+ 'jsx',
17
+ 'mjs',
18
+ 'cjs',
19
+ 'ts',
20
+ 'tsx',
21
+ 'mts',
22
+ 'cts'
23
+ ],
24
+ exclude: [
25
+ 'node_modules',
26
+ __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(api.context.rootPath, distPath)
27
+ ]
28
+ };
29
+ chain.plugin('eslint').use(ESLintPlugin, [
30
+ {
31
+ ...defaultOptions,
32
+ ...eslintPluginOptions
33
+ }
34
+ ]);
35
+ });
28
36
  }
29
- ]);
30
37
  });
31
- }
32
- });
33
- export {
34
- PLUGIN_ESLINT_NAME,
35
- pluginEslint
36
- };
38
+ export { PLUGIN_ESLINT_NAME, pluginEslint };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-eslint",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "repository": "https://github.com/rspack-contrib/rsbuild-plugin-eslint",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,8 +16,8 @@
16
16
  "types": "./dist/index.d.ts",
17
17
  "files": ["dist"],
18
18
  "scripts": {
19
- "build": "tsup",
20
- "dev": "tsup --watch",
19
+ "build": "rslib build",
20
+ "dev": "rslib build --watch",
21
21
  "lint": "biome check .",
22
22
  "lint:write": "biome check . --write",
23
23
  "prepare": "simple-git-hooks && npm run build",
@@ -33,23 +33,22 @@
33
33
  ]
34
34
  },
35
35
  "dependencies": {
36
- "eslint-rspack-plugin": "^4.2.1",
37
- "webpack": "^5.95.0"
36
+ "eslint-rspack-plugin": "^4.2.1"
38
37
  },
39
38
  "devDependencies": {
40
- "@biomejs/biome": "^1.9.2",
41
- "@playwright/test": "^1.47.2",
42
- "@rsbuild/core": "^1.0.8",
43
- "@types/node": "^20.16.10",
44
- "eslint": "^9.11.1",
39
+ "@biomejs/biome": "^1.9.4",
40
+ "@playwright/test": "^1.50.1",
41
+ "@rsbuild/core": "^1.2.3",
42
+ "@rslib/core": "^0.4.0",
43
+ "@types/node": "^22.13.0",
44
+ "eslint": "^9.19.0",
45
45
  "nano-staged": "^0.8.0",
46
- "playwright": "^1.47.2",
46
+ "playwright": "^1.50.1",
47
47
  "simple-git-hooks": "^2.11.1",
48
- "tsup": "^8.3.0",
49
- "typescript": "^5.6.2"
48
+ "typescript": "^5.7.3"
50
49
  },
51
50
  "peerDependencies": {
52
- "@rsbuild/core": "1.x || ^1.0.1-beta.0",
51
+ "@rsbuild/core": "1.x",
53
52
  "eslint": "^8.0.0 || ^9.0.0"
54
53
  },
55
54
  "peerDependenciesMeta": {
@@ -57,7 +56,7 @@
57
56
  "optional": true
58
57
  }
59
58
  },
60
- "packageManager": "pnpm@9.11.0",
59
+ "packageManager": "pnpm@9.15.4",
61
60
  "publishConfig": {
62
61
  "access": "public",
63
62
  "registry": "https://registry.npmjs.org/"
package/dist/index.d.cts DELETED
@@ -1,19 +0,0 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
- import { Options } from 'eslint-rspack-plugin';
3
-
4
- type PluginEslintOptions = {
5
- /**
6
- * Whether to enable ESLint checking.
7
- * @default true
8
- */
9
- enable?: boolean;
10
- /**
11
- * To modify the options of `eslint-rspack-plugin`.
12
- * @see https://github.com/rspack-contrib/eslint-rspack-plugin
13
- */
14
- eslintPluginOptions?: Options;
15
- };
16
- declare const PLUGIN_ESLINT_NAME = "rsbuild:eslint";
17
- declare const pluginEslint: (options?: PluginEslintOptions) => RsbuildPlugin;
18
-
19
- export { PLUGIN_ESLINT_NAME, type PluginEslintOptions, pluginEslint };