Replace non-inclusive "whitelist" and "blacklist" terms with "allowlist" etc. (#11758)
This commit is contained in:
parent
cfaa70dcf4
commit
1dd94e813e
@ -21,7 +21,7 @@ const buildUmdWrapper = replacements =>
|
||||
});
|
||||
`(replacements);
|
||||
|
||||
function buildGlobal(whitelist) {
|
||||
function buildGlobal(allowlist) {
|
||||
const namespace = t.identifier("babelHelpers");
|
||||
|
||||
const body = [];
|
||||
@ -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(
|
||||
@ -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 = [];
|
||||
@ -91,7 +91,7 @@ function buildUmd(whitelist) {
|
||||
]),
|
||||
);
|
||||
|
||||
buildHelpers(body, namespace, whitelist);
|
||||
buildHelpers(body, namespace, allowlist);
|
||||
|
||||
return t.program([
|
||||
buildUmdWrapper({
|
||||
@ -109,7 +109,7 @@ function buildUmd(whitelist) {
|
||||
]);
|
||||
}
|
||||
|
||||
function buildVar(whitelist) {
|
||||
function buildVar(allowlist) {
|
||||
const namespace = t.identifier("babelHelpers");
|
||||
|
||||
const body = [];
|
||||
@ -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))
|
||||
@ -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));
|
||||
|
||||
@ -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;
|
||||
@ -158,7 +158,7 @@ export default function (
|
||||
}[outputType];
|
||||
|
||||
if (build) {
|
||||
tree = build(whitelist);
|
||||
tree = build(allowlist);
|
||||
} else {
|
||||
throw new Error(`Unsupported output type ${outputType}`);
|
||||
}
|
||||
|
||||
@ -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"));
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user