question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
FDIMcommented, Dec 16, 2020

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

'no-restricted-imports': [
  'error', 
    {
      patterns: [
        '../*',
      ]
    }
],
2reactions
tonysyucommented, Feb 8, 2022

For what it’s worth, @ljharb’s suggestion to set up eslint to use the typescript resolver fixed the issue on my system; see the eslintrc.js settings in the description of https://github.com/import-js/eslint-plugin-import/issues/1392. That said, @FDIM’s suggestion is what I actually wanted for my project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-relative-parent-imports does not work at all? (repro repo ...
I'm using the @typescript-eslint/parser Example repo: https://github.com/sarink/eslint-plugin-import-no-relative-parent-imports-bug I ...
Read more >
ImportError : Attempted relative import with no known parent ...
I cannot reproduce OP's problem (imports work fine) and your solutions don't work, resulting in ModuleNotFoundError , while I'm using Python 3.8 ...
Read more >
Understanding relative and absolute imports in Next.js
Let's discuss Next.js absolute imports, relative imports, and different ways to implement them in your application.
Read more >
eslint-plugin-import - npm
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import ...
Read more >
Import and transfer tools - Alfresco Docs
It is not designed to fully synchronize the repository with the local file system ... If you need to troubleshoot or diagnose any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found