capitalized-comments conflicts with default-case ("// no default")
See original GitHub issueTell us about your environment
- ESLint Version: 3.11.1
- Node Version: 7.2.0
- npm Version: 4.0.2
What parser (default, Babel-ESLint, etc.) are you using? babel
Please show your full configuration:
module.exports = {
rules: {
'capitalized-comments': 1,
'default-case': 1,
},
}
What did you do? Please include the actual source code causing the issue.
The following code snippet triggers the capitalized-comments
rule violation for the "no default"
comment.
Fixing it by using "No default"
instead, the rule default-case
is triggered because "No default"
is not recognised as a valid marker of intentionally not providing a default case.
switch (item) {
case 'this':
return 1
case 'that':
return 2
// no default
}
What did you expect to happen?
I expected that using "No default"
would not trigger the default-case
rule violation.
What actually happened? Please include the actual, raw output from ESLint.
The default-case
rule violation was triggered because it does not recognise "No default"
as a valid “I intentionally omitted default case here” marker.
Issue Analytics
- State:
- Created 7 years ago
- Comments:23 (23 by maintainers)
Top GitHub Comments
Let’s go ahead and implement the original proposal (to just make “// no default” case-insensitive), and then maybe we can reconsider making all regexes case-insensitive later.
(EDIT 2016-11-29T19:17:00Z: Proposal now favors allowing full case insensitivity for default pattern only. No changes will be proposed for custom commentPatterns.)
Here’s a proposal (and I’ll champion this).
What rule do you want to change?
default-case
Does this change cause the rule to produce more or fewer warnings?
Fewer.
How will the change be implemented? (New option, new default behavior, etc.)?
New default behavior: Make the “no default” default comment pattern case-insensitive in the
default-case
rule.Please provide some example code that this change will affect:
What does the rule currently do for this code?
Example 1: Warns on the
// No default
comment Example 2: Does not warn on the// no default
comment Example 3: Warns on the// NO Default
commentWhat will the rule do after it’s changed?
Example 1: No longer warn on
// No default
Example 2: Continue to not warn on// no default
Example 3: No longer warn on// NO Default
comment