8000 Replace non-inclusive "whitelist" and "blacklist" terms with "allowli… · babel/babel@1dd94e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1dd94e8

Browse files
authored
Replace non-inclusive "whitelist" and "blacklist" terms with "allowlist" etc. (#11758)
1 parent cfaa70d commit 1dd94e8

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

packages/babel-core/src/tools/build-external-helpers.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const buildUmdWrapper = replacements =>
2121
});
2222
`(replacements);
2323

24-
function buildGlobal(whitelist) {
24+
function buildGlobal(allowlist) {
2525
const namespace = t.identifier("babelHelpers");
2626

2727
const body = [];
@@ -60,14 +60,14 @@ function buildGlobal(whitelist) {
6060
]),
6161
);
6262

63-
buildHelpers(body, namespace, whitelist);
63+
buildHelpers(body, namespace, allowlist);
6464

6565
return tree;
6666
}
6767

68-
function buildModule(whitelist) {
68+
function buildModule(allowlist) {
6969
const body = [];
70-
const refs = buildHelpers(body, null, whitelist);
70+
const refs = buildHelpers(body, null, allowlist);
7171

7272
body.unshift(
7373
t.exportNamedDeclaration(
@@ -81,7 +81,7 @@ function buildModule(whitelist) {
8181
return t.program(body, [], "module");
8282
}
8383

84-
function buildUmd(whitelist) {
84+
function buildUmd(allowlist) {
8585
const namespace = t.identifier("babelHelpers");
8686

8787
const body = [];
@@ -91,7 +91,7 @@ function buildUmd(whitelist) {
9191
]),
9292
);
9393

94-
buildHelpers(body, namespace, whitelist);
94+
buildHelpers(body, namespace, allowlist);
9595

9696
return t.program([
9797
buildUmdWrapper({
@@ -109,7 +109,7 @@ function buildUmd(whitelist) {
109109
]);
110110
}
111111

112-
function buildVar(whitelist) {
112+
function buildVar(allowlist) {
113113
const namespace = t.identifier("babelHelpers");
114114

115115
const body = [];
@@ -119,12 +119,12 @@ function buildVar(whitelist) {
119119
]),
120120
);
121121
const tree = t.program(body);
122-
buildHelpers(body, namespace, whitelist);
122+
buildHelpers(body, namespace, allowlist);
123123
body.push(t.expressionStatement(namespace));
124124
return tree;
125125
}
126126

127-
function buildHelpers(body, namespace, whitelist) {
127+
function buildHelpers(body, namespace, allowlist) {
128128
const getHelperReference = name => {
129129
return namespace
130130
? t.memberExpression(namespace, t.identifier(name))
@@ -133,7 +133,7 @@ function buildHelpers(body, namespace, whitelist) {
133133

134134
const refs = {};
135135
helpers.list.forEach(function (name) {
136-
if (whitelist && whitelist.indexOf(name) < 0) return;
136+
if (allowlist && allowlist.indexOf(name) < 0) return;
137137

138138
const ref = (refs[name] = getHelperReference(name));
139139

@@ -145,7 +145,7 @@ function buildHelpers(body, namespace, whitelist) {
145145
return refs;
146146
}
147147
export default function (
148-
whitelist?: Array<string>,
148+
allowlist?: Array<string>,
149149
outputType: "global" | "module" | "umd" | "var" = "global",
150150
) {
151151
let tree;
@@ -158,7 +158,7 @@ export default function (
158158
}[outputType];
159159

160160
if (build) {
161-
tree = build(whitelist);
161+
tree = build(allowlist);
162162
} else {
163163
throw new Error(`Unsupported output type ${outputType}`);
164164
}

packages/babel-core/test/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,13 +733,13 @@ describe("api", function () {
733733
expect(script).toEqual(expect.stringContaining("inherits"));
734734
});
735735

736-
it("whitelist", function () {
736+
it("allowlist", function () {
737737
const script = babel.buildExternalHelpers(["inherits"]);
738738
expect(script).not.toEqual(expect.stringContaining("classCallCheck"));
739739
expect(script).toEqual(expect.stringContaining("inherits"));
740740
});
741741

742-
it("empty whitelist", function () {
742+
it("empty allowlist", function () {
743743
const script = babel.buildExternalHelpers([]);
744744
expect(script).not.toEqual(expect.stringContaining("classCallCheck"));
745745
expect(script).not.toEqual(expect.stringContaining("inherits"));

packages/babel-helper-fixtures/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function assertDirectory(loc) {
4747
}
4848
}
4949

50-
function shouldIgnore(name, blacklist?: Array<string>) {
51-
if (blacklist && blacklist.indexOf(name) >= 0) {
50+
function shouldIgnore(name, ignore?: Array<string>) {
51+
if (ignore && ignore.indexOf(name) >= 0) {
5252
return true;
5353
}
5454

packages/babel-standalone/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ export function registerPresets(newPresets: {
162162
}
163163

164164
// All the plugins we should bundle
165-
// Want to get rid of this long whitelist of plugins?
165+
// Want to get rid of this long list of allowed plugins?
166166
// Wait! Please read https://github.com/babel/babel/pull/6177 first.
167167
registerPlugins(all);
168168

169169
// All the presets we should bundle
170-
// Want to get rid of this whitelist of presets?
170+
// Want to get rid of this list of allowed presets?
171171
// Wait! Please read https://github.com/babel/babel/pull/6177 first.
172172
registerPresets({
173173
env: presetEnv,

packages/babel-traverse/src/scope/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ export default class Scope {
419419
/**
420420
* Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
421421
* evaluating it wont result in potentially arbitrary code from being ran. The following are
422-
* whitelisted and determined not to cause side effects:
422+
* allowed and determined not to cause side effects:
423423
*
424424
* - `this` expressions
425425
* - `super` expressions

packages/babel-traverse/test/scope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ describe("scope", () => {
471471
});
472472

473473
if (kind1 !== kind2) {
474-
//todo: remove the if whitelist
474+
// todo: remove the if allowed
475475
if (kind1 === "const" && (kind2 === "function" || kind2 === "var")) {
476476
continue;
477477
}

0 commit comments

Comments
 (0)
0