Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove recursiveBlacklist option from jest-validate #10650

Merged
merged 4 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- `[jest-mock]` [**BREAKING**] Migrate to ESM ([#10887](https://github.com/facebook/jest/pull/10887))
- `[jest-runner]` [**BREAKING**] Migrate to ESM ([#10900](https://github.com/facebook/jest/pull/10900))
- `[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