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
Rule Proposal: line-comment-position #6077
Comments
What's the point of the |
{
"comment-position": {
"position": "beside",
"overrides": {
"block": "any"
}
}]
} |
Ok, so it would be an option just for the overrides, not for position. If we want to extend the original rule to also check for block comments, I would propose the following schema (syntax errors aside):
|
Sounds good to me, except {
enum: ["above", "beside"]
},
{
type: "object",
properties: {
block: {
anyOf: [
{
enum: ["above", "beside"]
},
{
type: "object",
properties: {
position: {
enum: ["above", "beside"]
},
ignoreWords: {
type: "array",
items: {type: "string"},
uniqueItems: true
}
},
additionalProperties: false
}
]
},
line: {
anyOf: [
{
enum: ["above", "beside"]
},
{
type: "object",
properties: {
position: {
enum: ["above", "beside"]
},
ignoreWords: {
type: "array",
items: {type: "string"},
uniqueItems: true
}
},
additionalProperties: false
}
]
}
},
additionalProperties: false
} |
Do we need to consider having |
Do you think |
Because |
Regexp support sounds good to me. |
Actually, original JSCS rule ignores block comments. |
Yeah, I think it's better to limit ourselves to what the original rule does. |
I updated this proposal by the result of discussion. |
I would use |
I updated it. |
@eslint/eslint-team I can champion this one if it gets accepted |
👍 |
2 similar comments
👍 |
👍 |
For what it's worth, our default comment pattern to relax |
@platinumazure thank you! I updated it. |
Does the acceptance of this rule this mean that the |
@SpadeAceman Not sure why that rule should be deprecated-- it's a valid use case which is orthogonal to the use cases in this proposal. |
I've taken a closer look, and it still seems to me that the functionality of |
We have deprecated old rules and superseded them with new rules in the past. We could theoretically do the same here, if deemed worthwhile. That said, the bar is pretty high. |
@SpadeAceman there is some overlap, but this doesn't cover every use case. This rule only deals with line comments, while |
I'm working on this and I have one question. If a custom |
Replacing was my intention because I thought good that there is a way to opt the default ignored patterns out. I don't have strong opinions here. |
I like replacing on principle (always a bad idea to lock a developer into a certain pattern). However it would be convenient if we provided a way to add patterns. Could we do something like "ignoreDefaultPatterns: true" to allow users to add patterns while simultaneously continuing to ignore the patterns ignored by default? (Pick a better name for the option, of course, but you get the idea.) |
From validateCommentPosition.
This rule will enforce the position of line comments.
position
"above"
(default) - Requires to locate comments above codes."beside"
- Requires to locate comments beside codes.ignorePattern
(default is"^\s*(?:eslint|jshint|jslint|istanbul|global|exported|jscs|falls?\s?through)"
) - If the comment content matches the given regexp pattern, this rule ignore the comment.The text was updated successfully, but these errors were encountered: