-
Notifications
You must be signed in to change notification settings - Fork 885
Track and restore initial or previous rule state for one line lint switches (fixes #1624) #1634
Conversation
I've updated this pull request with rework for how enabled/disabled states are tracked for file.
I've removed test cases for At this point I think that work is finished and PR is ready for review. |
I haven't found any docs on my question so I want to clarify it here: What is proper way for this repo to make branch up to date with |
It doesn't matter if you merge or rebase since we just squash the commit before merging into master |
99a8f7f
to
0e26676
Compare
@@ -164,19 +164,19 @@ class MultiLinter { | |||
|
|||
private getEnabledRules(fileName: string, source?: string, configuration: IConfigurationFile = DEFAULT_CONFIG): IRule[] { | |||
const sourceFile = this.getSourceFile(fileName, source); | |||
const isJs = fileName.substr(-3) === ".js"; |
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.
Found this during PR update.
I believe that this check should include .jsx
files too. Something like /\.jsx?$/i.test(fileName)
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, good catch
Rebased and updated PR with recent changes in |
0e26676
to
471d162
Compare
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.
looks good in general. The enable-line
and enable-next-line
cases still work right? Like nothing blows up?
}); | ||
|
||
if (end) { | ||
// switchRule method is only called when rule state changes therefore we can safely use opposite state |
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.
switchRule
-> switchRuleState
* We're assuming both lists are already sorted top-down so compare the tops, use the smallest of the two, | ||
* and build the intervals that way. | ||
/** | ||
* creates disabled intervals for rule based on list of swithers for it |
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.
swithers
-> switchers
} | ||
|
||
// use same logic as in AbstractRule | ||
function isEnabled(value: any): boolean { |
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.
factor out and put in Utils
@nchen63 thank you for review.
Yes. Actually there already were tests for
|
@IllusionMH Looks good. Thanks! |
This PR makes
EnableDisableRulesWalker
aware of initial rules configuration for file.This allows track rule state during file parsing and restore proper rule state after it was disabled for single line (with
disable-line
ordisable-next-line
switchers).Todo:
tslint:(disable|enable)
casesAdd tests for(it was early morning and I've missed that this rules aren't documented)enable-line
andenable-next-line
switchersenableDisableRuleMap
if rule state doesn't changeETA: October, 23rd