import-js/eslint-plugin-import
no-restricted-paths - absolute path expected where relative path is provided
オープン
#1,890 opened on 2020/08/24
help wanted
Repository metrics
- Stars
- (5,939 個のスター)
- PR merge metrics
- (平均マージ 138d 22h) (30d で 3 merged PRs)
説明
I am having trouble with the configuration for this rule and believe there is a bug in the way paths are resolved
// see https://github.com/benmosher/eslint-plugin-import/blob/master/src/rules/no-restricted-paths.js#L72
// it returns a relative path, are we sure thats what we want?
const absoluteImportPath = resolve(importPath, context)
Here we use resolve which comes from utils/resolve and it returns a relative path
should we be using path.resolve to return an absolute path instead? I am happy to open a PR with the change once confirmed
to be clear the change I am proposing is
- const absoluteImportPath = resolve(basePath, context)
+ const absoluteImportPath = path.resolve(basePath, importPath);