-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
chore: enable @typescript-eslint/ban-ts-comment
#11326
chore: enable @typescript-eslint/ban-ts-comment
#11326
Conversation
name: 'vite-remove-polyfill-import', | ||
post({ path }) { | ||
path.get('body').forEach((p) => { | ||
if (t.isImportDeclaration(p)) { | ||
// @ts-expect-error | ||
if (t.isImportDeclaration(p.node)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.isImportDeclaration
only expects Node
to be passed to the argument. p
is NodePath
and p.node
is Node
.
The previous code also works because NodePath
and Node
both has type
property.
https://github.com/babel/babel/blob/df733b18ae88f370caddecc30c6d96844007c411/packages/babel-types/src/validators/generated/index.ts#L1062-L1078
But given that t.isImportDeclaration
narrows the argument to ImportDeclaration
instead of NodePath<ImportDeclaration>
, passing p.node
is more correct.
We could use p.isImportDeclaration()
instead of t.isImportDeclaration(p.node)
, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation, it looks good as is!
the default option already contains what I requested
Description
superseds close #8413
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).