Skip to content

Commit

Permalink
Make ignorePaths glob patterns relative to prcoess.cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed Mar 13, 2020
1 parent 64c6999 commit d1f0632
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/rules/default-import-match-filename.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enforces default import name to match filename. Name matching is case-insensitiv

#### `ignorePaths`

This option accepts an array of glob patterns. The glob patterns are to be matched against the resolved **abosolute** path of import statements. As an example, with the option `{ignorePaths: ['**/foo.js']}`, the statement `import whatever from './foo.js'` is ignored, since `./foo.js` resolves to, say, `/home/me/thing/foo.js`, which matches the glob pattern `**/foo.js`.
This option accepts an array of glob patterns. An import statement will be ignored if the import source path matches some of the glob patterns, where the glob patterns are relative to the current working directory where the linter is launched. For example, with the option `{ignorePaths: ['**/foo.js']}`, the statement `import whatever from './foo.js'` will be ignored.

### Fail

Expand Down
4 changes: 3 additions & 1 deletion src/rules/default-import-match-filename.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ function getFilename(path, context) {
function isIgnored(context, ignorePaths, path) {
const resolvedPath = resolve(path, context)
return resolvedPath != null &&
ignorePaths.some(pattern => minimatch(resolvedPath, pattern))
ignorePaths.some(pattern =>
minimatch(Path.relative(process.cwd(), resolvedPath), pattern)
)
}

module.exports = {
Expand Down

0 comments on commit d1f0632

Please sign in to comment.