Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Option added to no-consecutive-blank-lines #1650

Merged
merged 2 commits into from
Oct 28, 2016
Merged

Option added to no-consecutive-blank-lines #1650

merged 2 commits into from
Oct 28, 2016

Conversation

nomaed
Copy link
Contributor

@nomaed nomaed commented Oct 22, 2016

Added an optional argument to no-consecutive-blank-lines rule to allow specifying the maximum number of allowed blank lines to appear in sequence, instead of only allowing a hard limit of 1.

If no option is specified, the old value of 1 is used, thus the rule is fully backwards compatible.

Similar to ESLint’s no-multiple-empty-lines rule “Max” option:
http://eslint.org/docs/rules/no-multiple-empty-lines

Added an optional argument to no-consecutive-blank-lines rule to allow
specifying maximum number of allowed blank lines instead of only
allowing 1.
By default, if no option is specified, the old value of 1 is used, thus
the rule is fully backwards compatible.
Similar to ESLint’s no-multiple-empty-lines rule “Max” option:
http://eslint.org/docs/rules/no-multiple-empty-lines
@@ -43,6 +67,9 @@ class NoConsecutiveBlankLinesWalker extends Lint.SkippableTokenAwareRuleWalker {
public visitSourceFile(node: ts.SourceFile) {
super.visitSourceFile(node);

const options = this.getOptions();
const allowedBlanks = options && options[0] || Rule.DEFAULT_ALLOWED_BLANKS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this match line 57? options is not an array

Copy link
Contributor Author

@nomaed nomaed Oct 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Different hierarchy. In Rule classes, options property is IOptions. In the RuleWalker classes they are any[].

export class RuleWalker extends SyntaxWalker {
    ...
    private options: any[];
    ...

    constructor(private sourceFile: ts.SourceFile, options: IOptions) {
        ...
        this.options = options.ruleArguments;
        ...
    }

    ...
}

@nchen63 nchen63 merged commit 255a657 into palantir:master Oct 28, 2016
@nchen63
Copy link
Contributor

nchen63 commented Oct 28, 2016

Thanks @nomaed!

@nchen63 nchen63 removed their assignment Nov 9, 2016
@nomaed nomaed deleted the consecutive-blanks-options branch December 6, 2016 12:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants