From 25aa2d592913f6086f552815a474570168922f2c Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Tue, 22 Sep 2020 12:51:31 -0700 Subject: [PATCH] refactor: remove usages of the term whitelist --- packages/angular/cli/lib/config/schema.json | 2 +- .../build_angular/src/dev-server/schema.json | 2 +- .../src/build-optimizer/build-optimizer.ts | 6 +++--- .../src/build-optimizer/build-optimizer_spec.ts | 13 ++++++++----- packages/angular_devkit/core/src/analytics/index.ts | 3 ++- packages/schematics/update/update/index.ts | 6 +++--- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/angular/cli/lib/config/schema.json b/packages/angular/cli/lib/config/schema.json index 7bd224d4f2..a198aaa60e 100644 --- a/packages/angular/cli/lib/config/schema.json +++ b/packages/angular/cli/lib/config/schema.json @@ -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" diff --git a/packages/angular_devkit/build_angular/src/dev-server/schema.json b/packages/angular_devkit/build_angular/src/dev-server/schema.json index 64ec242d27..67b2d49bd5 100644 --- a/packages/angular_devkit/build_angular/src/dev-server/schema.json +++ b/packages/angular_devkit/build_angular/src/dev-server/schema.json @@ -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" diff --git a/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer.ts b/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer.ts index 1dd9a5572c..5ec7f85729 100644 --- a/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer.ts +++ b/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer.ts @@ -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, diff --git a/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer_spec.ts b/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer_spec.ts index 04beef8f59..003f40c1bd 100644 --- a/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer_spec.ts +++ b/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer_spec.ts @@ -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); diff --git a/packages/angular_devkit/core/src/analytics/index.ts b/packages/angular_devkit/core/src/analytics/index.ts index 890ff8eb2b..a67e1eff79 100644 --- a/packages/angular_devkit/core/src/analytics/index.ts +++ b/packages/angular_devkit/core/src/analytics/index.ts @@ -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, diff --git a/packages/schematics/update/update/index.ts b/packages/schematics/update/update/index.ts index 2cf237ae4f..0b0bed26b0 100644 --- a/packages/schematics/update/update/index.ts +++ b/packages/schematics/update/update/index.ts @@ -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, 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 })) {