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

feat(eslint-plugin): add object-curly-spacing rule #2892

Merged
merged 7 commits into from Jan 18, 2021

Conversation

mpsijm
Copy link
Contributor

@mpsijm mpsijm commented Dec 21, 2020

Added new extended rule object-curly-spacing, thanks to @Kiikurage for the implementation in #1884.

Besides cherry-picking the commit of #1884, I've resolved @bradzacher's comments on the old PR and added a bunch more tests (copied from https://github.com/eslint/eslint/blob/master/tests/lib/rules/object-curly-spacing.js). @bradzacher also left the following comment:

I wonder if you could save all of the code duplication by "hacking" at the base rule?

eg:

TypeLiteral(node): void {
  rule.ObjectExpression({
    ...node,
    properties: node.members,
  } as any);
}

I tried to do this in mpsijm@5a4698e, but it made 10 tests fail. I didn't look too much into the details of the implementation as to see why, but I'm guessing it's because object type literals are more complicated than object expressions. If anyone is interested, you can compare the implementation to the original rule: https://github.com/eslint/eslint/blob/master/lib/rules/object-curly-spacing.js

  • tests
  • docs
  • typing update

Fixes #1784

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @mpsijm!

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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@bradzacher bradzacher added the enhancement: new base rule extension New base rule extension required to handle a TS specific case label Dec 21, 2020
@codecov
Copy link

codecov bot commented Dec 21, 2020

Codecov Report

Merging #2892 (f9f0e7e) into master (d02a40d) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2892      +/-   ##
==========================================
+ Coverage   92.78%   92.81%   +0.03%     
==========================================
  Files         311      312       +1     
  Lines       10458    10508      +50     
  Branches     2954     2969      +15     
==========================================
+ Hits         9703     9753      +50     
  Misses        348      348              
  Partials      407      407              
Flag Coverage Δ
unittest 92.81% <100.00%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
packages/eslint-plugin/src/configs/all.ts 100.00% <ø> (ø)
...es/eslint-plugin/src/rules/object-curly-spacing.ts 100.00% <100.00%> (ø)

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.

LGTM - thanks for picking this back up!

@bradzacher bradzacher changed the title feat(eslint-plugin): implement object-curly-spacing rule (#1784) feat(eslint-plugin): add object-curly-spacing rule Jan 18, 2021
@bradzacher bradzacher merged commit 32bd18d into typescript-eslint:master Jan 18, 2021
@mpsijm mpsijm deleted the 1784-object-curly-spacing branch January 18, 2021 07:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: new base rule extension New base rule extension required to handle a TS specific case
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[object-curly-spacing] One-line object types do not adhere to spacing rules
3 participants