-
Notifications
You must be signed in to change notification settings - Fork 890
[Bugfix] Fix for whitespace rule requiring extra space in ImportType in TS 2.9 #3992
Conversation
src/rules/whitespaceRule.ts
Outdated
@@ -296,6 +296,10 @@ function walk(ctx: Lint.WalkContext<Options>) { | |||
} | |||
break; | |||
case ts.SyntaxKind.ImportKeyword: | |||
if (parent.kind === (ts.SyntaxKind as any).ImportType) { |
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.
can you first check if ts.SyntaxKind.ImportType
is defined?
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.
Sure, done. Tho it seems redundant to me in this case, hence why it wasn't there in the first place. 😄
Hi @Tenga, just wanted to check if you have signed the CLA as that appears to be the remaining test left to pass. The cla-bot has been a little confused lately, so if you're unsure what the CLA is, I've copied its message from another PR:
|
Hey @johnwiseheart. I'm aware of it, I'm just waiting for the go-ahead from my employer before signing. ⌚️ |
@johnwiseheart CLA has been signed. |
@@ -296,6 +296,10 @@ function walk(ctx: Lint.WalkContext<Options>) { | |||
} | |||
break; | |||
case ts.SyntaxKind.ImportKeyword: | |||
if ((ts.SyntaxKind as any).ImportType !== undefined && parent.kind === (ts.SyntaxKind as any).ImportType) { |
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.
Hmm, I don't like having to cast as any. What is the issue here - is it that ts.SyntaxKind.ImportType
is a ts2.9+ thing?
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.
Yup.
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.
@giladgray @suchanlee @jkillian any ideas on how to work around this?
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.
Let's define a shared isImportKeyword
in src/utils.ts
similar to existing helper functions from tsutils.
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.
Code generally looks good; just one comment on the isImportKeyword
function.
@@ -296,6 +296,10 @@ function walk(ctx: Lint.WalkContext<Options>) { | |||
} | |||
break; | |||
case ts.SyntaxKind.ImportKeyword: | |||
if ((ts.SyntaxKind as any).ImportType !== undefined && parent.kind === (ts.SyntaxKind as any).ImportType) { |
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.
Let's define a shared isImportKeyword
in src/utils.ts
similar to existing helper functions from tsutils.
While I'm happy this fairly thin PR will finally be resolved, it leaves a bad taste in my mouth. This PR has been, with my full understanding, sitting in the queue for months, with me waiting for feedback/advice on how you guys would like to resolve a style problem. The end result is merging a PR that openly rips 90% of the work from this PR, because it was hard to wait a couple of hours to amend this PR with a one-liner change? ¯\_(ツ)_/¯ |
@Tenga Thanks for the feedback. You're right, and I'm sorry for marginalizing your contribution here. I should have waited a few days before merging in the other PR. For context on the sitting in the queue for months, TSLint hasn't had an active maintainer in those months, and I'm coming in now as a new maintainer to clean up the issues and PR queues. My goal here was to minimize the amount of pending work we have, but I went a bit overboard and didn't stop to think about this. If you send another PR, I can promise the same thing won't happen twice. |
@JoshuaKGoldberg Appreciate the response. 👍 If I encounter an opportunity to contribute again, I'll certainly do so. Just to clarify as I probably should've probably phrased it better. I understand that OSS is hard. "Sitting in queue for months" was not meant to be a diss or dissatisfaction with that, just the understanding of the reality. (Contributing guidelines prepare you for that anyway. 😛) |
PR checklist
Overview of change:
Fixes the bug where the new
ImportType
syntax required extra spacing whenwhitespace
rule was enabled.Is there anything you'd like reviewers to focus on?
SyntaxKind
asany
and let theImportKind
end upundefined
to fail the check.CHANGELOG.md entry:
[bugfix]
whitespace
rule no longer requires extra spaces with the TS 2.9 import type syntax