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
New: line-comment-position
rule (fixes #6077)
#6953
Conversation
@alberto, thanks for your PR! By analyzing the annotation information on this pull request, we identified @nzakas, @mysticatea and @gyandeeps to be potential reviewers |
LGTM |
}, | ||
|
||
create(context) { | ||
const DEFAULT_IGNORE_PATTERN = "^\\s*(?:eslint|jshint\\s+|jslint\\s+|istanbul\\s+|globals?\\s+|exported\\s+|jscs|falls?\\s?through)"; |
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.
If this is constant and can't be overridden, I would lean towards using a regex literal here. Helps avoid Leaning Toothpick Syndrome.
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 used a string for symmetry with ignorePattern
.
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.
Sure, but it's internal. Using a string here results in a performance hit,
and I'm not convinced that it's more readable either.
On Aug 25, 2016 5:31 PM, "alberto" notifications@github.com wrote:
In lib/rules/line-comment-position.js
#6953 (comment):
ignorePattern: {
type: "string"
},
applyDefaultPatterns: {
type: "boolean"
}
},
additionalProperties: false
}
]
}
]
- },
- create(context) {
const DEFAULT_IGNORE_PATTERN = "^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs|falls?\s?through)";
I used a string for symmetry with ignorePattern.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/eslint/eslint/pull/6953/files/55e1849ca32affa2fb639624d14c153cdbd470d0#r76337140,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AARWejQEM9RWQjG8h4TAyuPn6uZB_Dh7ks5qjhe-gaJpZM4JpTWN
.
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.
My motivation was that, even if it is internal, the rule source is linked in the docs and could be used as a reference for ignorePattern
. As for performance, the RegExp is created once per file, so I'm not sure there is much of a performance hit.
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.
Tie goes to the author when it's a preference discussion. Let's move on. :)
LGTM except two small nitpicks (one empty line that could be collapsed, one suggestion of using regex literal instead of string that will be passed into |
@@ -0,0 +1,100 @@ | |||
# enforce position of line comments (line-comment-position) | |||
|
|||
Line comments can be positioned above or beside code. This rule helps teams maintain a consistent style. |
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 section is supposed to be an introduction to the concept that the rule covers. It helps to show some examples and explain that some style guides prefer one or the other.
Lgtm, just a note on the docs. I don't think it's with putting the regular expression in the docs. It's hard to understand as it is, so better to leave in the code. |
LGTM |
What issue does this pull request address?
#6077
What changes did you make? (Give an overview)
Created new rule
line-comment-position
Is there anything you'd like reviewers to focus on?