Skip to content

Commit

Permalink
fix: rename rule due to duplicate rule name of tslint-react
Browse files Browse the repository at this point in the history
  • Loading branch information
paibamboo committed Mar 14, 2019
1 parent 6a8154c commit d212c04
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Lint from "tslint";
import * as ts from "typescript";

class JsxSpaceBeforeTrailingSlashRule extends Lint.RuleWalker {
class JsxSpaceBeforeClosingTagRule extends Lint.RuleWalker {
private readonly enforceWhiteSpace: boolean = true;
constructor(
sourceFile: ts.SourceFile,
Expand All @@ -20,12 +20,12 @@ class JsxSpaceBeforeTrailingSlashRule extends Lint.RuleWalker {
public visitJsxSelfClosingElement(node: ts.JsxSelfClosingElement): void {
super.visitJsxSelfClosingElement(node);
if (this.enforceWhiteSpace) {
if (!JsxSpaceBeforeTrailingSlashRule.hasWhitespaceBeforeClosing(node.getText())) {
if (!JsxSpaceBeforeClosingTagRule.hasWhitespaceBeforeClosing(node.getText())) {
this.addFailureAtNode(node, "Self-closing JSX elements must have a space before the '/>' part");
return;
}
} else {
if (!/[\r\n]/.test(node.getText()) && JsxSpaceBeforeTrailingSlashRule.hasWhitespaceBeforeClosing(node.getText())) {
if (!/[\r\n]/.test(node.getText()) && JsxSpaceBeforeClosingTagRule.hasWhitespaceBeforeClosing(node.getText())) {
this.addFailureAtNode(node, "One-line self-closing JSX elements must not have a space(s) before the '/>' part");
return;
}
Expand All @@ -36,6 +36,6 @@ class JsxSpaceBeforeTrailingSlashRule extends Lint.RuleWalker {
// tslint:disable-next-line:export-name max-classes-per-file
export class Rule extends Lint.Rules.TypedRule {
public applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
return this.applyWithWalker(new JsxSpaceBeforeTrailingSlashRule(sourceFile, this.getOptions()));
return this.applyWithWalker(new JsxSpaceBeforeClosingTagRule(sourceFile, this.getOptions()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"../../../../lib"
],
"rules": {
"jsx-space-before-trailing-slash": true
"jsx-space-before-closing-tag": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"../../../../lib"
],
"rules": {
"jsx-space-before-trailing-slash": [true, "never"]
"jsx-space-before-closing-tag": [true, "never"]
}
}

0 comments on commit d212c04

Please sign in to comment.