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

[eslint-plugin-packlets] Linting does not mark local imports when using path aliases #3121

Open
trane opened this issue Dec 31, 2021 · 0 comments · May be fixed by #3122
Open

[eslint-plugin-packlets] Linting does not mark local imports when using path aliases #3121

trane opened this issue Dec 31, 2021 · 0 comments · May be fixed by #3122

Comments

@trane
Copy link
Contributor

trane commented Dec 31, 2021

Summary

The packlets plugin checks local imports to ensure that we only import local code from other packlets — but there is a common edge case in Typescript repositories for which this fails: imports that use aliases defined in the tsconfig.json's compilerOptions.paths.

Details

Imagine this directory structure:

repo
├── app
└── src
    └── packlets
        ├── logger
        └── metrics

Now take this import statment in src/packlets/logger/log.ts:

import { Thing } from '../../app' // ERROR

However, if your tsconfig.json had the following configuration:

{
  "compilerOptions": {
    "paths": {
      "@app": ["app"],
    }
  }
}

An alias in your src/packlets/logger/log.ts would pass linting:

import { Thing } from '@app' // ALLOWED

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@rushstack/eslint-plugin-packlets version? 0.3.4
Operating system? Mac
Would you consider contributing a PR? Yes
TypeScript compiler version? 4.5.4
Node.js version (node -v)? v14.17.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs triage
Development

Successfully merging a pull request may close this issue.

1 participant