Merge branch 'master' into stringLiteralTypes

This commit is contained in:
Daniel Rosenwasser 2015-10-22 23:42:00 -07:00
commit 049d02f871
7 changed files with 62 additions and 17 deletions

View file

@ -820,7 +820,8 @@ var tslintRuleDir = "scripts/tslint";
var tslintRules = ([
"nextLineRule",
"noNullRule",
"booleanTriviaRule"
"booleanTriviaRule",
"typeOperatorSpacingRule"
]);
var tslintRulesFiles = tslintRules.map(function(p) {
return path.join(tslintRuleDir, p + ".ts");

View file

@ -0,0 +1,29 @@
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = "The '|' and '&' operators must be surrounded by single spaces";
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new TypeOperatorSpacingWalker(sourceFile, this.getOptions()));
}
}
class TypeOperatorSpacingWalker extends Lint.RuleWalker {
public visitNode(node: ts.Node) {
if (node.kind === ts.SyntaxKind.UnionType || node.kind === ts.SyntaxKind.IntersectionType) {
let types = (<ts.UnionOrIntersectionTypeNode>node).types;
let expectedStart = types[0].end + 2; // space, | or &
for (let i = 1; i < types.length; i++) {
let currentType = types[i];
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
this.addFailure(failure);
}
expectedStart = currentType.end + 2;
}
}
super.visitNode(node);
}
}

View file

@ -15578,7 +15578,7 @@ namespace ts {
}
}
function checkGrammarJsxElement(node: JsxOpeningElement|JsxSelfClosingElement) {
function checkGrammarJsxElement(node: JsxOpeningLikeElement) {
const seen: Map<boolean> = {};
for (let attr of node.attributes) {
if (attr.kind === SyntaxKind.JsxSpreadAttribute) {

View file

@ -5,6 +5,7 @@ import fs = require("fs");
import path = require("path");
import url = require("url");
import child_process = require("child_process");
import os = require('os');
/// Command line processing ///
@ -263,7 +264,20 @@ http.createServer(function (req: http.ServerRequest, res: http.ServerResponse) {
var browserPath: string;
if ((browser && browser === 'chrome')) {
var defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe";
let defaultChromePath = "";
switch (os.platform()) {
case "win32":
case "win64":
defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe";
break;
case "linux":
defaultChromePath = "/opt/google/chrome/chrome"
break;
default:
console.log(`default Chrome location is unknown for platform '${os.platform()}'`);
break;
}
if (fs.existsSync(defaultChromePath)) {
browserPath = defaultChromePath;
} else {

View file

@ -38,6 +38,7 @@
"no-trailing-whitespace": true,
"no-inferrable-types": true,
"no-null": true,
"boolean-trivia": true
"boolean-trivia": true,
"type-operator-spacing": true
}
}