@rsbuild/plugin-eslint 0.4.8

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ <p align="center">
2
+ <a href="https://rsbuild.dev" target="blank"><img src="https://github.com/web-infra-dev/rsbuild/assets/7237365/84abc13e-b620-468f-a90b-dbf28e7e9427" alt="Rsbuild Logo" /></a>
3
+ </p>
4
+
5
+ # Rsbuild
6
+
7
+ The Rspack-based build tool. It's fast, out-of-the-box and extensible.
8
+
9
+ ## Documentation
10
+
11
+ https://rsbuild.dev/
12
+
13
+ ## Contributing
14
+
15
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/rsbuild/blob/main/CONTRIBUTING.md).
16
+
17
+ ## License
18
+
19
+ Rsbuild is [MIT licensed](https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE).
@@ -0,0 +1,18 @@
1
+ import { RsbuildPlugin } from '@rsbuild/core';
2
+ import { Options } from 'eslint-webpack-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-webpack-plugin`.
12
+ * @see https://github.com/webpack-contrib/eslint-webpack-plugin
13
+ */
14
+ eslintPluginOptions?: Options;
15
+ };
16
+ declare const pluginEslint: (options?: PluginEslintOptions) => RsbuildPlugin;
17
+
18
+ export { type PluginEslintOptions, pluginEslint };
package/dist/index.js ADDED
@@ -0,0 +1,68 @@
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
+ pluginEslint: () => pluginEslint
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+ var import_node_path = __toESM(require("path"));
37
+ var pluginEslint = (options = {}) => ({
38
+ name: "rsbuild:eslint",
39
+ setup(api) {
40
+ const { enable = true, eslintPluginOptions } = options;
41
+ if (!enable) {
42
+ return;
43
+ }
44
+ api.modifyBundlerChain(async (chain, { target, CHAIN_ID }) => {
45
+ if (target !== api.context.targets[0]) {
46
+ return;
47
+ }
48
+ const { default: ESLintPlugin } = await import("eslint-webpack-plugin");
49
+ const defaultOptions = {
50
+ extensions: ["js", "jsx", "mjs", "cjs", "ts", "tsx", "mts", "cts"],
51
+ exclude: [
52
+ "node_modules",
53
+ import_node_path.default.relative(api.context.rootPath, api.context.distPath)
54
+ ]
55
+ };
56
+ chain.plugin(CHAIN_ID.PLUGIN.ESLINT).use(ESLintPlugin, [
57
+ {
58
+ ...defaultOptions,
59
+ ...eslintPluginOptions
60
+ }
61
+ ]);
62
+ });
63
+ }
64
+ });
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ pluginEslint
68
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,41 @@
1
+ import { createRequire } from 'module';
2
+ var require = createRequire(import.meta['url']);
3
+
4
+
5
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.47.1_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
6
+ import { fileURLToPath } from "url";
7
+ import path from "path";
8
+
9
+ // src/index.ts
10
+ import path2 from "path";
11
+ var pluginEslint = (options = {}) => ({
12
+ name: "rsbuild:eslint",
13
+ setup(api) {
14
+ const { enable = true, eslintPluginOptions } = options;
15
+ if (!enable) {
16
+ return;
17
+ }
18
+ api.modifyBundlerChain(async (chain, { target, CHAIN_ID }) => {
19
+ if (target !== api.context.targets[0]) {
20
+ return;
21
+ }
22
+ const { default: ESLintPlugin } = await import("eslint-webpack-plugin");
23
+ const defaultOptions = {
24
+ extensions: ["js", "jsx", "mjs", "cjs", "ts", "tsx", "mts", "cts"],
25
+ exclude: [
26
+ "node_modules",
27
+ path2.relative(api.context.rootPath, api.context.distPath)
28
+ ]
29
+ };
30
+ chain.plugin(CHAIN_ID.PLUGIN.ESLINT).use(ESLintPlugin, [
31
+ {
32
+ ...defaultOptions,
33
+ ...eslintPluginOptions
34
+ }
35
+ ]);
36
+ });
37
+ }
38
+ });
39
+ export {
40
+ pluginEslint
41
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@rsbuild/plugin-eslint",
3
+ "version": "0.4.8",
4
+ "description": "ESLint plugin for Rsbuild",
5
+ "homepage": "https://rsbuild.dev",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/web-infra-dev/rsbuild",
9
+ "directory": "packages/plugin-eslint"
10
+ },
11
+ "license": "MIT",
12
+ "type": "commonjs",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "dependencies": {
26
+ "eslint": "^8.57.0",
27
+ "eslint-webpack-plugin": "^4.0.1",
28
+ "webpack": "^5.89.0",
29
+ "@rsbuild/shared": "0.4.8"
30
+ },
31
+ "devDependencies": {
32
+ "typescript": "^5.3.0",
33
+ "@rsbuild/core": "0.4.8",
34
+ "@scripts/test-helper": "0.4.8"
35
+ },
36
+ "peerDependencies": {
37
+ "@rsbuild/core": "^0.4.8"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "provenance": true,
42
+ "registry": "https://registry.npmjs.org/"
43
+ },
44
+ "scripts": {
45
+ "build": "modern build",
46
+ "dev": "modern build --watch"
47
+ }
48
+ }