@rushstack/eslint-bulk 0.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/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ @rushstack/eslint-bulk
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @rushstack/eslint-bulk
2
+
3
+ This is a companion package for @rushstack/eslint-patch that should be installed globally as follows:
4
+ ```bash
5
+ npm i -g @rushstack/eslint-bulk
6
+ ```
7
+
8
+ The **eslint-bulk** package is a set of command line tools to use with the ESLint bulk suppressions patch.
9
+ eslint-bulk commands must be run in the same current working directory containing your package's pertaining
10
+ .eslintrc.js or .eslintrc.cjs file.
11
+
12
+ ## eslint-bulk suppress
13
+
14
+ Use this command to automatically generate bulk suppressions for the given files and given rules.
15
+ Supply the paths as the main argument. The paths argument is a glob pattern that follows the same
16
+ rules as the "files" argument in the "eslint" command.
17
+
18
+ ```bash
19
+ eslint-bulk suppress --rule NAME1 [--rule NAME2...] PATH1 [PATH2...]
20
+ eslint-bulk suppress --all PATH1 [PATH2...]
21
+ ```
22
+
23
+ ## eslint-bulk prune
24
+
25
+ Use this command to automatically delete all unused suppression entries in all .eslint-bulk-suppressions.json
26
+ files under the current working directory.
27
+
28
+ ```bash
29
+ eslint-bulk prune
30
+ ```
31
+
32
+ # Links
33
+
34
+ - [CHANGELOG.md](https://github.com/microsoft/rushstack/blob/main/eslint/eslint-bulk/CHANGELOG.md) - Find
35
+ out what's new in the latest version
36
+
37
+ `@rushstack/eslint-bulk` is part of the [Rush Stack](https://rushstack.io/) family of projects.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../lib/start.js');
package/lib/start.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":""}
package/lib/start.js ADDED
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
+ // See LICENSE in the project root for license information.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ const child_process_1 = require("child_process");
29
+ const process = __importStar(require("process"));
30
+ const fs = __importStar(require("fs"));
31
+ const path = __importStar(require("path"));
32
+ function findPatchPath() {
33
+ let eslintrcPath;
34
+ if (fs.existsSync(path.join(process.cwd(), '.eslintrc.js'))) {
35
+ eslintrcPath = '.eslintrc.js';
36
+ }
37
+ else if (fs.existsSync(path.join(process.cwd(), '.eslintrc.cjs'))) {
38
+ eslintrcPath = '.eslintrc.cjs';
39
+ }
40
+ else {
41
+ console.error('@rushstack/eslint-bulk: Please run this command from the directory that contains .eslintrc.js or .eslintrc.cjs');
42
+ process.exit(1);
43
+ }
44
+ const env = Object.assign(Object.assign({}, process.env), { _RUSHSTACK_ESLINT_BULK_DETECT: 'true' });
45
+ let stdout;
46
+ try {
47
+ stdout = (0, child_process_1.execSync)(`eslint --stdin --config ${eslintrcPath}`, { env, input: '', stdio: 'pipe' });
48
+ }
49
+ catch (e) {
50
+ console.error('@rushstack/eslint-bulk: Error finding patch path: ' + e.message);
51
+ process.exit(1);
52
+ }
53
+ const startDelimiter = 'RUSHSTACK_ESLINT_BULK_START';
54
+ const endDelimiter = 'RUSHSTACK_ESLINT_BULK_END';
55
+ const regex = new RegExp(`${startDelimiter}(.*?)${endDelimiter}`);
56
+ const match = stdout.toString().match(regex);
57
+ if (match) {
58
+ // The configuration data will look something like this:
59
+ //
60
+ // RUSHSTACK_ESLINT_BULK_START{"minCliVersion":"0.0.0","cliEntryPoint":"path/to/eslint-bulk.js"}RUSHSTACK_ESLINT_BULK_END
61
+ const configurationJson = match[1].trim();
62
+ let configuration;
63
+ try {
64
+ configuration = JSON.parse(configurationJson);
65
+ if (!configuration.minCliVersion || !configuration.cliEntryPoint) {
66
+ throw new Error('Required field is missing');
67
+ }
68
+ }
69
+ catch (e) {
70
+ console.error('@rushstack/eslint-bulk: Error parsing patch configuration object:' + e.message);
71
+ process.exit(1);
72
+ }
73
+ const myVersion = require('../package.json').version;
74
+ const myVersionParts = myVersion.split('.').map((x) => parseInt(x, 10));
75
+ const minVersion = configuration.minCliVersion;
76
+ const minVersionParts = minVersion.split('.').map((x) => parseInt(x, 10));
77
+ if (myVersionParts.length !== 3 ||
78
+ minVersionParts.length !== 3 ||
79
+ myVersionParts.some((x) => isNaN(x)) ||
80
+ minVersionParts.some((x) => isNaN(x))) {
81
+ console.error(`@rushstack/eslint-bulk: Unable to compare versions "${myVersion}" and "${minVersion}"`);
82
+ process.exit(1);
83
+ }
84
+ for (let i = 0; i < 3; ++i) {
85
+ if (myVersionParts[i] > minVersionParts[i]) {
86
+ break;
87
+ }
88
+ if (myVersionParts[i] < minVersionParts[i]) {
89
+ console.error(`@rushstack/eslint-bulk: The @rushstack/eslint-bulk version ${myVersion} is too old;` +
90
+ ` please upgrade to ${minVersion} or newer.`);
91
+ process.exit(1);
92
+ }
93
+ }
94
+ return configuration.cliEntryPoint;
95
+ }
96
+ console.error('@rushstack/eslint-bulk: Error finding patch path. Are you sure the package you are in has @rushstack/eslint-patch as a direct or indirect dependency?');
97
+ process.exit(1);
98
+ }
99
+ const patchPath = findPatchPath();
100
+ try {
101
+ const args = process.argv.slice(2).join(' ');
102
+ const command = `node ${patchPath} ${args}`;
103
+ (0, child_process_1.execSync)(command, { stdio: 'inherit' });
104
+ }
105
+ catch (e) {
106
+ console.error(`@rushstack/eslint-bulk: Error running patch at ${patchPath}:\n` + e.message);
107
+ process.exit(1);
108
+ }
109
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"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AC,EACrC;YACA,OAAO,CAAC,KAAK,CAAC,uDAAuD,SAAS,UAAU,UAAU,GAAG,CAAC,CAAC;YACvG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;YAClC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE;gBAC1C,MAAM;aACP;YACD,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE;gBAC1C,OAAO,CAAC,KAAK,CACX,8DAA8D,SAAS,cAAc;oBACnF,sBAAsB,UAAU,YAAY,CAC/C,CAAC;gBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;SACF;QAED,OAAO,aAAa,CAAC,aAAa,CAAC;KACpC;IAED,OAAO,CAAC,KAAK,CACX,uJAAuJ,CACxJ,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,SAAS,GAAW,aAAa,EAAE,CAAC;AAC1C,IAAI;IACF,MAAM,IAAI,GAAW,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,OAAO,GAAW,QAAQ,SAAS,IAAI,IAAI,EAAE,CAAC;IACpD,IAAA,wBAAQ,EAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;CACzC;AAAC,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,kDAAkD,SAAS,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;IAC5F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { execSync } from 'child_process';\nimport * as process from 'process';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\ninterface IEslintBulkConfigurationJson {\n /**\n * `@rushtack/eslint`-bulk should report an error if its package.json is older than this number\n */\n minCliVersion: string;\n /**\n * `@rushtack/eslint-bulk` will invoke this entry point\n */\n cliEntryPoint: string;\n}\n\nfunction findPatchPath(): string {\n let eslintrcPath: string;\n if (fs.existsSync(path.join(process.cwd(), '.eslintrc.js'))) {\n eslintrcPath = '.eslintrc.js';\n } else if (fs.existsSync(path.join(process.cwd(), '.eslintrc.cjs'))) {\n eslintrcPath = '.eslintrc.cjs';\n } else {\n console.error(\n '@rushstack/eslint-bulk: Please run this command from the directory that contains .eslintrc.js or .eslintrc.cjs'\n );\n process.exit(1);\n }\n\n const env: NodeJS.ProcessEnv = { ...process.env, _RUSHSTACK_ESLINT_BULK_DETECT: 'true' };\n\n let stdout: Buffer;\n try {\n stdout = execSync(`eslint --stdin --config ${eslintrcPath}`, { env, input: '', stdio: 'pipe' });\n } catch (e) {\n console.error('@rushstack/eslint-bulk: Error finding patch path: ' + e.message);\n process.exit(1);\n }\n\n const startDelimiter: string = 'RUSHSTACK_ESLINT_BULK_START';\n const endDelimiter: string = 'RUSHSTACK_ESLINT_BULK_END';\n\n const regex: RegExp = new RegExp(`${startDelimiter}(.*?)${endDelimiter}`);\n const match: RegExpMatchArray | null = stdout.toString().match(regex);\n\n if (match) {\n // The configuration data will look something like this:\n //\n // RUSHSTACK_ESLINT_BULK_START{\"minCliVersion\":\"0.0.0\",\"cliEntryPoint\":\"path/to/eslint-bulk.js\"}RUSHSTACK_ESLINT_BULK_END\n const configurationJson: string = match[1].trim();\n let configuration: IEslintBulkConfigurationJson;\n try {\n configuration = JSON.parse(configurationJson);\n if (!configuration.minCliVersion || !configuration.cliEntryPoint) {\n throw new Error('Required field is missing');\n }\n } catch (e) {\n console.error('@rushstack/eslint-bulk: Error parsing patch configuration object:' + e.message);\n process.exit(1);\n }\n\n const myVersion: string = require('../package.json').version;\n const myVersionParts: number[] = myVersion.split('.').map((x) => parseInt(x, 10));\n const minVersion: string = configuration.minCliVersion;\n const minVersionParts: number[] = minVersion.split('.').map((x) => parseInt(x, 10));\n if (\n myVersionParts.length !== 3 ||\n minVersionParts.length !== 3 ||\n myVersionParts.some((x) => isNaN(x)) ||\n minVersionParts.some((x) => isNaN(x))\n ) {\n console.error(`@rushstack/eslint-bulk: Unable to compare versions \"${myVersion}\" and \"${minVersion}\"`);\n process.exit(1);\n }\n\n for (let i: number = 0; i < 3; ++i) {\n if (myVersionParts[i] > minVersionParts[i]) {\n break;\n }\n if (myVersionParts[i] < minVersionParts[i]) {\n console.error(\n `@rushstack/eslint-bulk: The @rushstack/eslint-bulk version ${myVersion} is too old;` +\n ` please upgrade to ${minVersion} or newer.`\n );\n process.exit(1);\n }\n }\n\n return configuration.cliEntryPoint;\n }\n\n console.error(\n '@rushstack/eslint-bulk: Error finding patch path. Are you sure the package you are in has @rushstack/eslint-patch as a direct or indirect dependency?'\n );\n process.exit(1);\n}\n\nconst patchPath: string = findPatchPath();\ntry {\n const args: string = process.argv.slice(2).join(' ');\n const command: string = `node ${patchPath} ${args}`;\n execSync(command, { stdio: 'inherit' });\n} catch (e) {\n console.error(`@rushstack/eslint-bulk: Error running patch at ${patchPath}:\\n` + e.message);\n process.exit(1);\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@rushstack/eslint-bulk",
3
+ "version": "0.1.0",
4
+ "description": "A set of helper CLIs to use with the rushstack ESLint toolchain",
5
+ "main": "index.js",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "url": "https://github.com/microsoft/rushstack.git",
9
+ "type": "git",
10
+ "directory": "eslint/eslint-bulk"
11
+ },
12
+ "homepage": "https://rushstack.io",
13
+ "bin": {
14
+ "eslint-bulk": "./bin/eslint-bulk"
15
+ },
16
+ "keywords": [
17
+ "eslintrc",
18
+ "eslint",
19
+ "bulk",
20
+ "legacy",
21
+ "retroactive",
22
+ "disable",
23
+ "ignore",
24
+ "suppression"
25
+ ],
26
+ "devDependencies": {
27
+ "@types/node": "18.17.15",
28
+ "local-node-rig": "1.0.0",
29
+ "@rushstack/heft": "0.63.2"
30
+ },
31
+ "scripts": {
32
+ "build": "heft build --clean",
33
+ "_phase:build": "heft run --only build -- --clean",
34
+ "start": "node ./lib/start.js"
35
+ }
36
+ }