Skip to content

Commit e3d5fc9

Browse files
authoredJul 16, 2020
fix: use more inclusive terminology in code (palantir#4226)

File tree

11 files changed

+52
-47
lines changed

11 files changed

+52
-47
lines changed
 
File renamed without changes.

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"bundle": "lerna run --parallel bundle",
1111
"compile": "lerna run compile",
1212
"clean": "lerna run --parallel clean",
13-
"copy:ci-config": "mkdir -p site/.circleci && cp .circleci/config-master.yml site/.circleci/config.yml",
13+
"copy:ci-config": "mkdir -p site/.circleci && cp .circleci/config-gh-pages.yml site/.circleci/config.yml",
1414
"copy:docs-app": "cp -rf packages/docs-app/dist/ site/docs",
1515
"copy:landing-app": "cp -rf packages/landing-app/dist/ site",
16-
"deploy": "gh-pages -d site -b master",
16+
"deploy": "gh-pages -d site -b gh-pages",
1717
"dev": "lerna run dev --parallel --ignore \"!@blueprintjs/{landing-app,table-dev-app}\"",
1818
"dev:core": "lerna run dev --parallel --scope \"@blueprintjs/{core,icons,docs-app}\"",
1919
"dev:docs": "lerna run dev --parallel --scope \"@blueprintjs/{core,docs-app,docs-theme}\"",

‎packages/core/src/common/props.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ const INVALID_PROPS = [
137137
];
138138

139139
/**
140-
* Typically applied to HTMLElements to filter out blacklisted props. When applied to a Component,
140+
* Typically applied to HTMLElements to filter out disallowed props. When applied to a Component,
141141
* can filter props from being passed down to the children. Can also filter by a combined list of
142-
* supplied prop keys and the blacklist (only appropriate for HTMLElements).
142+
* supplied prop keys and the denylist (only appropriate for HTMLElements).
143143
* @param props The original props object to filter down.
144-
* @param {string[]} invalidProps If supplied, overwrites the default blacklist.
145-
* @param {boolean} shouldMerge If true, will merge supplied invalidProps and blacklist together.
144+
* @param {string[]} invalidProps If supplied, overwrites the default denylist.
145+
* @param {boolean} shouldMerge If true, will merge supplied invalidProps and denylist together.
146146
*/
147147
export function removeNonHTMLProps(
148148
props: { [key: string]: any },

‎packages/core/src/common/utils/compareUtils.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17+
/** @deprecated use IKeyAllowlist */
18+
export type IKeyWhitelist<T> = IKeyAllowlist<T>;
19+
/** @deprecated use IKeyDenylist */
20+
export type IKeyBlacklist<T> = IKeyDenylist<T>;
21+
1722
// we use the empty object {} a lot in this public API
1823
/* eslint-disable @typescript-eslint/ban-types */
1924

20-
export interface IKeyWhitelist<T> {
25+
export interface IKeyAllowlist<T> {
2126
include: Array<keyof T>;
2227
}
2328

24-
export interface IKeyBlacklist<T> {
29+
export interface IKeyDenylist<T> {
2530
exclude: Array<keyof T>;
2631
}
2732

@@ -46,7 +51,7 @@ export function arraysEqual(arrA: any[], arrB: any[], compare = (a: any, b: any)
4651
* of keys will be compared; otherwise, all keys will be compared.
4752
* @returns true if items are equal.
4853
*/
49-
export function shallowCompareKeys<T extends {}>(objA: T, objB: T, keys?: IKeyBlacklist<T> | IKeyWhitelist<T>) {
54+
export function shallowCompareKeys<T extends {}>(objA: T, objB: T, keys?: IKeyDenylist<T> | IKeyAllowlist<T>) {
5055
// treat `null` and `undefined` as the same
5156
if (objA == null && objB == null) {
5257
return true;
@@ -122,7 +127,7 @@ export function getDeepUnequalKeyValues<T extends {}>(
122127
/**
123128
* Partial shallow comparison between objects using the given list of keys.
124129
*/
125-
function shallowCompareKeysImpl<T>(objA: T, objB: T, keys: IKeyBlacklist<T> | IKeyWhitelist<T>) {
130+
function shallowCompareKeysImpl<T>(objA: T, objB: T, keys: IKeyDenylist<T> | IKeyAllowlist<T>) {
126131
return filterKeys(objA, objB, keys).every(key => {
127132
return objA.hasOwnProperty(key) === objB.hasOwnProperty(key) && objA[key] === objB[key];
128133
});
@@ -141,17 +146,17 @@ function isSimplePrimitiveType(value: any) {
141146
return typeof value === "number" || typeof value === "string" || typeof value === "boolean";
142147
}
143148

144-
function filterKeys<T>(objA: T, objB: T, keys: IKeyBlacklist<T> | IKeyWhitelist<T>) {
145-
if (isWhitelist(keys)) {
149+
function filterKeys<T>(objA: T, objB: T, keys: IKeyDenylist<T> | IKeyAllowlist<T>) {
150+
if (isAllowlist(keys)) {
146151
return keys.include;
147-
} else if (isBlacklist(keys)) {
152+
} else if (isDenylist(keys)) {
148153
const keysA = Object.keys(objA);
149154
const keysB = Object.keys(objB);
150155

151156
// merge keys from both objects into a big set for quick access
152157
const keySet = arrayToObject(keysA.concat(keysB));
153158

154-
// delete blacklisted keys from the key set
159+
// delete denied keys from the key set
155160
keys.exclude.forEach(key => delete keySet[key]);
156161

157162
// return the remaining keys as an array
@@ -161,12 +166,12 @@ function filterKeys<T>(objA: T, objB: T, keys: IKeyBlacklist<T> | IKeyWhitelist<
161166
return [];
162167
}
163168

164-
function isWhitelist<T>(keys: any): keys is IKeyWhitelist<T> {
165-
return keys != null && (keys as IKeyWhitelist<T>).include != null;
169+
function isAllowlist<T>(keys: any): keys is IKeyAllowlist<T> {
170+
return keys != null && (keys as IKeyAllowlist<T>).include != null;
166171
}
167172

168-
function isBlacklist<T>(keys: any): keys is IKeyBlacklist<T> {
169-
return keys != null && (keys as IKeyBlacklist<T>).exclude != null;
173+
function isDenylist<T>(keys: any): keys is IKeyDenylist<T> {
174+
return keys != null && (keys as IKeyDenylist<T>).exclude != null;
170175
}
171176

172177
function arrayToObject(arr: any[]) {

‎packages/core/test/common/propsTests.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe("Props", () => {
3636
};
3737
});
3838

39-
it("removes only from curated blacklist when supplied 1 argument", () => {
39+
it("removes only from curated denylist when supplied 1 argument", () => {
4040
assert.deepEqual(removeNonHTMLProps(props), {
4141
apple: true,
4242
banana: true,
@@ -56,7 +56,7 @@ describe("Props", () => {
5656
});
5757
});
5858

59-
it("removes from the curated blacklist and the supplied array when shouldMerge=true", () => {
59+
it("removes from the curated denylist and the supplied array when shouldMerge=true", () => {
6060
assert.deepEqual(removeNonHTMLProps(props, ["apple", "banana"], true), { cat: true });
6161
});
6262
});

‎packages/core/test/common/utils/compareUtilsTests.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/* eslint-disable max-classes-per-file */
1818

1919
import { expect } from "chai";
20-
import { IKeyBlacklist, IKeyWhitelist } from "../../../src/common/utils";
20+
import { IKeyAllowlist, IKeyDenylist } from "../../../src/common/utils";
2121
import * as CompareUtils from "../../../src/common/utils/compareUtils";
2222

2323
describe("CompareUtils", () => {
@@ -89,15 +89,15 @@ describe("CompareUtils", () => {
8989
expectedResult: boolean,
9090
a: any,
9191
b: any,
92-
keys: IKeyBlacklist<IKeys> | IKeyWhitelist<IKeys>,
92+
keys: IKeyDenylist<IKeys> | IKeyAllowlist<IKeys>,
9393
) {
9494
it(getCompareTestDescription(a, b), () => {
9595
expect(CompareUtils.shallowCompareKeys(a, b, keys)).to.equal(expectedResult);
9696
});
9797
}
9898
});
9999

100-
describe("with `keys` defined as blacklist", () => {
100+
describe("with `keys` defined as denylist", () => {
101101
describe("returns true if only the specified values are shallowly equal", () => {
102102
runTest(true, { a: 1 }, { a: 1 }, bl(["b", "c", "d"]));
103103
runTest(true, { a: 1, b: [1, 2, 3], c: "3" }, { b: [1, 2, 3], a: 1, c: "3" }, bl(["b"]));
@@ -127,7 +127,7 @@ describe("CompareUtils", () => {
127127
expectedResult: boolean,
128128
a: any,
129129
b: any,
130-
keys: IKeyBlacklist<IKeys> | IKeyWhitelist<IKeys>,
130+
keys: IKeyDenylist<IKeys> | IKeyAllowlist<IKeys>,
131131
) {
132132
it(getCompareTestDescription(a, b), () => {
133133
expect(CompareUtils.shallowCompareKeys(a, b, keys)).to.equal(expectedResult);
@@ -323,15 +323,15 @@ interface IKeys {
323323
}
324324

325325
/**
326-
* A compactly named function for converting a string array to a key blacklist.
326+
* A compactly named function for converting a string array to a key denylist.
327327
*/
328-
function bl(keys: string[]): IKeyBlacklist<IKeys> {
328+
function bl(keys: string[]): IKeyDenylist<IKeys> {
329329
return { exclude: keys as Array<keyof IKeys> };
330330
}
331331

332332
/**
333333
* A compactly named function for converting a string array to a key whitelist.
334334
*/
335-
function wl(keys: string[]): IKeyWhitelist<IKeys> {
335+
function wl(keys: string[]): IKeyAllowlist<IKeys> {
336336
return { include: keys as Array<keyof IKeys> };
337337
}

‎packages/table/src/common/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ const CSS_FONT_PROPERTIES = ["font-style", "font-variant", "font-weight", "font-
2929

3030
// the functions using these interfaces now live in core. it's not clear how to
3131
// import interfaces from core and re-export them here, so just redefine them.
32-
export interface IKeyWhitelist<T> {
32+
export interface IKeyAllowlist<T> {
3333
include: Array<keyof T>;
3434
}
35-
export interface IKeyBlacklist<T> {
35+
export interface IKeyDenylist<T> {
3636
exclude: Array<keyof T>;
3737
}
3838

‎packages/table/src/headers/header.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export interface IHeaderState {
230230
hasValidSelection?: boolean;
231231
}
232232

233-
const SHALLOW_COMPARE_PROP_KEYS_BLACKLIST: Array<keyof IInternalHeaderProps> = ["focusedCell", "selectedRegions"];
233+
const SHALLOW_COMPARE_PROP_KEYS_DENYLIST: Array<keyof IInternalHeaderProps> = ["focusedCell", "selectedRegions"];
234234

235235
export class Header extends React.Component<IInternalHeaderProps, IHeaderState> {
236236
protected activationIndex: number;
@@ -251,9 +251,9 @@ export class Header extends React.Component<IInternalHeaderProps, IHeaderState>
251251
return (
252252
!CoreUtils.shallowCompareKeys(this.state, nextState) ||
253253
!CoreUtils.shallowCompareKeys(this.props, nextProps, {
254-
exclude: SHALLOW_COMPARE_PROP_KEYS_BLACKLIST,
254+
exclude: SHALLOW_COMPARE_PROP_KEYS_DENYLIST,
255255
}) ||
256-
!CoreUtils.deepCompareKeys(this.props, nextProps, SHALLOW_COMPARE_PROP_KEYS_BLACKLIST)
256+
!CoreUtils.deepCompareKeys(this.props, nextProps, SHALLOW_COMPARE_PROP_KEYS_DENYLIST)
257257
);
258258
}
259259

‎packages/table/src/table.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ export class Table extends AbstractComponent2<ITableProps, ITableState, ITableSn
546546
selectedRegions: newSelectedRegions,
547547
};
548548

549-
if (!CoreUtils.deepCompareKeys(state, nextState, Table.SHALLOW_COMPARE_STATE_KEYS_BLACKLIST)) {
549+
if (!CoreUtils.deepCompareKeys(state, nextState, Table.SHALLOW_COMPARE_STATE_KEYS_DENYLIST)) {
550550
return nextState;
551551
}
552552

@@ -565,11 +565,11 @@ export class Table extends AbstractComponent2<ITableProps, ITableState, ITableSn
565565
getNumBufferLines: 1,
566566
};
567567

568-
private static SHALLOW_COMPARE_PROP_KEYS_BLACKLIST = [
568+
private static SHALLOW_COMPARE_PROP_KEYS_DENYLIST = [
569569
"selectedRegions", // (intentionally omitted; can be deeply compared to save on re-renders in controlled mode)
570570
] as Array<keyof ITableProps>;
571571

572-
private static SHALLOW_COMPARE_STATE_KEYS_BLACKLIST = [
572+
private static SHALLOW_COMPARE_STATE_KEYS_DENYLIST = [
573573
"selectedRegions", // (intentionally omitted; can be deeply compared to save on re-renders in uncontrolled mode)
574574
"viewportRect",
575575
] as Array<keyof ITableState>;
@@ -789,14 +789,14 @@ export class Table extends AbstractComponent2<ITableProps, ITableState, ITableSn
789789
}
790790

791791
public shouldComponentUpdate(nextProps: ITableProps, nextState: ITableState) {
792-
const propKeysBlacklist = { exclude: Table.SHALLOW_COMPARE_PROP_KEYS_BLACKLIST };
793-
const stateKeysBlacklist = { exclude: Table.SHALLOW_COMPARE_STATE_KEYS_BLACKLIST };
792+
const propKeysDenylist = { exclude: Table.SHALLOW_COMPARE_PROP_KEYS_DENYLIST };
793+
const stateKeysDenylist = { exclude: Table.SHALLOW_COMPARE_STATE_KEYS_DENYLIST };
794794

795795
return (
796-
!CoreUtils.shallowCompareKeys(this.props, nextProps, propKeysBlacklist) ||
797-
!CoreUtils.shallowCompareKeys(this.state, nextState, stateKeysBlacklist) ||
798-
!CoreUtils.deepCompareKeys(this.props, nextProps, Table.SHALLOW_COMPARE_PROP_KEYS_BLACKLIST) ||
799-
!CoreUtils.deepCompareKeys(this.state, nextState, Table.SHALLOW_COMPARE_STATE_KEYS_BLACKLIST)
796+
!CoreUtils.shallowCompareKeys(this.props, nextProps, propKeysDenylist) ||
797+
!CoreUtils.shallowCompareKeys(this.state, nextState, stateKeysDenylist) ||
798+
!CoreUtils.deepCompareKeys(this.props, nextProps, Table.SHALLOW_COMPARE_PROP_KEYS_DENYLIST) ||
799+
!CoreUtils.deepCompareKeys(this.state, nextState, Table.SHALLOW_COMPARE_STATE_KEYS_DENYLIST)
800800
);
801801
}
802802

‎packages/table/src/tableBodyCells.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ export interface ITableBodyCellsProps extends IRowIndices, IColumnIndices, IProp
7171
viewportRect: Rect;
7272
}
7373

74-
const SHALLOW_COMPARE_BLACKLIST: Array<keyof ITableBodyCellsProps> = ["viewportRect"];
74+
const SHALLOW_COMPARE_DENYLIST: Array<keyof ITableBodyCellsProps> = ["viewportRect"];
7575

7676
/**
7777
* We don't want to reset the batcher when this set of keys changes. Any other
7878
* changes should reset the batcher's internal cache.
7979
*/
80-
const BATCHER_RESET_PROP_KEYS_BLACKLIST: Array<keyof ITableBodyCellsProps> = [
80+
const BATCHER_RESET_PROP_KEYS_DENYLIST: Array<keyof ITableBodyCellsProps> = [
8181
"columnIndexEnd",
8282
"columnIndexStart",
8383
"rowIndexEnd",
@@ -102,7 +102,7 @@ export class TableBodyCells extends AbstractComponent2<ITableBodyCellsProps> {
102102
public shouldComponentUpdate(nextProps?: ITableBodyCellsProps) {
103103
return (
104104
!CoreUtils.shallowCompareKeys(nextProps, this.props, {
105-
exclude: SHALLOW_COMPARE_BLACKLIST,
105+
exclude: SHALLOW_COMPARE_DENYLIST,
106106
}) ||
107107
// "viewportRect" is not a plain object, so we can't just deep
108108
// compare; we need custom logic.
@@ -112,7 +112,7 @@ export class TableBodyCells extends AbstractComponent2<ITableBodyCellsProps> {
112112

113113
public componentDidUpdate(prevProps: ITableBodyCellsProps) {
114114
const shouldResetBatcher = !CoreUtils.shallowCompareKeys(prevProps, this.props, {
115-
exclude: BATCHER_RESET_PROP_KEYS_BLACKLIST,
115+
exclude: BATCHER_RESET_PROP_KEYS_DENYLIST,
116116
});
117117
if (shouldResetBatcher) {
118118
this.batcher.reset();

‎scripts/circle-publish-npm

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ if [ ! -z "$CIRCLE_TAG" ]; then
1515
branch='develop'
1616
fi
1717

18-
if ! [[ "$branch" == "master" || "$branch" == "develop" || "$branch" == "next" || "$branch" == release/* ]]; then
19-
echo "Not on master, develop, next, release/* or a tag - not publishing."
18+
if ! [[ "$branch" == "develop" || "$branch" == "next" || "$branch" == release/* ]]; then
19+
echo "Not on develop, next, release/* or a tag - not publishing."
2020
exit 1
2121
fi
2222

0 commit comments

Comments
 (0)
Please sign in to comment.