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
Chore: Use messageIds in some of the core rules #9648
Changes from 10 commits
3544552
8e25a20
ff2f9c9
ef410f7
5da3f4c
a71366d
7b0e8f0
6c90475
17e2d8a
4b65957
e8474b6
db0f4a1
916a9a4
3f505f7
47ace63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,13 @@ module.exports = { | |
}, | ||
additionalProperties: false | ||
} | ||
] | ||
], | ||
messages: { | ||
noAfter: "There should be no space after '{{tokenValue}}'.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See notes in array-bracket-newline. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
noBefore: "There should be no space before '{{tokenValue}}'.", | ||
after: "A space is required after '{{tokenValue}}'.", | ||
before: "A space is required before '{{tokenValue}}'." | ||
} | ||
}, | ||
create(context) { | ||
const spaced = context.options[0] === "always", | ||
|
@@ -76,7 +82,7 @@ module.exports = { | |
context.report({ | ||
node, | ||
loc: token.loc.start, | ||
message: "There should be no space after '{{tokenValue}}'.", | ||
messageId: "noAfter", | ||
data: { | ||
tokenValue: token.value | ||
}, | ||
|
@@ -98,7 +104,7 @@ module.exports = { | |
context.report({ | ||
node, | ||
loc: token.loc.start, | ||
message: "There should be no space before '{{tokenValue}}'.", | ||
messageId: "noBefore", | ||
data: { | ||
tokenValue: token.value | ||
}, | ||
|
@@ -120,7 +126,7 @@ module.exports = { | |
context.report({ | ||
node, | ||
loc: token.loc.start, | ||
message: "A space is required after '{{tokenValue}}'.", | ||
messageId: "after", | ||
data: { | ||
tokenValue: token.value | ||
}, | ||
|
@@ -140,7 +146,7 @@ module.exports = { | |
context.report({ | ||
node, | ||
loc: token.loc.start, | ||
message: "A space is required before '{{tokenValue}}'.", | ||
messageId: "before", | ||
data: { | ||
tokenValue: token.value | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,12 @@ module.exports = { | |
} | ||
] | ||
} | ||
] | ||
], | ||
|
||
messages: { | ||
noLineBreak: "There should be no linebreak here.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See notes in array-bracket-newline. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
lineBreak: "There should be a linebreak after this element." | ||
} | ||
}, | ||
|
||
create(context) { | ||
|
@@ -100,7 +105,7 @@ module.exports = { | |
start: tokenBefore.loc.end, | ||
end: token.loc.start | ||
}, | ||
message: "There should be no linebreak here.", | ||
messageId: "noLineBreak", | ||
fix(fixer) { | ||
if (astUtils.isCommentToken(tokenBefore)) { | ||
return null; | ||
|
@@ -149,7 +154,7 @@ module.exports = { | |
start: tokenBefore.loc.end, | ||
end: token.loc.start | ||
}, | ||
message: "There should be a linebreak after this element.", | ||
messageId: "lineBreak", | ||
fix(fixer) { | ||
return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n"); | ||
} | ||
|
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'm struggling with these messageIds, partially because a name like
noOpen
might imply either that there is a linebreak but should not be (which is what "noOpen" means here), or that there is no linebreak but should be. I would suggest a name likeshouldNotHaveLinebreakOpen
ordoesNotHaveLinebreakOpen
(or slightly less verbose) to make it clear what "no" means here. I like the idea of having messageIds close to what the messages say, so of the two, I would probably favorshouldNotHaveLinebreakOpen
.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.
unexpectedOpeningLinebreak
?