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(eslint-plugin): [keyword-spacing] unexpected space before/after in import type #6095

Conversation

omril1
Copy link
Contributor

@omril1 omril1 commented Nov 26, 2022

PR Checklist

Overview

This is very hard to define correctly as the type keyword sits between already supported tokens from the base rule that have their own defined before/after.
For now, this is how I think the defining cases should be but I'm open to changing them or add more as you see fit

  • I'm not sure if I should add support for an overrides option for type, and how to do it with extending the base rule

@nx-cloud
Copy link

nx-cloud bot commented Nov 26, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit e8d5efc. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @omril1!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@netlify
Copy link

netlify bot commented Nov 26, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit e8d5efc
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6388fa61a7e44c000986d84d
😎 Deploy Preview https://deploy-preview-6095--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@omril1 omril1 changed the title fix(eslint-plugin) keyword-spacing unexpected space before/after in import type fix(eslint-plugin): keyword-spacing unexpected space before/after in import type Nov 26, 2022
@omril1 omril1 changed the title fix(eslint-plugin): keyword-spacing unexpected space before/after in import type fix(eslint-plugin): [keyword-spacing] unexpected space before/after in import type Nov 26, 2022
@codecov
Copy link

codecov bot commented Nov 26, 2022

Codecov Report

Merging #6095 (e8d5efc) into main (1dba257) will decrease coverage by 0.00%.
The diff coverage is 91.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6095      +/-   ##
==========================================
- Coverage   91.27%   91.26%   -0.01%     
==========================================
  Files         366      366              
  Lines       12419    12427       +8     
  Branches     3632     3638       +6     
==========================================
+ Hits        11335    11342       +7     
  Misses        774      774              
- Partials      310      311       +1     
Flag Coverage Δ
unittest 91.26% <91.66%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ackages/eslint-plugin/src/rules/keyword-spacing.ts 96.77% <91.66%> (-3.23%) ⬇️

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Did you mean to put this as a draft? Since it doesn't yet address the original issue, I'll convert it. Let me know if anything's unclear. And thanks for working on this!

node.specifiers?.[0]?.type === AST_NODE_TYPES.ImportDefaultSpecifier
) {
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought draft means you won't review it (Sorry, I guess it meant something else to me).

I opened it for review because I can't think of a way to solve it without adding an override option for the type keyword or should it use the existing option for the import keyword.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I just didn't realize there was a question associated with this! Sorry, i misinterpreted the discussion. Will think on it 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Or, actually, definitely yes. Since the type option doesn't exist in ESLint core and is TypeScript-specific, we should add in a feature for it. Yes please 😄

Copy link
Contributor Author

@omril1 omril1 Nov 26, 2022

Choose a reason for hiding this comment

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

Any example I can look at how to do that? The types seem looser than the schema validation (typed as overrides?: Record<string, { before?: boolean; after?: boolean;}> but adding type: { after: true } to object breaks the schema validation

OK, I found something similar to the no-magic-numbers rule

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as draft November 26, 2022 20:37
@omril1 omril1 marked this pull request as ready for review December 1, 2022 19:46
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

strange_bugfix

thanks so much for following up to fix this!

@bradzacher bradzacher changed the title fix(eslint-plugin): [keyword-spacing] unexpected space before/after in import type fix(eslint-plugin): [keyword-spacing] unexpected space before/after in import type Dec 2, 2022
@bradzacher bradzacher merged commit 98caa92 into typescript-eslint:main Dec 2, 2022
@omril1 omril1 deleted the fix/issue6063-keyword-spacing-unexpected-space-before branch December 2, 2022 04:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [@typescript-eslint/keyword-spacing] Unexpected space(s) before "{" in import type
3 participants