Skip to content

Commit b9ec493

Browse files
committed
fix: rename from global suppressions to bulk suppressions
1 parent 8cba410 commit b9ec493

17 files changed

+139
-40
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"suppressions": [
3+
{
4+
"file": "src/test-lab.ts",
5+
"scope": ".",
6+
"target": ".",
7+
"rule": "prefer-const"
8+
},
9+
{
10+
"file": "src/test-lab.ts",
11+
"scope": ".ArrowFunctionExpression",
12+
"target": ".x",
13+
"rule": "@typescript-eslint/no-empty-function"
14+
},
15+
{
16+
"file": "src/test-lab.ts",
17+
"scope": ".ArrowFunctionExpression",
18+
"target": ".y",
19+
"rule": "@typescript-eslint/no-empty-function"
20+
},
21+
{
22+
"file": "src/test-lab.ts",
23+
"scope": ".ArrowFunctionExpression",
24+
"target": ".z",
25+
"rule": "@typescript-eslint/no-empty-function"
26+
},
27+
{
28+
"file": "src/test-lab.ts",
29+
"scope": ".ClassDeclaration",
30+
"target": ".ExampleClass",
31+
"rule": "@typescript-eslint/ban-types"
32+
},
33+
{
34+
"file": "src/test-lab.ts",
35+
"scope": ".ClassDeclaration.MethodDefinition",
36+
"target": ".ExampleClass.exampleMethod",
37+
"rule": "no-var"
38+
},
39+
{
40+
"file": "src/test-lab.ts",
41+
"scope": ".ClassDeclaration.MethodDefinition.ClassExpression.MethodDefinition.ObjectExpression.FunctionExpression",
42+
"target": ".AbsurdClass.absurdClassMethod.AbsurdClass2.constructor.absurdObject.absurdObjectMethod",
43+
"rule": "@typescript-eslint/no-empty-function"
44+
},
45+
{
46+
"file": "src/test-lab.ts",
47+
"scope": ".ClassExpression.MethodDefinition",
48+
"target": ".exampleAnonymousClass.constructor",
49+
"rule": "@typescript-eslint/no-empty-function"
50+
},
51+
{
52+
"file": "src/test-lab.ts",
53+
"scope": ".ClassExpression.MethodDefinition",
54+
"target": ".exampleAnonymousClass.exampleSetGet",
55+
"rule": "@typescript-eslint/ban-types"
56+
},
57+
{
58+
"file": "src/test-lab.ts",
59+
"scope": ".FunctionDeclaration",
60+
"target": ".exampleFunction",
61+
"rule": "@typescript-eslint/ban-types"
62+
},
63+
{
64+
"file": "src/test-lab.ts",
65+
"scope": ".ObjectExpression.ArrowFunctionExpression",
66+
"target": ".exampleObject2.exampleObjectProperty",
67+
"rule": "@typescript-eslint/no-empty-function"
68+
},
69+
{
70+
"file": "src/test-lab.ts",
71+
"scope": ".ObjectExpression.FunctionExpression",
72+
"target": ".exampleObject2.exampleObjectMethod",
73+
"rule": "@typescript-eslint/no-inferrable-types"
74+
},
75+
{
76+
"file": "src/test-lab.ts",
77+
"scope": ".TSInterfaceDeclaration",
78+
"target": ".ExampleInterface",
79+
"rule": "@typescript-eslint/no-empty-interface"
80+
},
81+
{
82+
"file": "src/test-lab.ts",
83+
"scope": ".TSModuleDeclaration",
84+
"target": ".ExampleModule",
85+
"rule": "@typescript-eslint/no-namespace"
86+
},
87+
{
88+
"file": "src/test-lab.ts",
89+
"scope": ".TSModuleDeclaration.TSInterfaceDeclaration",
90+
"target": ".ExampleModule.ExampleInterface2",
91+
"rule": "@typescript-eslint/no-empty-interface"
92+
},
93+
{
94+
"file": "src/test-lab.ts",
95+
"scope": ".TSTypeAliasDeclaration",
96+
"target": ".ExampleObjectType",
97+
"rule": "@typescript-eslint/ban-types"
98+
}
99+
]
100+
}

build-tests/eslint-global-suppressions-test/.eslintrc.js renamed to build-tests/eslint-bulk-suppressions-test/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is a workaround for https://github.com/eslint/eslint/issues/3458
22
require('@rushstack/eslint-config/patch/modern-module-resolution');
3-
require('@rushstack/eslint-config/patch/eslint-global-suppressions');
3+
require('@rushstack/eslint-config/patch/eslint-bulk-suppressions');
44

55
module.exports = {
66
extends: ['plugin:@typescript-eslint/recommended'],

build-tests/eslint-global-suppressions-test/package.json renamed to build-tests/eslint-bulk-suppressions-test/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "eslint-global-suppressions-test",
3-
"description": "Sample code to test eslint global suppressions",
2+
"name": "eslint-bulk-suppressions-test",
3+
"description": "Sample code to test eslint bulk suppressions",
44
"version": "1.0.0",
55
"private": true,
66
"scripts": {
77
"eslint": "eslint .",
8-
"eslint-global-suppress-all": "ESLINT_GLOBAL_SUPPRESS_RULES=* eslint .",
9-
"eslint-without-global-suppressions": "USE_ESLINT_GLOBAL_SUPPRESSIONS=false eslint ."
8+
"eslint-bulk-suppress-all": "ESLINT_BULK_SUPPRESS_RULES=* eslint .",
9+
"eslint-without-bulk-suppressions": "USE_ESLINT_BULK_SUPPRESSIONS=false eslint ."
1010
},
1111
"devDependencies": {
1212
"@rushstack/eslint-config": "workspace:*",

build-tests/eslint-global-suppressions-test/.eslint-global-suppressions.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

common/config/rush/browser-approved-packages.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,18 @@
4646
"name": "@rushstack/rush-vscode-command-webview",
4747
"allowedCategories": [ "vscode-extensions" ]
4848
},
49+
{
50+
"name": "@typescript-eslint/type-utils",
51+
"allowedCategories": [ "libraries" ]
52+
},
4953
{
5054
"name": "@typescript-eslint/types",
5155
"allowedCategories": [ "libraries", "tests" ]
5256
},
57+
{
58+
"name": "@typescript-eslint/utils",
59+
"allowedCategories": [ "libraries" ]
60+
},
5361
{
5462
"name": "@vscode/test-electron",
5563
"allowedCategories": [ "vscode-extensions" ]
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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-
require('@rushstack/eslint-patch/lib/eslint-global-suppressions');
4+
require('@rushstack/eslint-patch/eslint-bulk-suppressions');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./lib/eslint-bulk-suppressions');

eslint/eslint-patch/src/eslint-global-suppressions/global-suppressions-patch.ts renamed to eslint/eslint-patch/src/eslint-bulk-suppressions/bulk-suppressions-patch.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface Suppression {
1111
rule: string;
1212
}
1313

14-
interface GlobalSuppressionsJson {
14+
interface BulkSuppressionsJson {
1515
suppressions: Suppression[];
1616
}
1717

@@ -109,7 +109,7 @@ function findEslintrcDirectory(fileAbsolutePath: string): string {
109109
throw new Error('Cannot locate eslintrc');
110110
}
111111

112-
function validateSuppressionsJson(json: GlobalSuppressionsJson): json is GlobalSuppressionsJson {
112+
function validateSuppressionsJson(json: BulkSuppressionsJson): json is BulkSuppressionsJson {
113113
if (typeof json !== 'object') return false;
114114
if (json === null) return false;
115115
if (!json.hasOwnProperty('suppressions')) return false;
@@ -134,16 +134,16 @@ function validateSuppressionsJson(json: GlobalSuppressionsJson): json is GlobalS
134134
return true;
135135
}
136136

137-
function readSuppressionsJson(eslintrcDirectory: string): GlobalSuppressionsJson {
138-
const suppressionsPath = path.join(eslintrcDirectory, '.eslint-global-suppressions.json');
137+
function readSuppressionsJson(eslintrcDirectory: string): BulkSuppressionsJson {
138+
const suppressionsPath = path.join(eslintrcDirectory, '.eslint-bulk-suppressions.json');
139139
let suppressionsJson = { suppressions: [] };
140140
try {
141141
const fileContent = fs.readFileSync(suppressionsPath, 'utf-8');
142142
suppressionsJson = JSON.parse(fileContent);
143143

144144
if (!validateSuppressionsJson(suppressionsJson)) {
145145
console.log(
146-
`Unexpected file content in .eslint-global-suppressions.json. JSON expected to be in the following format:
146+
`Unexpected file content in .eslint-bulk-suppressions.json. JSON expected to be in the following format:
147147
{
148148
suppressions: {
149149
file: string;
@@ -173,9 +173,9 @@ function serializeFileScopeTargetRule(suppression: {
173173
}
174174

175175
function shouldWriteSuppression(rule: string): boolean {
176-
if (process.env.ESLINT_GLOBAL_SUPPRESS_RULES === undefined) return false;
176+
if (process.env.ESLINT_BULK_SUPPRESS_RULES === undefined) return false;
177177

178-
const rulesToSuppress = process.env.ESLINT_GLOBAL_SUPPRESS_RULES.split(',');
178+
const rulesToSuppress = process.env.ESLINT_BULK_SUPPRESS_RULES.split(',');
179179

180180
if (rulesToSuppress.length === 1 && rulesToSuppress[0] === '*') return true;
181181

@@ -212,7 +212,7 @@ function writeSuppression(params: {
212212

213213
insort(suppressionsJson.suppressions, { file, scope, target, rule }, compareSuppressions);
214214

215-
const suppressionsPath = path.join(eslintrcDirectory, '.eslint-global-suppressions.json');
215+
const suppressionsPath = path.join(eslintrcDirectory, '.eslint-bulk-suppressions.json');
216216
fs.writeFileSync(suppressionsPath, JSON.stringify(suppressionsJson, null, 2));
217217
}
218218

@@ -224,13 +224,13 @@ function readSerializedSuppressionsSet(fileAbsolutePath: string) {
224224
}
225225

226226
// One-line insert into the ruleContext report method to prematurely exit if the ESLint problem has been suppressed
227-
export function shouldGlobalSuppress(params: {
227+
export function shouldBulkSuppress(params: {
228228
filename: string;
229229
currentNode: BaseNode;
230230
ruleId: string;
231231
}): boolean {
232-
// Use this ENV variable to turn off eslint-global-suppressions functionality, default behavior is on
233-
if (process.env.USE_ESLINT_GLOBAL_SUPPRESSIONS === 'false') return false;
232+
// Use this ENV variable to turn off eslint-bulk-suppressions functionality, default behavior is on
233+
if (process.env.USE_ESLINT_BULK_SUPPRESSIONS === 'false') return false;
234234

235235
const { filename: fileAbsolutePath, currentNode, ruleId: rule } = params;
236236
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
@@ -249,11 +249,11 @@ export function shouldGlobalSuppress(params: {
249249
)
250250
writeSuppression({ eslintrcDirectory, file: fileRelativePath, scope, target, rule: rule });
251251

252-
const shouldGlobalSuppress: boolean = readSerializedSuppressionsSet(fileAbsolutePath).has(
252+
const shouldBulkSuppress: boolean = readSerializedSuppressionsSet(fileAbsolutePath).has(
253253
serializedFileScopeTargetRule
254254
);
255255

256-
return shouldGlobalSuppress;
256+
return shouldBulkSuppress;
257257
}
258258

259259
// utility function for linter-patch.js to make require statements that use relative paths in linter.js work in linter-patch.js
@@ -306,6 +306,6 @@ export function findEslintLibraryLocation() {
306306

307307
module.exports = {
308308
requireFromPathToLinterJS,
309-
shouldGlobalSuppress,
309+
shouldBulkSuppress,
310310
findEslintLibraryLocation
311311
};

eslint/eslint-patch/src/eslint-global-suppressions/index.ts renamed to eslint/eslint-patch/src/eslint-bulk-suppressions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path';
2-
import { findEslintLibraryLocation } from './global-suppressions-patch';
2+
import { findEslintLibraryLocation } from './bulk-suppressions-patch';
33
import { Linter as LinterPatch } from './linter-patch-for-eslint-v8.7.0';
44

55
const eslintLibraryLocation = findEslintLibraryLocation();

eslint/eslint-patch/src/eslint-global-suppressions/linter-patch-for-eslint-v8.23.1.js renamed to eslint/eslint-patch/src/eslint-bulk-suppressions/linter-patch-for-eslint-v8.23.1.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
//------------------------------------------------------------------------------
2525

2626
// --- BEGIN MONKEY PATCH ---
27-
const globalSuppressionsPatch = require('./global-suppressions-patch');
28-
const requireFromPathToLinterJS = globalSuppressionsPatch.requireFromPathToLinterJS;
27+
const bulkSuppressionsPatch = require('./bulk-suppressions-patch');
28+
const requireFromPathToLinterJS = bulkSuppressionsPatch.requireFromPathToLinterJS;
2929
const path = require('path'),
3030
eslintScope = requireFromPathToLinterJS('eslint-scope'),
3131
evk = requireFromPathToLinterJS('eslint-visitor-keys'),
@@ -1084,7 +1084,7 @@ function runRules(
10841084
options: getRuleOptions(configuredRules[ruleId]),
10851085
report(...args) {
10861086
// --- BEGIN MONKEY PATCH ---
1087-
if (globalSuppressionsPatch.shouldGlobalSuppress({ filename, currentNode, ruleId })) return;
1087+
if (bulkSuppressionsPatch.shouldBulkSuppress({ filename, currentNode, ruleId })) return;
10881088
// --- END MONKEY PATCH ---
10891089
/*
10901090
* Create a report translator lazily.

eslint/eslint-patch/src/eslint-global-suppressions/linter-patch-for-eslint-v8.7.0.js renamed to eslint/eslint-patch/src/eslint-bulk-suppressions/linter-patch-for-eslint-v8.7.0.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
//------------------------------------------------------------------------------
2525

2626
// --- BEGIN MONKEY PATCH ---
27-
const globalSuppressionsPatch = require('./global-suppressions-patch');
28-
const requireFromPathToLinterJS = globalSuppressionsPatch.requireFromPathToLinterJS;
27+
const bulkSuppressionsPatch = require('./bulk-suppressions-patch');
28+
const requireFromPathToLinterJS = bulkSuppressionsPatch.requireFromPathToLinterJS;
2929
const path = require('path'),
3030
eslintScope = requireFromPathToLinterJS('eslint-scope'),
3131
evk = requireFromPathToLinterJS('eslint-visitor-keys'),
@@ -1052,7 +1052,7 @@ function runRules(
10521052
options: getRuleOptions(configuredRules[ruleId]),
10531053
report(...args) {
10541054
// --- BEGIN MONKEY PATCH ---
1055-
if (globalSuppressionsPatch.shouldGlobalSuppress({ filename, currentNode, ruleId })) return;
1055+
if (bulkSuppressionsPatch.shouldBulkSuppress({ filename, currentNode, ruleId })) return;
10561056
// --- END MONKEY PATCH ---
10571057
/*
10581058
* Create a report translator lazily.

eslint/eslint-patch/tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

rush.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,8 @@
588588
"shouldPublish": false
589589
},
590590
{
591-
"packageName": "eslint-global-suppressions-test",
592-
"projectFolder": "build-tests/eslint-global-suppressions-test",
591+
"packageName": "eslint-bulk-suppressions-test",
592+
"projectFolder": "build-tests/eslint-bulk-suppressions-test",
593593
},
594594
{
595595
"packageName": "package-extractor-test-01",

0 commit comments

Comments
 (0)