Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[new-rule-request] : Enum operator spacing #2536

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

Closed
doumart opened this issue Sep 10, 2020 · 5 comments · Fixed by #2593
Closed

[new-rule-request] : Enum operator spacing #2536

doumart opened this issue Sep 10, 2020 · 5 comments · Fixed by #2593
Labels
enhancement: new plugin rule New rule request for eslint-plugin package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@doumart
Copy link
Contributor

doumart commented Sep 10, 2020

enum Direction {
  UP= 1
  RIGHT= 2
  LEFT =4
  DOWN =8
}

Given this enum, it would be a good rule to enforce spacing between =.

correct

enum Direction {
  UP = 1
  RIGHT = 2
  LEFT = 4
  DOWN = 8
}

I searched the repo and didn't found a rule for that.

@doumart doumart added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Sep 10, 2020
@bradzacher bradzacher added enhancement: new plugin rule New rule request for eslint-plugin and removed triage Waiting for team members to take a look labels Sep 10, 2020
@doumart
Copy link
Contributor Author

doumart commented Sep 18, 2020

Wish me luck i'm trying to do it. PR soon

@bradzacher
Copy link
Member

This could also be build as an extension rule on top of space-infix-ops

@doumart
Copy link
Contributor Author

doumart commented Sep 19, 2020

@bradzacher if i understand correctly i just add extendBaseRule:true to my rule (rename it to space-infix-ops) and that's it? Do you know any documentation on how to make an extension rule? For now a made a new rule that work and is ready to be put in PR (test, lint and all)

@bradzacher
Copy link
Member

we unfortunately don't have any tutorials or docs on writing rules - it's on the todo list.

The best documentation is examples.. kind of.
https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#extension-rules

Some direct examples:

an extension rule is a rule that either:

  • literally extends a base rule (as in the above examples) by overriding or adding additional selectors
  • forks a base rule by copying the source code and modifying it appropriately.

Which path to take depends on the rule itself and how it's written. Sometimes you need access to internal rule logic so you're stuck forking it. Other times you can just add selectors you need.

@doumart
Copy link
Contributor Author

doumart commented Sep 19, 2020

Thanks i'll read this and make changes!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: new plugin rule New rule request for eslint-plugin package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants