Skip to content

Commit

Permalink
Remove recursiveBlacklist option from jest-validate (#10650)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj authored Dec 5, 2020
1 parent 5e2e8ed commit 8a5c4d5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 48 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- `[jest-runner]` [**BREAKING**] Migrate to ESM ([#10900](https://github.com/facebook/jest/pull/10900))
- `[jest-runtime]` [**BREAKING**] Remove deprecated and unnused `getSourceMapInfo` from Runtime ([#9969](https://github.com/facebook/jest/pull/9969))
- `[jest-util]` No longer checking `enumerable` when adding `process.domain` ([#10862](https://github.com/facebook/jest/pull/10862))
- `[jest-validate]` [**BREAKING**] Remove `recursiveBlacklist ` option in favor of previously introduced `recursiveDenylist` ([#10650](https://github.com/facebook/jest/pull/10650))

### Performance

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export default function normalize(
comment: DOCUMENTATION_NOTE,
deprecatedConfig: DEPRECATED_CONFIG,
exampleConfig: VALID_CONFIG,
recursiveBlacklist: [
recursiveDenylist: [
'collectCoverageOnlyFrom',
// 'coverageThreshold' allows to use 'global' and glob strings on the same
// level, there's currently no way we can deal with such config
Expand Down
34 changes: 0 additions & 34 deletions packages/jest-validate/src/__tests__/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,40 +100,6 @@ test.each([
},
);

test('respects recursiveBlacklist', () => {
const warn = console.warn;
console.warn = jest.fn();
const config = {
something: {
nested: {
some_random_key: 'value',
some_random_key2: 'value2',
},
},
};
const exampleConfig = {
something: {
nested: {
test: true,
},
},
};

validate(config, {exampleConfig});

expect(console.warn).toBeCalled();

console.warn.mockReset();

validate(config, {
exampleConfig,
recursiveBlacklist: ['something.nested'],
});

expect(console.warn).not.toBeCalled();
console.warn = warn;
});

test('respects recursiveDenylist', () => {
const warn = console.warn;
console.warn = jest.fn();
Expand Down
1 change: 0 additions & 1 deletion packages/jest-validate/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export type ValidationOptions = {
) => void;
exampleConfig: Record<string, unknown>;
recursive?: boolean;
recursiveBlacklist?: Array<string>;
recursiveDenylist?: Array<string>;
title?: Title;
unknown?: (
Expand Down
16 changes: 4 additions & 12 deletions packages/jest-validate/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ const _validate = (
options.error(key, config[key], exampleConfig[key], options, path);
}
} else if (
shouldSkipValidationForPath(
path,
key,
options.recursiveDenylist || options.recursiveBlacklist,
)
shouldSkipValidationForPath(path, key, options.recursiveDenylist)
) {
// skip validating unknown options inside blacklisted paths
} else {
Expand All @@ -85,12 +81,8 @@ const _validate = (
if (
options.recursive &&
!Array.isArray(exampleConfig[key]) &&
(options.recursiveDenylist || options.recursiveBlacklist) &&
!shouldSkipValidationForPath(
path,
key,
options.recursiveDenylist || options.recursiveBlacklist,
)
options.recursiveDenylist &&
!shouldSkipValidationForPath(path, key, options.recursiveDenylist)
) {
_validate(config[key], exampleConfig[key], options, [...path, key]);
}
Expand All @@ -112,7 +104,7 @@ const validate = (
// Preserve default denylist entries even with user-supplied denylist
const combinedDenylist: Array<string> = [
...(defaultConfig.recursiveDenylist || []),
...(options.recursiveDenylist || options.recursiveBlacklist || []),
...(options.recursiveDenylist || []),
];

const defaultedOptions: ValidationOptions = Object.assign({
Expand Down

0 comments on commit 8a5c4d5

Please sign in to comment.