I'm using the ESLint no-restricted-imports rule, which uses this package under the hood. I've reproduced this issue against node-ignore directly.
We have some tokens in our import paths which are denoted by square brackets. Ignoring these doesn't currently seem to work. I've escaped them in the pattern as required by gitignore (and another \ to escape the \ for JavaScript), and tried the same scenario using git check-ignore which works.
it('ignores patterns containing square brackets', () => {
const ignorer = ignore().add(['src/\\[app\\]']);
expect(ignorer.ignores('src/[app]')).toBe(true); // fails
});
Such paths also can't be un-ignored:
it('un-ignores negated patterns containing square brackets', () => {
const ignorer = ignore().add(['src/**', '!src/\\[app\\]']);
expect(ignorer.ignores('src/a')).toBe(true);
expect(ignorer.ignores('src/[app]')).toBe(false); // fails
});
Version: 5.1.4
I'm using the ESLint no-restricted-imports rule, which uses this package under the hood. I've reproduced this issue against node-ignore directly.
We have some tokens in our import paths which are denoted by square brackets. Ignoring these doesn't currently seem to work. I've escaped them in the pattern as required by gitignore (and another
\to escape the\for JavaScript), and tried the same scenario usinggit check-ignorewhich works.Such paths also can't be un-ignored:
Version: 5.1.4