Eslint-plugin-import: no-relative-parent-imports does not work at all? (repro repo included)

Created on 14 Jan 2020  路  5Comments  路  Source: benmosher/eslint-plugin-import

I can't seem to get this rule to work. I'm using the @typescript-eslint/parser

Example repo: https://github.com/sarink/eslint-plugin-import-no-relative-parent-imports-bug

I believe the relevant lines from the debug log are:

2020-01-14T20:05:00.042Z eslint:file-enumerator Yield: child.ts
2020-01-14T20:05:00.042Z eslint:cascading-config-array-factory Load config files for /Users/sarink/Projects/eslint-plugin-import-no-relative-parent-imports-bug/src/children.
2020-01-14T20:05:00.042Z eslint:cascading-config-array-factory Cache hit: /Users/sarink/Projects/eslint-plugin-import-no-relative-parent-imports-bug/src/children.
2020-01-14T20:05:00.042Z eslint:cli-engine Lint /Users/sarink/Projects/eslint-plugin-import-no-relative-parent-imports-bug/src/children/child.ts
2020-01-14T20:05:00.042Z eslint:linter Linting code for /Users/sarink/Projects/eslint-plugin-import-no-relative-parent-imports-bug/src/children/child.ts (pass 1)
2020-01-14T20:05:00.042Z eslint:linter Verify
2020-01-14T20:05:00.042Z eslint:linter With ConfigArray: /Users/sarink/Projects/eslint-plugin-import-no-relative-parent-imports-bug/src/children/child.ts
2020-01-14T20:05:00.075Z eslint:linter Generating fixed text for /Users/sarink/Projects/eslint-plugin-import-no-relative-parent-imports-bug/src/children/child.ts (pass 1)
2020-01-14T20:05:00.075Z eslint:source-code-fixer Applying fixes
2020-01-14T20:05:00.075Z eslint:source-code-fixer shouldFix parameter was false, not attempting fixes
2020-01-14T20:05:00.076Z eslint:file-enumerator Leave the directory: /Users/sarink/Projects/eslint-plugin-import-no-relative-parent-imports-bug/src/children
2020-01-14T20:05:00.076Z eslint:ignore-pattern Check {
  filePath: '/Users/sarink/Projects/eslint-plugin-import-no-relative-parent-imports-bug/src/parent.ts',
  dot: false,
  relativePath: 'src/parent.ts',
  result: false
}

It looks like the plugin is seeing "src/parent.ts", but in fact in the code it is written like "../parent"?

Thanks!

bug help wanted typescript

All 5 comments

Bump? :(

I'd be happy to accept a PR that fixes it; it also might be an issue in the typescript resolver.

I'm not sure how to further debug it, do you have any suggestions?

@ljharb I made a pull request, but you might want to look carefully at it, I couldn鈥檛 figure out how to add tests for this

Just bumped into this as well. Looks like workaround is easy, use common rule?

'no-restricted-imports': [
  'error', 
    {
      patterns: [
        '../*',
      ]
    }
],
Was this page helpful?
0 / 5 - 0 ratings