-
Notifications
You must be signed in to change notification settings - Fork 199
Used undefined instead of null. #565
Used undefined instead of null. #565
Conversation
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 looks fantastic. I'm really excited to get it in!
Can you just replace options: undefined
back to options: null
?
@@ -17,7 +17,7 @@ export class Rule extends Lint.Rules.AbstractRule { | |||
ruleName: 'chai-prefer-contains-to-index-of', | |||
type: 'maintainability', | |||
description: 'Avoid Chai assertions that invoke indexOf and compare for a -1 result.', | |||
options: null, | |||
options: undefined, |
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 one always confused me. TSLint itself describes the rule's options as:
Schema of the options the rule accepts.
The first boolean for whether the rule is enabled or not is already implied.
This field describes the options after that boolean.
If null, this rule has no options and is not configurable.
...so we should probably default this to null
.
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.
Ah, yes, you're absolutely right. I had a look at that comment as well as how the options are used in TSLint before I made the changes and it looked like it shouldn't matter if undefined is used, but of course the one place I didn't look at was what TSLint uses for their own rules, and they use null.
Yes, let's turn them back on there. Those files are a little older. |
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.
👍
@JoshuaKGoldberg, I'm having a lot of issues with this change in the recommended ruleset. As much as I would love to stick to Are you at all opposed to removing this from the recommended ruleset? |
You can turn the rule off in the config file and still use the recommended ruleset. {
"extends": ["tslint-microsoft-contrib"],
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"rules": {
"no-null-keyword": false
}
} As the readme says,
|
@reduckted, thanks, we're doing that for a few rules indeed. FWIW, I do find this rule useful, I just don't think it should be recommended/enabled by default. Many packages out there do not play nice with this, and as we noticed on our end, fixing violations recommended by this rule on things outside of our control (dependencies) will often break. |
Fixes #490.
I've changed the code to use
undefined
instead ofnull
, except where it's actually needed, which was only a handful of places:There's one thing I'm not sure if I should change (I've left it unchanged for now). The additional_rule_metadata.json and recommended_ruleset.js files both suggest turning the
no-null-keyword
off. Given that it's now turned on, do those files need to change?