-
Notifications
You must be signed in to change notification settings - Fork 889
no-shadowed-variable: add new option 'temporalDeadZone' #3389
Conversation
Adds a new option to ignore variable shadowing when it occurs in the temporal dead zone of the shadowed block scoped variable. Setting this option to `true` will restore the pre-v5.5.0 behavior, but only for block scoped declarations (parameters, classes, enums, let, const). Fixes: #3078
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.
mostly looks good, small comments
src/rules/noShadowedVariableRule.ts
Outdated
@@ -35,6 +35,26 @@ export class Rule extends Lint.Rules.AbstractRule { | |||
and \`"typeParameter"\`. Just set the value to \`false\` for the check you want to disable. | |||
All checks default to \`true\`, i.e. are enabled by default. | |||
Note that you cannot disable variables and parameters. | |||
|
|||
The option \`"temporalDeadZone"\` defaults to \`false\`. When set to \`true\` parameters, classes, enums and variables declared |
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 think it should default to true
to align with the other options -- they are all true
by default, which indicates that a certain type of check is enabled. Here, we intend to enable checking within temporal dead zones by default; requiring the option to be false
would make sense to opt-out of the check -- this would make the rule less strict (similar to setting false
on the other options).
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.
So you basically want me to swap true and false here and in all conditions? Sounds reasonable
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.
Yes I would like you to swap true and false in all the new code you've added (leave the existing options as they were)
|
||
export function foo(wam: boolean) { | ||
if (wam) { | ||
const now = new Date(); |
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.
would you mind marking this up with comments to indicate where the option is taking effect? similar to your example in the docs, just a simple // not an error with tdz disabled
Updated as suggested |
…nto no-shadowed-variable-tdz
PR checklist
Overview of change:
Adds a new option to ignore variable shadowing when it occurs in the temporal dead zone of the shadowed block scoped variable.
Setting this option to
true
will restore the pre-v5.5.0 behavior, but only for block scoped declarations (parameters, classes, enums, let, const).Fixes: #3078
Is there anything you'd like reviewers to focus on?
CHANGELOG.md entry:
[new-rule-option]
"temporalDeadZone"
forno-shadowed-variable
to ignore shadowing in the temporal dead zone of classes, parameters, enums and variables declared withlet
orconst