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

Unable to ignore a path containing square brackets #59

Closed
robatwilliams opened this issue May 19, 2020 · 3 comments
Closed

Unable to ignore a path containing square brackets #59

robatwilliams opened this issue May 19, 2020 · 3 comments
Labels

Comments

@robatwilliams
Copy link

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

@kaelzhang
Copy link
Owner

Nice catch buddy. But it will take time, I need a complete test with more test cases about escaping.

gitignore manual is really lame and lacks of cases, so I need to be cautious.

@kaelzhang
Copy link
Owner

Landed in 5.1.5

@kaelzhang
Copy link
Owner

kaelzhang commented May 22, 2020

However, Eslint depends on [email protected], so the fix is blocked by eslint/eslint#13294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants