@rsbuild/plugin-eslint 1.0.3 → 1.1.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 CHANGED
@@ -9,6 +9,7 @@ The plugin has integrated [eslint-rspack-plugin](https://www.npmjs.com/package/e
9
9
  <img src="https://img.shields.io/npm/v/@rsbuild/plugin-eslint?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
10
10
  </a>
11
11
  <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
12
+ <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
13
  </p>
13
14
 
14
15
  ## Usage
@@ -71,9 +72,9 @@ pluginEslint({
71
72
 
72
73
  ### eslintPluginOptions
73
74
 
74
- To modify the options of `eslint-rspack-plugin`, please refer to [eslint-rspack-plugin - README](https://github.com/webpack-contrib/eslint-rspack-plugin#readme) to learn about available options.
75
+ 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.
75
76
 
76
- - **Type:** [Options](https://github.com/webpack-contrib/eslint-rspack-plugin/blob/master/types/options.d.ts)
77
+ - **Type:** [Options](https://github.com/rspack-contrib/eslint-rspack-plugin/blob/master/types/options.d.ts)
77
78
  - **Default:**
78
79
 
79
80
  ```ts
package/dist/index.cjs CHANGED
@@ -1,72 +1,116 @@
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;
2
+ var __webpack_modules__ = {
3
+ "eslint-rspack-plugin": function(module) {
4
+ module.exports = import("eslint-rspack-plugin");
5
+ }
19
6
  };
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
7
+ /************************************************************************/ // The module cache
8
+ var __webpack_module_cache__ = {};
9
+ // The require function
10
+ function __webpack_require__(moduleId) {
11
+ // Check if module is in cache
12
+ var cachedModule = __webpack_module_cache__[moduleId];
13
+ if (void 0 !== cachedModule) return cachedModule.exports;
14
+ // Create a new module (and put it into the cache)
15
+ var module = __webpack_module_cache__[moduleId] = {
16
+ exports: {}
17
+ };
18
+ // Execute the module function
19
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
20
+ // Return the exports of the module
21
+ return module.exports;
22
+ }
23
+ /************************************************************************/ // webpack/runtime/compat_get_default_export
24
+ (()=>{
25
+ // getDefaultExport function for compatibility with non-ESM modules
26
+ __webpack_require__.n = function(module) {
27
+ var getter = module && module.__esModule ? function() {
28
+ return module['default'];
29
+ } : function() {
30
+ return module;
31
+ };
32
+ __webpack_require__.d(getter, {
33
+ a: getter
34
+ });
35
+ return getter;
36
+ };
37
+ })();
38
+ // webpack/runtime/define_property_getters
39
+ (()=>{
40
+ __webpack_require__.d = function(exports1, definition) {
41
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
42
+ enumerable: true,
43
+ get: definition[key]
44
+ });
45
+ };
46
+ })();
47
+ // webpack/runtime/has_own_property
48
+ (()=>{
49
+ __webpack_require__.o = function(obj, prop) {
50
+ return Object.prototype.hasOwnProperty.call(obj, prop);
51
+ };
52
+ })();
53
+ // webpack/runtime/make_namespace_object
54
+ (()=>{
55
+ // define __esModule on exports
56
+ __webpack_require__.r = function(exports1) {
57
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
58
+ value: 'Module'
59
+ });
60
+ Object.defineProperty(exports1, '__esModule', {
61
+ value: true
62
+ });
63
+ };
64
+ })();
65
+ /************************************************************************/ var __webpack_exports__ = {};
66
+ // ESM COMPAT FLAG
67
+ __webpack_require__.r(__webpack_exports__);
68
+ // EXPORTS
69
+ __webpack_require__.d(__webpack_exports__, {
70
+ pluginEslint: ()=>/* binding */ pluginEslint,
71
+ PLUGIN_ESLINT_NAME: ()=>/* binding */ PLUGIN_ESLINT_NAME
35
72
  });
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;
45
- }
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
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
+ });
63
110
  }
64
- ]);
65
111
  });
66
- }
67
- });
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- PLUGIN_ESLINT_NAME,
71
- pluginEslint
112
+ var __webpack_export_target__ = exports;
113
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
114
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
115
+ value: true
72
116
  });
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,39 @@
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__ 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 there is multiple environment, only apply eslint plugin to the first target
11
+ // to avoid multiple eslint running at the same time
12
+ if (0 !== environment.index) return;
13
+ const { default: ESLintPlugin } = await import("eslint-rspack-plugin");
14
+ const defaultOptions = {
15
+ extensions: [
16
+ 'js',
17
+ 'jsx',
18
+ 'mjs',
19
+ 'cjs',
20
+ 'ts',
21
+ 'tsx',
22
+ 'mts',
23
+ 'cts'
24
+ ],
25
+ exclude: [
26
+ 'node_modules',
27
+ __WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(api.context.rootPath, distPath)
28
+ ]
29
+ };
30
+ chain.plugin('eslint').use(ESLintPlugin, [
31
+ {
32
+ ...defaultOptions,
33
+ ...eslintPluginOptions
34
+ }
35
+ ]);
36
+ });
28
37
  }
29
- ]);
30
38
  });
31
- }
32
- });
33
- export {
34
- PLUGIN_ESLINT_NAME,
35
- pluginEslint
36
- };
39
+ export { PLUGIN_ESLINT_NAME, pluginEslint };
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
1
  {
2
- "name": "@rsbuild/plugin-eslint",
3
- "version": "1.0.3",
4
- "repository": "https://github.com/rspack-contrib/rsbuild-plugin-eslint",
5
- "license": "MIT",
6
- "type": "module",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js",
11
- "require": "./dist/index.cjs"
12
- }
13
- },
14
- "main": "./dist/index.js",
15
- "module": "./dist/index.mjs",
16
- "types": "./dist/index.d.ts",
17
- "files": [
18
- "dist"
19
- ],
20
- "simple-git-hooks": {
21
- "pre-commit": "npx nano-staged"
22
- },
23
- "nano-staged": {
24
- "*.{js,jsx,ts,tsx,mjs,cjs}": [
25
- "biome check --write --no-errors-on-unmatched"
26
- ]
27
- },
28
- "dependencies": {
29
- "eslint-rspack-plugin": "^4.2.0",
30
- "webpack": "^5.94.0"
31
- },
32
- "devDependencies": {
33
- "@biomejs/biome": "^1.8.3",
34
- "@playwright/test": "^1.46.1",
35
- "@rsbuild/core": "^1.0.1",
36
- "@types/node": "^20.16.2",
37
- "eslint": "^9.9.1",
38
- "nano-staged": "^0.8.0",
39
- "playwright": "^1.46.1",
40
- "simple-git-hooks": "^2.11.1",
41
- "tsup": "^8.2.4",
42
- "typescript": "^5.5.4"
43
- },
44
- "peerDependencies": {
45
- "@rsbuild/core": "1.x || ^1.0.1-beta.0",
46
- "eslint": "^8.0.0 || ^9.0.0"
47
- },
48
- "peerDependenciesMeta": {
49
- "@rsbuild/core": {
50
- "optional": true
51
- }
52
- },
53
- "publishConfig": {
54
- "access": "public",
55
- "registry": "https://registry.npmjs.org/"
56
- },
57
- "scripts": {
58
- "build": "tsup",
59
- "dev": "tsup --watch",
60
- "lint": "biome check .",
61
- "lint:write": "biome check . --write",
62
- "test": "playwright test"
63
- }
64
- }
2
+ "name": "@rsbuild/plugin-eslint",
3
+ "version": "1.1.0",
4
+ "repository": "https://github.com/rspack-contrib/rsbuild-plugin-eslint",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs"
12
+ }
13
+ },
14
+ "main": "./dist/index.js",
15
+ "module": "./dist/index.mjs",
16
+ "types": "./dist/index.d.ts",
17
+ "files": ["dist"],
18
+ "scripts": {
19
+ "build": "rslib build",
20
+ "dev": "rslib build --watch",
21
+ "lint": "biome check .",
22
+ "lint:write": "biome check . --write",
23
+ "prepare": "simple-git-hooks && npm run build",
24
+ "test": "playwright test",
25
+ "bump": "npx bumpp"
26
+ },
27
+ "simple-git-hooks": {
28
+ "pre-commit": "npx nano-staged"
29
+ },
30
+ "nano-staged": {
31
+ "*.{js,jsx,ts,tsx,mjs,cjs}": [
32
+ "biome check --write --no-errors-on-unmatched"
33
+ ]
34
+ },
35
+ "dependencies": {
36
+ "eslint-rspack-plugin": "^4.2.1"
37
+ },
38
+ "devDependencies": {
39
+ "@biomejs/biome": "^1.9.4",
40
+ "@playwright/test": "^1.49.0",
41
+ "@rsbuild/core": "^1.1.6",
42
+ "@rslib/core": "^0.1.1",
43
+ "@types/node": "^22.10.1",
44
+ "eslint": "^9.16.0",
45
+ "nano-staged": "^0.8.0",
46
+ "playwright": "^1.49.0",
47
+ "simple-git-hooks": "^2.11.1",
48
+ "typescript": "^5.7.2"
49
+ },
50
+ "peerDependencies": {
51
+ "@rsbuild/core": "1.x",
52
+ "eslint": "^8.0.0 || ^9.0.0"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "@rsbuild/core": {
56
+ "optional": true
57
+ }
58
+ },
59
+ "packageManager": "pnpm@9.14.4",
60
+ "publishConfig": {
61
+ "access": "public",
62
+ "registry": "https://registry.npmjs.org/"
63
+ }
64
+ }
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 };