Skip to content

Commit

Permalink
Replace non-inclusive "whitelist" and "blacklist" terms with "allowli…
Browse files Browse the repository at this point in the history
…st" etc. (#11758)
  • Loading branch information
wojtekmaj committed Jun 29, 2020
1 parent cfaa70d commit 1dd94e8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions packages/babel-core/src/tools/build-external-helpers.js
Expand Up @@ -21,7 +21,7 @@ const buildUmdWrapper = replacements =>
});
`(replacements);

function buildGlobal(whitelist) {
function buildGlobal(allowlist) {
const namespace = t.identifier("babelHelpers");

const body = [];
Expand Down Expand Up @@ -60,14 +60,14 @@ function buildGlobal(whitelist) {
]),
);

buildHelpers(body, namespace, whitelist);
buildHelpers(body, namespace, allowlist);

return tree;
}

function buildModule(whitelist) {
function buildModule(allowlist) {
const body = [];
const refs = buildHelpers(body, null, whitelist);
const refs = buildHelpers(body, null, allowlist);

body.unshift(
t.exportNamedDeclaration(
Expand All @@ -81,7 +81,7 @@ function buildModule(whitelist) {
return t.program(body, [], "module");
}

function buildUmd(whitelist) {
function buildUmd(allowlist) {
const namespace = t.identifier("babelHelpers");

const body = [];
Expand All @@ -91,7 +91,7 @@ function buildUmd(whitelist) {
]),
);

buildHelpers(body, namespace, whitelist);
buildHelpers(body, namespace, allowlist);

return t.program([
buildUmdWrapper({
Expand All @@ -109,7 +109,7 @@ function buildUmd(whitelist) {
]);
}

function buildVar(whitelist) {
function buildVar(allowlist) {
const namespace = t.identifier("babelHelpers");

const body = [];
Expand All @@ -119,12 +119,12 @@ function buildVar(whitelist) {
]),
);
const tree = t.program(body);
buildHelpers(body, namespace, whitelist);
buildHelpers(body, namespace, allowlist);
body.push(t.expressionStatement(namespace));
return tree;
}

function buildHelpers(body, namespace, whitelist) {
function buildHelpers(body, namespace, allowlist) {
const getHelperReference = name => {
return namespace
? t.memberExpression(namespace, t.identifier(name))
Expand All @@ -133,7 +133,7 @@ function buildHelpers(body, namespace, whitelist) {

const refs = {};
helpers.list.forEach(function (name) {
if (whitelist && whitelist.indexOf(name) < 0) return;
if (allowlist && allowlist.indexOf(name) < 0) return;

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

Expand All @@ -145,7 +145,7 @@ function buildHelpers(body, namespace, whitelist) {
return refs;
}
export default function (
whitelist?: Array<string>,
allowlist?: Array<string>,
outputType: "global" | "module" | "umd" | "var" = "global",
) {
let tree;
Expand All @@ -158,7 +158,7 @@ export default function (
}[outputType];

if (build) {
tree = build(whitelist);
tree = build(allowlist);
} else {
throw new Error(`Unsupported output type ${outputType}`);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/test/api.js
Expand Up @@ -733,13 +733,13 @@ describe("api", function () {
expect(script).toEqual(expect.stringContaining("inherits"));
});

it("whitelist", function () {
it("allowlist", function () {
const script = babel.buildExternalHelpers(["inherits"]);
expect(script).not.toEqual(expect.stringContaining("classCallCheck"));
expect(script).toEqual(expect.stringContaining("inherits"));
});

it("empty whitelist", function () {
it("empty allowlist", function () {
const script = babel.buildExternalHelpers([]);
expect(script).not.toEqual(expect.stringContaining("classCallCheck"));
expect(script).not.toEqual(expect.stringContaining("inherits"));
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-helper-fixtures/src/index.js
Expand Up @@ -47,8 +47,8 @@ function assertDirectory(loc) {
}
}

function shouldIgnore(name, blacklist?: Array<string>) {
if (blacklist && blacklist.indexOf(name) >= 0) {
function shouldIgnore(name, ignore?: Array<string>) {
if (ignore && ignore.indexOf(name) >= 0) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/babel-standalone/src/index.js
Expand Up @@ -162,12 +162,12 @@ export function registerPresets(newPresets: {
}

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

// All the presets we should bundle
// Want to get rid of this whitelist of presets?
// Want to get rid of this list of allowed presets?
// Wait! Please read https://github.com/babel/babel/pull/6177 first.
registerPresets({
env: presetEnv,
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-traverse/src/scope/index.js
Expand Up @@ -419,7 +419,7 @@ export default class Scope {
/**
* Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
* evaluating it wont result in potentially arbitrary code from being ran. The following are
* whitelisted and determined not to cause side effects:
* allowed and determined not to cause side effects:
*
* - `this` expressions
* - `super` expressions
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-traverse/test/scope.js
Expand Up @@ -471,7 +471,7 @@ describe("scope", () => {
});

if (kind1 !== kind2) {
//todo: remove the if whitelist
// todo: remove the if allowed
if (kind1 === "const" && (kind2 === "function" || kind2 === "var")) {
continue;
}
Expand Down

0 comments on commit 1dd94e8

Please sign in to comment.