Skip to content

Commit a01c2e7

Browse files
committed
fix(eslint-bulk): change clean command to prune and update --help
1 parent d698ca7 commit a01c2e7

File tree

7 files changed

+41
-30
lines changed

7 files changed

+41
-30
lines changed

eslint/eslint-bulk/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ Supply the files as the main argument. The "files" argument is a glob pattern th
1313
rules as the "eslint" command.
1414

1515
```bash
16-
eslint-bulk suppress path/to/file1 path/to/file2 path/to/directory --rule rule1 --rule rule2
16+
eslint-bulk suppress --rule rule1 --rule rule2 path/to/file1 path/to/file2 path/to/directory
1717
```
1818

19-
## eslint-bulk clean
19+
## eslint-bulk prune
2020

2121
Use this command to automatically delete unused suppression entries for the given files in the
2222
corresponding .eslint-bulk-suppressions.json file(s). Supply the files as the main argument. The
2323
"files" argument is a glob pattern that follows the same rules as the "eslint" command.
2424

2525
```bash
26-
eslint-bulk clean path/to/file1 path/to/file2 path/to/directory
26+
eslint-bulk prune path/to/file1 path/to/file2 path/to/directory
2727
```
2828

2929
# Links

eslint/eslint-bulk/bin/eslint-bulk

100644100755
File mode changed.

eslint/eslint-patch/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ argument. The "files" argument is a glob pattern that follows the same rules as
142142
eslint-bulk suppress path/to/file1 path/to/file2 path/to/directory --rule rule1 --rule rule2
143143
```
144144

145-
## eslint-bulk cleanup
145+
## eslint-bulk prune
146146

147147
Use this command to automatically delete unused suppression entries for the given files in the
148148
corresponding .eslint-bulk-suppressions.json file(s). Supply the files as the main argument. The
149149
"files" argument is a glob pattern thatfollows the same rules as the "eslint" command.
150150

151151
```bash
152-
eslint-bulk cleanup path/to/file1 path/to/file2 path/to/directory
152+
eslint-bulk prune path/to/file1 path/to/file2 path/to/directory
153153
```
154154

155155
# Links

eslint/eslint-patch/src/eslint-bulk-suppressions/bulk-suppressions-patch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ export function shouldBulkSuppress(params: {
246246
}
247247

248248
export function onFinish(params: { filename: string }): void {
249-
if (process.env.ESLINT_BULK_CLEAN === 'true') {
250-
BulkSuppressionsCleanUp(params);
249+
if (process.env.ESLINT_BULK_PRUNE === 'true') {
250+
BulkSuppressionsPrune(params);
251251
}
252252
}
253253

254-
export function BulkSuppressionsCleanUp(params: { filename: string }): void {
254+
export function BulkSuppressionsPrune(params: { filename: string }): void {
255255
const { filename: fileAbsolutePath } = params;
256256
const suppressionsJson = readSuppressionsJson(fileAbsolutePath);
257257
const newSuppressionsJson = {

eslint/eslint-patch/src/eslint-bulk-suppressions/cli/clean.ts renamed to eslint/eslint-patch/src/eslint-bulk-suppressions/cli/prune.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
import { ExecException, exec } from 'child_process';
55
import { getEslintCli } from './utils/get-eslint-cli';
6-
import { printCleanHelp } from './utils/print-help';
6+
import { printPruneHelp } from './utils/print-help';
77

8-
export function clean() {
8+
export function prune() {
99
const args = process.argv.slice(3);
1010

1111
if (args.includes('--help') || args.includes('-h')) {
12-
printCleanHelp();
12+
printPruneHelp();
1313
process.exit(0);
1414
}
1515

@@ -32,7 +32,7 @@ export function clean() {
3232
const eslintCLI = getEslintCli(process.cwd());
3333

3434
const env = Object.assign({}, process.env);
35-
env.ESLINT_BULK_CLEAN = 'true';
35+
env.ESLINT_BULK_PRUNE = 'true';
3636

3737
exec(
3838
`${eslintCLI} ${parsedArgs.files.join(' ')} --format=json`,
@@ -52,7 +52,7 @@ export function clean() {
5252
}
5353

5454
console.log(
55-
`@rushstack/eslint-bulk: Successfully cleaned up .eslint-bulk-suppressions.json at ${process.cwd()} for ${
55+
`@rushstack/eslint-bulk: Successfully pruned unused suppressions in .eslint-bulk-suppressions.json at ${process.cwd()} for ${
5656
parsedArgs.files
5757
}`
5858
);

eslint/eslint-patch/src/eslint-bulk-suppressions/cli/start.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import { clean } from './clean';
4+
import { prune } from './prune';
55
import { suppress } from './suppress';
66
import { isCorrectCwd } from './utils/is-correct-cwd';
77
import { printHelp } from './utils/print-help';
@@ -20,8 +20,8 @@ const subcommand = process.argv[2];
2020

2121
if (subcommand === 'suppress') {
2222
suppress();
23-
} else if (subcommand === 'clean') {
24-
clean();
23+
} else if (subcommand === 'prune') {
24+
prune();
2525
} else {
2626
throw new Error('@rushstack/eslint-bulk: Unknown subcommand: ' + subcommand);
2727
}

eslint/eslint-patch/src/eslint-bulk-suppressions/cli/utils/print-help.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import { wrapWordsToLines } from './wrap-words-to-lines';
55

6-
export function printCleanHelp() {
7-
const help = `Usage: eslint-bulk suppress [options] <files...>
6+
export function printPruneHelp() {
7+
const help = `Usage: eslint-bulk prune [options] <path...>
88
99
This command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to delete all unused suppression entries in the local .eslint-bulk-suppressions.json file that correspond to the target files given as arguments.
1010
1111
Argument:
12-
<files...>
13-
Glob patterns for files to suppress, same as eslint files argument. Should be relative to the project root.`;
12+
<path...>
13+
Glob patterns for paths to suppress, same as eslint files argument. Should be relative to the project root.`;
1414

1515
const wrapped = wrapWordsToLines(help);
1616
for (const line of wrapped) {
@@ -19,16 +19,27 @@ Argument:
1919
}
2020

2121
export function printHelp() {
22-
const help = `Usage: eslint-bulk <command> [options] <files...>
22+
const help = `eslint-bulk <command>
2323
24-
This command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to suppress or clean up unused suppressions in the local .eslint-bulk-suppressions.json file.
24+
Usage:
25+
26+
eslint-bulk suppress --rule NAME1 [--rule NAME2...] PATH1 [PATH2...]
27+
eslint-bulk suppress --all PATH1 [PATH2...]
28+
eslint-bulk suppress --help
29+
30+
eslint-bulk prune PATH1 [PATH2...]
31+
eslint-bulk prune --help
32+
33+
eslint-bulk --help
34+
35+
This command line tool is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to suppress or prune unused suppressions in the local .eslint-bulk-suppressions.json file.
2536
2637
Commands:
27-
suppress
28-
Please run "eslint-bulk suppress --help" to learn how to use this command.
38+
eslint-bulk suppress [options] <path...>
39+
Please run "eslint-bulk suppress --help" to learn more.
2940
30-
clean
31-
Please run "eslint-bulk clean --help" to learn how to use this command.
41+
eslint-bulk prune <path...>
42+
Please run "eslint-bulk prune --help" to learn how to use this command.
3243
`;
3344

3445
const wrapped = wrapWordsToLines(help);
@@ -38,20 +49,20 @@ Commands:
3849
}
3950

4051
export function printSuppressHelp() {
41-
const help = `Usage: eslint-bulk suppress [options] <files...>
52+
const help = `Usage: eslint-bulk suppress [options] <path...>
4253
4354
This command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to either generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.
4455
4556
Argument:
46-
<files...>
47-
Glob patterns for files to suppress, same as eslint files argument. Should be relative to the project root.
57+
<path...>
58+
Glob patterns for paths to suppress, same as eslint files argument. Should be relative to the project root.
4859
4960
Options:
5061
-h, -H, --help
5162
Display this help message.
5263
5364
-R, --rule
54-
The full name of the ESLint rule you want to bulk-suppress. Specify multiple rules with --rule rule1 --rule rule2.
65+
The full name of the ESLint rule you want to bulk-suppress. Specify multiple rules with --rule NAME1 --rule NAME2.
5566
5667
-A, --all
5768
Bulk-suppress all rules in the specified file patterns.`;

0 commit comments

Comments
 (0)