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

chore(jest-haste-map): remove support for ignorePattern as function #10348

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,8 @@

### Chore & Maintenance

- `[jest-haste-map]` [**BREAKING**] Remove support for deprecated option `ignorePattern` as function ([#10348](https://github.com/facebook/jest/pull/10348))

### Performance

## 26.4.2
Expand Down
20 changes: 10 additions & 10 deletions packages/jest-haste-map/src/__tests__/index.test.js
Expand Up @@ -330,19 +330,19 @@ describe('HasteMap', () => {
});
});

it('ignores vcs directories with ignore pattern function', () => {
const config = {...defaultConfig, ignorePattern: f => /Kiwi/.test(f)};
mockFs[path.join('/', 'project', 'fruits', 'Kiwi.js')] = `
it('warn on ignore pattern except for regex', () => {
const config = {ignorePattern: 'Kiwi', ...defaultConfig};
mockFs['/project/fruits/Kiwi.js'] = `
// Kiwi!
`;

mockFs[path.join('/', 'project', 'fruits', '.git', 'fruit-history.js')] = `
// test
`;
return new HasteMap(config).build().then(({hasteFS}) => {
expect(hasteFS.matchFiles(/Kiwi/)).toEqual([]);
expect(hasteFS.matchFiles('.git')).toEqual([]);
});
try {
new HasteMap(config).build();
} catch (err) {
expect(err.message).toBe(
'jest-haste-map: the `ignorePattern` option must be a RegExp',
);
}
});

it('builds a haste map on a fresh cache', () => {
Expand Down
10 changes: 2 additions & 8 deletions packages/jest-haste-map/src/index.ts
Expand Up @@ -262,14 +262,8 @@ class HasteMap extends EventEmitter {
options.ignorePattern.flags,
);
} else {
const ignorePattern = options.ignorePattern;
const vcsIgnoreRegExp = new RegExp(VCS_DIRECTORIES);
this._options.ignorePattern = (filePath: string) =>
vcsIgnoreRegExp.test(filePath) || ignorePattern(filePath);

this._console.warn(
'jest-haste-map: the `ignorePattern` options as a function is being ' +
'deprecated. Provide a RegExp instead. See https://github.com/facebook/jest/pull/4063.',
throw new Error(
'jest-haste-map: the `ignorePattern` option must be a RegExp',
);
}
} else {
Expand Down