Fix lint errors

This commit is contained in:
Andy Hanson 2017-03-17 13:37:12 -07:00
parent 230e1da1f9
commit 2305c10a65
26 changed files with 139 additions and 226 deletions

View file

@ -1,4 +1,4 @@
/// <reference path="core.ts" />
/// <reference path="core.ts" />
/// <reference path="diagnosticInformationMap.generated.ts" />
namespace ts {

View file

@ -298,8 +298,8 @@ namespace ts {
let noDiagnosticsTypeChecker: TypeChecker;
let classifiableNames: Map<string>;
let cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
let cachedDeclarationDiagnosticsForFile: DiagnosticCache = {};
const cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
const cachedDeclarationDiagnosticsForFile: DiagnosticCache = {};
let resolvedTypeReferenceDirectives = createMap<ResolvedTypeReferenceDirective>();
let fileProcessingDiagnostics = createDiagnosticCollection();
@ -1105,7 +1105,7 @@ namespace ts {
return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
}
function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile| undefined, cancellationToken: CancellationToken) {
function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile | undefined, cancellationToken: CancellationToken) {
return runWithCancellationToken(() => {
const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
// Don't actually write any files since we're just getting diagnostics.

View file

@ -927,12 +927,11 @@ namespace FourSlash {
this.assertObjectsEqual<ReferencesJson>(fullActual, fullExpected);
}
function rangeToReferenceEntry(r: Range) {
let { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined };
isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition;
const result: any = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition };
function rangeToReferenceEntry(r: Range): ts.ReferenceEntry {
const { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined };
const result: ts.ReferenceEntry = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess: !!isWriteAccess, isDefinition: !!isDefinition };
if (isInString !== undefined) {
result.isInString = isInString;
result.isInString = isInString
}
return result;
}
@ -2291,7 +2290,6 @@ namespace FourSlash {
else {
if (actual === undefined) {
this.raiseError(`${name} failed - expected the template {newText: "${expected.newText}", caretOffset: "${expected.caretOffset}"} but got nothing instead`);
}
if (actual.newText !== expected.newText) {

View file

@ -1,88 +0,0 @@
///<reference path='_project.ts'/>
describe('getFormattingEditsForRange', function() {
//
// Verify that formatting the typescript file "sourceFileName" results in the
// baseline file "baselineFileName".
//
function getFormattingEditsForRange(sourceFileName: string) {
var baselineFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + "BaseLine.ts";
sourceFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + ".ts";
var typescriptLS = new Harness.TypeScriptLS();
typescriptLS.addDefaultLibrary();
typescriptLS.addFile(sourceFileName);
var ls = typescriptLS.getLanguageService();
var script = ls.languageService.getScriptAST(sourceFileName);
assert.notNull(script);
var edits = ls.languageService.getFormattingEditsForRange(sourceFileName, 0, script.limChar, new Services.FormatCodeOptions());
typescriptLS.checkEdits(sourceFileName, baselineFileName, edits);
}
describe('test cases for formatting engine', function() {
it("formats typescript constructs properly", function() {
getFormattingEditsForRange('typescriptConstructs');
});
it("formats document ready function properly", function() {
getFormattingEditsForRange('documentReadyFunction');
});
it("formats on closing bracket properly", function() {
getFormattingEditsForRange('onClosingBracket');
});
it("formats various javascript constructs", function() {
getFormattingEditsForRange('various');
});
it("formats main javascript program", function() {
getFormattingEditsForRange('main');
});
it("formats on semicolon properly", function() {
getFormattingEditsForRange('onSemiColon');
});
it("formats enum with trailling tab characters properly", function() {
getFormattingEditsForRange('tabAfterCloseCurly');
});
it("formats object literal", function() {
getFormattingEditsForRange('objectLiteral');
});
it("formats with statements", function() {
getFormattingEditsForRange('withStatement');
});
it("formats ':' and '?' in parameters", function() {
getFormattingEditsForRange('colonAndQMark');
});
it("formats 'import' declaration", function() {
getFormattingEditsForRange('importDeclaration');
});
it("formats exported class with implicit module", function() {
//TODO: this is to force generation of implicit module in AST
var svGenTarget = TypeScript.moduleGenTarget;
try {
TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Asynchronous;
getFormattingEditsForRange('implicitModule');
}
finally {
TypeScript.moduleGenTarget = svGenTarget;
}
});
it("formats constructor statements correctelly", function() {
getFormattingEditsForRange('spaceAfterConstructor');
});
it("formats classes and interfaces correctelly", function() {
getFormattingEditsForRange('classes');
});
it("formats modules correctly", function() {
getFormattingEditsForRange('modules');
});
it("formats fat arrow expressions correctelly", function() {
getFormattingEditsForRange('fatArrowFunctions');
});
it("formats empty object/interface literals correctelly", function() {
getFormattingEditsForRange('emptyInterfaceLiteral');
});
it("formats variable declaration lists", function() {
getFormattingEditsForRange('formatVariableDeclarationList');
});
});
});

View file

@ -2,6 +2,9 @@
/// <reference path="..\..\services\textChanges.ts" />
/// <reference path="..\harness.ts" />
// Some tests have trailing whitespace
// tslint:disable trim-trailing-whitespace
namespace ts {
describe("textChanges", () => {
function findChild(name: string, n: Node) {
@ -572,7 +575,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a")));
})
});
}
{
const text = `
@ -581,7 +584,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a")));
})
});
}
{
const text = `
@ -590,7 +593,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -599,7 +602,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -609,7 +612,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a")));
})
});
}
{
const text = `
@ -619,7 +622,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a")));
})
});
}
{
const text = `
@ -629,7 +632,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter16", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -639,7 +642,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter17", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -648,7 +651,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter18", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -656,7 +659,7 @@ class A {
x;
}`;
runSingleFileTest("insertNodeAfterMultipleNodes", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
let newNodes = [];
const newNodes = [];
for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) {
newNodes.push(
createProperty(undefined, undefined, i + "", undefined, undefined, undefined));
@ -714,7 +717,7 @@ class A {
class A {
x = foo
}
`
`;
runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createProperty(
/*decorators*/ undefined,
@ -732,7 +735,7 @@ class A {
x() {
}
}
`
`;
runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createProperty(
/*decorators*/ undefined,
@ -749,7 +752,7 @@ class A {
interface A {
x
}
`
`;
runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createProperty(
/*decorators*/ undefined,
@ -766,7 +769,7 @@ interface A {
interface A {
x()
}
`
`;
runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createProperty(
/*decorators*/ undefined,
@ -781,7 +784,7 @@ interface A {
{
const text = `
let x = foo
`
`;
runSingleFileTest("insertNodeInStatementListAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createStatement(createParen(createLiteral(1)));
changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), newNode, { suffix: newLineCharacter });

View file

@ -5,8 +5,6 @@ interface DOMTokenList {
}
interface NodeList {
/**
* Returns an array of key, value pairs for every entry in the list
*/
@ -28,7 +26,7 @@ interface NodeList {
values(): IterableIterator<Node>;
[Symbol.iterator](): IterableIterator<Node>
[Symbol.iterator](): IterableIterator<Node>;
}
interface NodeListOf<TNode extends Node> {
@ -53,5 +51,5 @@ interface NodeListOf<TNode extends Node> {
*/
values(): IterableIterator<TNode>;
[Symbol.iterator](): IterableIterator<TNode>
[Symbol.iterator](): IterableIterator<TNode>;
}

View file

@ -17,7 +17,7 @@ declare var Map: MapConstructor;
interface ReadonlyMap<K, V> {
forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
get(key: K): V|undefined;
get(key: K): V | undefined;
has(key: K): boolean;
readonly size: number;
}

View file

@ -268,7 +268,7 @@ interface Object {
* Determines whether an object has a property with the specified name.
* @param v A property name.
*/
hasOwnProperty(v: PropertyKey): boolean
hasOwnProperty(v: PropertyKey): boolean;
/**
* Determines whether a specified property is enumerable.
@ -486,10 +486,10 @@ interface String {
bold(): string;
/** Returns a <tt> HTML element */
fixed(): string
fixed(): string;
/** Returns a <font> HTML element and sets the color attribute value */
fontcolor(color: string): string
fontcolor(color: string): string;
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: number): string;

View file

@ -91,7 +91,7 @@ interface IArguments {
}
interface Map<K, V> {
[Symbol.iterator](): IterableIterator<[K,V]>;
[Symbol.iterator](): IterableIterator<[K, V]>;
entries(): IterableIterator<[K, V]>;
keys(): IterableIterator<K>;
values(): IterableIterator<V>;

View file

@ -12,11 +12,11 @@ interface ProxyHandler<T> {
enumerate? (target: T): PropertyKey[];
ownKeys? (target: T): PropertyKey[];
apply? (target: T, thisArg: any, argArray?: any): any;
construct? (target: T, argArray: any, newTarget?: any): object
construct? (target: T, argArray: any, newTarget?: any): object;
}
interface ProxyConstructor {
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
new <T>(target: T, handler: ProxyHandler<T>): T
new <T>(target: T, handler: ProxyHandler<T>): T;
}
declare var Proxy: ProxyConstructor;

View file

@ -16,7 +16,7 @@ interface SymbolConstructor {
* Returns a new unique Symbol value.
* @param description Description of the new Symbol object.
*/
(description?: string|number): symbol;
(description?: string | number): symbol;
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.

View file

@ -14,7 +14,7 @@ interface SharedArrayBuffer {
/**
* Returns a section of an SharedArrayBuffer.
*/
slice(begin:number, end?:number): SharedArrayBuffer;
slice(begin: number, end?: number): SharedArrayBuffer;
readonly [Symbol.species]: SharedArrayBuffer;
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
}

18
src/lib/es5.d.ts vendored
View file

@ -2,6 +2,8 @@
/// ECMAScript APIs
/////////////////////////////
// tslint:disable no-var-keyword
declare const NaN: number;
declare const Infinity: number;
@ -490,7 +492,7 @@ interface NumberConstructor {
declare const Number: NumberConstructor;
interface TemplateStringsArray extends ReadonlyArray<string> {
readonly raw: ReadonlyArray<string>
readonly raw: ReadonlyArray<string>;
}
interface Math {
@ -1354,14 +1356,14 @@ type Readonly<T> = {
*/
type Pick<T, K extends keyof T> = {
[P in K]: T[P];
}
};
/**
* Construct a type with a set of properties K of type T
*/
type Record<K extends string, T> = {
[P in K]: T;
}
};
/**
* Marker for contextual 'this' type
@ -1383,7 +1385,7 @@ interface ArrayBuffer {
/**
* Returns a section of an ArrayBuffer.
*/
slice(begin:number, end?:number): ArrayBuffer;
slice(begin: number, end?: number): ArrayBuffer;
}
interface ArrayBufferConstructor {
@ -4169,7 +4171,7 @@ declare const Float64Array: Float64ArrayConstructor;
/// ECMAScript Internationalization API
/////////////////////////////
declare module Intl {
declare namespace Intl {
interface CollatorOptions {
usage?: string;
localeMatcher?: string;
@ -4197,7 +4199,7 @@ declare module Intl {
new (locales?: string | string[], options?: CollatorOptions): Collator;
(locales?: string | string[], options?: CollatorOptions): Collator;
supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[];
}
};
interface NumberFormatOptions {
localeMatcher?: string;
@ -4234,7 +4236,7 @@ declare module Intl {
new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
(locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[];
}
};
interface DateTimeFormatOptions {
localeMatcher?: string;
@ -4277,7 +4279,7 @@ declare module Intl {
new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[];
}
};
}
interface String {

View file

@ -1,4 +1,4 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="session.ts" />

View file

@ -33,7 +33,7 @@ namespace ts.server {
}
export class SessionClient implements LanguageService {
private sequence: number = 0;
private sequence = 0;
private lineMaps: ts.Map<number[]> = ts.createMap<number[]>();
private messages: string[] = [];
private lastRenameEntry: RenameEntry;

View file

@ -135,7 +135,7 @@ namespace ts.server {
try {
this.fd = fs.openSync(this.logFilename, "w");
}
catch(_) {
catch (_) {
// swallow the error and keep logging disabled if file cannot be opened
}
}
@ -315,7 +315,7 @@ namespace ts.server {
}
const body: protocol.TypesInstallerInitializationFailedEventBody = {
message: response.message
}
};
const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed";
this.eventSender.event(body, eventName);
return;
@ -480,7 +480,7 @@ namespace ts.server {
: undefined;
const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity)
return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity);
}
// This places log file in the directory containing editorServices.js
// TODO: check that this location is writable

View file

@ -24,7 +24,7 @@ namespace ts.server.typingsInstaller {
try {
fs.appendFileSync(this.logFile, text + sys.newLine);
}
catch(e) {
catch (e) {
this.logEnabled = false;
}
}

View file

@ -301,7 +301,6 @@ namespace ts.codefix {
}
function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] {
//const newImportText = isDefault ? `default as ${name}` : name;
const importList = <NamedImports>importClause.namedBindings;
const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name));
// case 1:
@ -556,7 +555,7 @@ namespace ts.codefix {
}
function createChangeTracker() {
return textChanges.ChangeTracker.fromCodeFixContext(context);;
return textChanges.ChangeTracker.fromCodeFixContext(context);
}
function createCodeAction(

View file

@ -36,11 +36,11 @@ namespace ts.FindAllReferences {
}
else if (node.kind === SyntaxKind.ObjectLiteralExpression) {
entry.kind = ScriptElementKind.interfaceElement;
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)]
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)];
}
else if (node.kind === SyntaxKind.ClassExpression) {
entry.kind = ScriptElementKind.localClassElement;
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)]
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)];
}
else {
entry.kind = getNodeKind(node);

View file

@ -265,7 +265,7 @@ namespace ts.textChanges {
options: {},
range: { pos: after.end, end: after.end },
node: createToken(SyntaxKind.SemicolonToken)
})
});
}
}
const endPosition = getAdjustedEndPosition(sourceFile, after, options);
@ -307,8 +307,8 @@ namespace ts.textChanges {
// c,
// result - '*' denotes leading trivia that will be inserted after new text (displayed as '#')
// a,*
//***insertedtext<separator>#
//###b,
// ***insertedtext<separator>#
// ###b,
// c,
// find line and character of the next element
const lineAndCharOfNextElement = getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart()));
@ -393,7 +393,7 @@ namespace ts.textChanges {
// insert element before the line break on the line that contains 'after' element
let insertPos = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false);
if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) {
insertPos--
insertPos--;
}
this.changes.push({
sourceFile,

View file

@ -1,4 +1,4 @@
lib.d.ts(32,18): error TS2300: Duplicate identifier 'eval'.
lib.d.ts(34,18): error TS2300: Duplicate identifier 'eval'.
tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode.
tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS2300: Duplicate identifier 'eval'.

View file

@ -1,4 +1,5 @@
{
"rulesDirectory": "built/local/tslint",
"rules": {
"no-bom": true,
"class-name": true,