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

[Fix] no-extraneous-dependencies/TypeScript: do not error when importing type from dev dependencies #1820

Merged
merged 1 commit into from Jun 14, 2020
Merged

[Fix] no-extraneous-dependencies/TypeScript: do not error when importing type from dev dependencies #1820

merged 1 commit into from Jun 14, 2020

Conversation

fernandopasik
Copy link
Contributor

fixes #1618

This PR is to avoid error should be listed in the project's dependencies, not devDependencies. when only importing typescript types

@fernandopasik
Copy link
Contributor Author

@ljharb please can you review? :)

@fernandopasik fernandopasik changed the title No extraneous dependencies type import [import/no-extraneous-dependencies] Error when importing type from dev dependencies Jun 12, 2020
@coveralls
Copy link

coveralls commented Jun 12, 2020

Coverage Status

Coverage increased (+0.04%) to 97.847% when pulling 1f7422d on fernandopasik:no-extraneous-dependencies-type-import into 54eb51b on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 97.158% when pulling 70ba425 on fernandopasik:no-extraneous-dependencies-type-import into 54eb51b on benmosher:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 97.158% when pulling 70ba425 on fernandopasik:no-extraneous-dependencies-type-import into 54eb51b on benmosher:master.

],
})
})
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry about that one.

Would it be a good idea to add https://eslint.org/docs/rules/eol-last to the eslint config of the project?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would, thanks; i'll do that.


describe('TypeScript', function () {
getTSParsers()
.filter((parser) => parser !== require.resolve('typescript-eslint-parser'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why filter this one out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typescript-eslint-parser is the old parser and doesn't support the importKind property. That parser was not done at the time of typescript 3.8 which is the one that supports this feature

I've added it back with the cases as all invalid.

@ljharb ljharb changed the title [import/no-extraneous-dependencies] Error when importing type from dev dependencies [Fix] no-extraneous-dependencies/TypeScript: do not error when importing type from dev dependencies Jun 13, 2020
@ljharb ljharb merged commit 1f7422d into import-js:master Jun 14, 2020
@fernandopasik fernandopasik deleted the no-extraneous-dependencies-type-import branch June 14, 2020 00:06
@bradennapier
Copy link
Contributor

Awesome, was just coming to ask if this was potentially possible - thanks for your work on this @fernandopasik ! Looking forward to this being released.

namjul pushed a commit to namjul/gumption-ui that referenced this pull request Feb 23, 2021
TIL: importing just typescript types using the keyword `import type` the
eslint `no-extraneous-dependencies` does not get applied.
I might be misusing it in this case.
import-js/eslint-plugin-import#1820
@AndyOGo
Copy link
Contributor

AndyOGo commented Mar 14, 2023

@fernandopasik
This PR is great.
Though it doesn't support inline type imports.

// works
import type { Foo } from "types-package";

// doesn't work yet
import { type Foo } from "types-package".

@fernandopasik
Copy link
Contributor Author

Hey @AndyOGo ! Thanks, I think typescript introduced those after this PR

@AndyOGo
Copy link
Contributor

AndyOGo commented Mar 15, 2023

@fernandopasik
@ljharb
Thanks for your quick reply.

I admire your work.
And I provided a patch to support inline types.
#2735

@fernandopasik
Copy link
Contributor Author

😳 You must mean you only admire @ljharb work, he's the only legend there

thank you! 🙇‍♂️

@AndyOGo
Copy link
Contributor

AndyOGo commented Mar 15, 2023

Of course, I admire @ljharb bombastic work a lot.

In general I admire people who seek to understand semantics, to help and make contributions.
Maybe my opinion is cynical, though to my observation only a few rare developers take the time to understand e.g. AST trees, take part in a project for free, help making it better.

So, I admire both of you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[import/no-extraneous-dependencies] Problems when only using types
5 participants