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

no-missing-import does not work with "paths" from "tsconfig.json" #84

Closed
Zamiell opened this issue Feb 2, 2023 · 3 comments · Fixed by #139
Closed

no-missing-import does not work with "paths" from "tsconfig.json" #84

Zamiell opened this issue Feb 2, 2023 · 3 comments · Fixed by #139

Comments

@Zamiell
Copy link

Zamiell commented Feb 2, 2023

In a monorepo, you typically use the "paths" option inside of the "tsconfig.json" file to make your individual packages aware of each other like this:

tsconfig.json

{
    "paths": {
      "foo": ["packages/foo/src/index.ts"],
      "bar": ["packages/bar/src/index.ts"],
    },
}

However, this triggers false positives for no-missing-import.

@wdzeng
Copy link

wdzeng commented Jul 30, 2023

Any updates on this?

JoshuaKGoldberg added a commit to JoshuaKGoldberg/create-typescript-app that referenced this issue Sep 21, 2023
## PR Checklist

- [x] Addresses an existing open issue: fixes #864; fixes #866
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Adds:

- `--exclude-lint-deprecation`
- `--exclude-lint-eslint`
- `--exclude-lint-jsdoc`
- `--exclude-lint-regex`
- `--exclude-lint-strict`
- `--exclude-lint-stylistic`

Assorted cleanups:

* Removes `eslint-config-prettier` since I believe none of the
recommended configs include rules impacted by it (yay!)
* Removes `eslint-plugin-import` as TypeScript's `"moduleResolution":
"NodeNext"` will report on a missing file extension in an import
* As of eslint-community/eslint-plugin-n#24 I
don't think `n/no-missing-import` is buggy enough to need to be disabled
* eslint-community/eslint-plugin-n#84 is still
in effect, but this template doesn't use `paths`.
* Removes the ESLint config comment now that most users are on a simpler
"common" config
* Finally add some high-level unit testing for `createESLintRC` to help
validate the changes
@scagood
Copy link

scagood commented Oct 26, 2023

🤔 I have not had this issue in my monorepos, could you make a small reproduction repository?


Here are a couple of screenshots from a yarn v3 repo:

image image

I have not needed the "paths" property at all for importing files, I have only needed this for importing additional types that I don't directly import, eg in another package:

image

For reference, I do think we should add paths support into the plugin. I just also want to understand why the current method of checking imports does not work 👀

@scagood
Copy link

scagood commented Nov 6, 2023

I think I found the issue, it turns out that when the depended upon package is not built (at least once) then the file shows up as missing!

scagood added a commit to scagood/eslint-plugin-n that referenced this issue Nov 26, 2023
scagood added a commit to scagood/eslint-plugin-n that referenced this issue Dec 11, 2023
scagood added a commit to scagood/eslint-plugin-n that referenced this issue Jan 2, 2024
scagood added a commit to scagood/eslint-plugin-n that referenced this issue Jan 9, 2024
aladdin-add added a commit that referenced this issue Jan 9, 2024
* feat: Use enhanced-resolve for imports

* chore: Improve the metadata from "ImportTarget"

* chore: remove "enhanced-resolve" from "no-hide-core-modules"

* test: Add a test for #66

* feat!: Allow ts paths aliases (#84)

* feat: Allow for "allowImportingTsExtensions" (#134)

* feat: Add test for import maps (#147)

* Update lib/util/import-target.js

Co-authored-by: Sebastian Good <2230835+scagood@users.noreply.github.com>

* test: Add test for n/no-missing-require eslint/use-at-your-own-risk

* chore: Remove esbuild

* feat: Allow for settings.cwd to be used before process.cwd

* chore: replace reference to eslint/use-at-your-own-risk

* chore: Remove more unused packages

* chore: update rule test options to flat config

* fix: incorrect env in tests

---------

Co-authored-by: 唯然 <weiran.zsd@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants