tslint-react
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -18,2 +18,3 @@ /** | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function nodeIsKind(node, kind) { | ||
@@ -20,0 +21,0 @@ return node.kind === kind; |
{ | ||
"name": "tslint-react", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Lint rules related to React & JSX for TSLint", | ||
@@ -22,9 +22,12 @@ "main": "tslint-react.json", | ||
"devDependencies": { | ||
"@types/colors": "^1.1.1", | ||
"@types/glob": "^5.0.30", | ||
"@types/node": "^7.0.7", | ||
"colors": "^1.1.2", | ||
"glob": "^7.0.3", | ||
"npm-run-all": "^2.1.2", | ||
"glob": "^7.1.1", | ||
"npm-run-all": "^4.0.2", | ||
"path": "^0.12.7", | ||
"tslint": "^4.3.1", | ||
"typescript": "^2.1.4" | ||
"tslint": "^4.5.1", | ||
"typescript": "^2.2.1" | ||
} | ||
} |
@@ -48,2 +48,6 @@ [![NPM version](https://badge.fury.io/js/tslint-react.svg)](https://www.npmjs.com/package/tslint-react) | ||
- Allows blacklisting of props in JSX with an optional explanatory message in the reported failure. | ||
- `jsx-boolean-value` (since v2.5.0) | ||
- When using a boolean attribute in JSX, you can set the attribute value to true or omit the value. This rule will enforce one or the other to keep consistency in your code. | ||
- Rule options: `always`, `never`. | ||
- Default is set to `always`. | ||
- `jsx-curly-spacing` (since v1.1.0) | ||
@@ -64,3 +68,3 @@ - Requires _or_ bans spaces between curly brace characters in JSX. | ||
- `jsx-use-translation-function` (since v2.4.0) | ||
- Enforces use of a translation function. Plain string literals are disallowed in JSX when enabled. | ||
- Enforces use of a translation function. Plain string literals are disallowed in JSX when enabled. | ||
- Rule options: _none_ | ||
@@ -67,0 +71,0 @@ - Off by default |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -28,3 +34,3 @@ var Rule = (function (_super) { | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -47,3 +53,3 @@ Rule.prototype.apply = function (sourceFile) { | ||
function JsxAlignmentWalker() { | ||
var _this = _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.getCharacter = function (node) { return _this.getLineAndCharacter(node).character; }; | ||
@@ -50,0 +56,0 @@ _this.getLine = function (node) { return _this.getLineAndCharacter(node).line; }; |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -28,3 +34,3 @@ var Rule = (function (_super) { | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -31,0 +37,0 @@ Rule.prototype.apply = function (sourceFile) { |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -37,3 +43,3 @@ var ts = require("typescript"); | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -81,3 +87,3 @@ Rule.prototype.apply = function (sourceFile) { | ||
function JsxCurlySpacingWalker() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -84,0 +90,0 @@ JsxCurlySpacingWalker.prototype.visitJsxExpression = function (node) { |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -29,3 +35,3 @@ var ts = require("typescript"); | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -43,3 +49,3 @@ Rule.prototype.apply = function (sourceFile) { | ||
function JsxNoLambdaWalker() { | ||
var _this = _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.isInJsxAttribute = false; | ||
@@ -46,0 +52,0 @@ return _this; |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -28,3 +34,3 @@ var Rule = (function (_super) { | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -42,3 +48,3 @@ Rule.prototype.apply = function (sourceFile) { | ||
function JsxNoMultilineJsWalker() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -45,0 +51,0 @@ JsxNoMultilineJsWalker.prototype.visitJsxExpression = function (node) { |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -30,3 +36,3 @@ var ts = require("typescript"); | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -44,3 +50,3 @@ Rule.prototype.apply = function (sourceFile) { | ||
function JsxNoStringRefWalker() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -47,0 +53,0 @@ JsxNoStringRefWalker.prototype.visitNode = function (node) { |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -29,3 +35,3 @@ var ts = require("typescript"); | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -43,3 +49,3 @@ Rule.prototype.apply = function (sourceFile) { | ||
function JsxSelfCloseWalker() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -46,0 +52,0 @@ JsxSelfCloseWalker.prototype.visitJsxElement = function (node) { |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -30,3 +36,3 @@ var ts = require("typescript"); | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -45,3 +51,3 @@ Rule.prototype.apply = function (sourceFile) { | ||
function JsxUseTranslationFunctionWalker() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -48,0 +54,0 @@ JsxUseTranslationFunctionWalker.prototype.visitJsxElement = function (node) { |
@@ -18,7 +18,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Lint = require("tslint"); | ||
@@ -29,3 +35,3 @@ var ts = require("typescript"); | ||
function Rule() { | ||
return _super.apply(this, arguments) || this; | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -43,4 +49,6 @@ Rule.prototype.apply = function (sourceFile) { | ||
__extends(JsxWrapMultilineWalker, _super); | ||
function JsxWrapMultilineWalker() { | ||
return _super.apply(this, arguments) || this; | ||
function JsxWrapMultilineWalker(sourceFile, options) { | ||
var _this = _super.call(this, sourceFile, options) || this; | ||
_this.scanner = ts.createScanner(ts.ScriptTarget.ES5, false, ts.LanguageVariant.Standard, sourceFile.text); | ||
return _this; | ||
} | ||
@@ -69,2 +77,4 @@ JsxWrapMultilineWalker.prototype.visitJsxElement = function (node) { | ||
} | ||
this.scanner.setTextPos(node.getFullStart() - 1); | ||
var prevTokenKind = this.scanner.scan(); | ||
var siblings = node.parent.getChildren(sourceFile); | ||
@@ -74,6 +84,6 @@ var index = siblings.indexOf(node); | ||
var nextToken = siblings[index + 1]; | ||
if (previousToken == null | ||
|| previousToken.kind !== ts.SyntaxKind.OpenParenToken | ||
|| nextToken == null | ||
|| nextToken.kind !== ts.SyntaxKind.CloseParenToken) { | ||
if (prevTokenKind === ts.SyntaxKind.OpenParenToken && node.getFullText().match(/^[\r\n]+/)) { | ||
return; | ||
} | ||
if (nextToken == null || nextToken.kind !== ts.SyntaxKind.CloseParenToken) { | ||
this.addNotWrappedFailure(node); | ||
@@ -80,0 +90,0 @@ return; |
@@ -5,2 +5,3 @@ { | ||
"jsx-alignment": true, | ||
"jsx-boolean-value": true, | ||
"jsx-curly-spacing": [true, "never"], | ||
@@ -11,5 +12,4 @@ "jsx-no-lambda": true, | ||
"jsx-self-close": true, | ||
// pretty buggy right now; we can re-enable when issues like #53 are fixed | ||
"jsx-wrap-multiline": false | ||
"jsx-wrap-multiline": true | ||
} | ||
} |
60921
25
1251
113
9