-
-
Notifications
You must be signed in to change notification settings - Fork 153
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: add new rule enforce-line-break #484
Conversation
…bove type declaration is on the 1st line, update tests
src/rules/enforceLineBreak.js
Outdated
fix (fixer) { | ||
return fixer.insertTextBeforeRange(node.leadingComments[0].range, '\n'); | ||
}, | ||
message: 'Please enter a line above type declaration', |
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.
I think the error messages general have the tone of New line required above type declaration
. Should we change to like that?
src/rules/enforceLineBreak.js
Outdated
fix (fixer) { | ||
return fixer.insertTextBefore(node, '\n'); | ||
}, | ||
message: 'Please enter a line above type declaration', |
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.
Should the message itself be a func that can be reused for both above and below?
const breakLineMessage = (direction) => `Please enter a line ${direction} type declaration`;
return; | ||
} | ||
|
||
if (node.loc.start.line !== 1) { |
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.
Just curious what does this do?
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.
This is so you won't get the error 'New line required above type declaration` if the type declaration happens to be on the first line.
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.
LGTM
🎉 This PR is included in version 5.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
New rule to enforce line breaks before and after type declarations.
Closes #476
@gajus