refactor: remove usages of the term whitelist

This commit is contained in:
Joey Perrott 2020-09-22 12:51:31 -07:00 committed by Minko Gechev
parent dd59bfcc60
commit 25aa2d5929
6 changed files with 18 additions and 14 deletions

View File

@ -1197,7 +1197,7 @@
},
"allowedHosts": {
"type": "array",
"description": "Whitelist of hosts that are allowed to access the dev server.",
"description": "List of hosts that are allowed to access the dev server.",
"default": [],
"items": {
"type": "string"

View File

@ -57,7 +57,7 @@
},
"allowedHosts": {
"type": "array",
"description": "Whitelist of hosts that are allowed to access the dev server.",
"description": "List of hosts that are allowed to access the dev server.",
"default": [],
"items": {
"type": "string"

View File

@ -23,7 +23,7 @@ import { getWrapEnumsTransformer } from '../transforms/wrap-enums';
// Angular packages are known to have no side effects.
const whitelistedAngularModules = [
const knownSideEffectFreeAngularModules = [
/[\\/]node_modules[\\/]@angular[\\/]animations[\\/]/,
/[\\/]node_modules[\\/]@angular[\\/]common[\\/]/,
/[\\/]node_modules[\\/]@angular[\\/]compiler[\\/]/,
@ -61,7 +61,7 @@ function isKnownCoreFile(filePath: string) {
function isKnownSideEffectFree(filePath: string) {
return ngFactories.some((re) => re.test(filePath)) ||
whitelistedAngularModules.some((re) => re.test(filePath));
knownSideEffectFreeAngularModules.some((re) => re.test(filePath));
}
export interface BuildOptimizerOptions {
@ -117,7 +117,7 @@ export function buildOptimizer(options: BuildOptimizerOptions): TransformJavascr
getTransforms.push(
// getPrefixFunctionsTransformer is rather dangerous, apply only to known pure es5 modules.
// It will mark both `require()` calls and `console.log(stuff)` as pure.
// We only apply it to whitelisted modules, since we know they are safe.
// We only apply it to modules known to be side effect free, since we know they are safe.
// getPrefixFunctionsTransformer needs to be before getFoldFileTransformer.
getPrefixFunctionsTransformer,
selectedGetScrubFileTransformer,

View File

@ -254,25 +254,28 @@ describe('build-optimizer', () => {
});
});
describe('whitelisted modules', () => {
// This statement is considered pure by getPrefixFunctionsTransformer on whitelisted modules.
describe('known side effect free modules', () => {
// This statement is considered pure by getPrefixFunctionsTransformer on known side effect free
// modules.
const input = 'console.log(42);';
const output = '/*@__PURE__*/ console.log(42);';
it('should process whitelisted modules', () => {
it('should process known side effect free modules', () => {
const inputFilePath = '/node_modules/@angular/core/@angular/core.es5.js';
const boOutput = buildOptimizer({ content: input, inputFilePath });
expect(boOutput.content).toContain(output);
expect(boOutput.emitSkipped).toEqual(false);
});
it('should not process non-whitelisted modules', () => {
it('should not process modules which are not in the list of known side effect free modules',
() => {
const inputFilePath = '/node_modules/other-package/core.es5.js';
const boOutput = buildOptimizer({ content: input, inputFilePath });
expect(boOutput.emitSkipped).toEqual(true);
});
it('should not process non-whitelisted umd modules', () => {
it('should not process umd modules which are not in the list of known side effect free modules',
() => {
const inputFilePath = '/node_modules/other_lib/index.js';
const boOutput = buildOptimizer({ content: input, inputFilePath });
expect(boOutput.emitSkipped).toEqual(true);

View File

@ -17,7 +17,8 @@ export * from './noop';
*
* These cannot be in their respective schema.json file because we either change the type
* (e.g. --buildEventLog is string, but we want to know the usage of it, not its value), or
* some validation needs to be done (we cannot record ng add --collection if it's not whitelisted).
* some validation needs to be done (we cannot record ng add --collection if it's not marked as
* allowed).
*/
export enum NgCliAnalyticsDimensions {
CpuCount = 1,

View File

@ -59,7 +59,7 @@ export function angularMajorCompatGuarantee(range: string) {
// This is a map of packageGroupName to range extending function. If it isn't found, the range is
// kept the same.
const peerCompatibleWhitelist: { [name: string]: PeerVersionTransform } = {
const knownPeerCompatibleList: { [name: string]: PeerVersionTransform } = {
'@angular/core': angularMajorCompatGuarantee,
};
@ -96,7 +96,7 @@ function _updatePeerVersion(infoMap: Map<string, PackageInfo>, name: string, ran
name = maybePackageInfo.installed.updateMetadata.packageGroupName || name;
}
const maybeTransform = peerCompatibleWhitelist[name];
const maybeTransform = knownPeerCompatibleList[name];
if (maybeTransform) {
if (typeof maybeTransform == 'function') {
return maybeTransform(range);
@ -172,7 +172,7 @@ function _validateReversePeerDependencies(
continue;
}
// Override the peer version range if it's whitelisted.
// Override the peer version range if it's known as a compatible.
const extendedRange = _updatePeerVersion(infoMap, peer, range);
if (!semver.satisfies(version, extendedRange, { includePrerelease: next || undefined })) {