Skip to content

Fix latest tslint errors #13006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,6 @@ task("update-sublime", ["local", serverFile], function () {
var tslintRuleDir = "scripts/tslint";
var tslintRules = [
"nextLineRule",
"preferConstRule",
"booleanTriviaRule",
"typeOperatorSpacingRule",
"noInOperatorRule",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"through2": "latest",
"travis-fold": "latest",
"ts-node": "latest",
"tslint": "4.0.0-dev.3",
"tslint": "next",
"typescript": "next"
},
"scripts": {
Expand Down
204 changes: 0 additions & 204 deletions scripts/tslint/preferConstRule.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ namespace ts {
// Parameters with names are handled at the top of this function. Parameters
// without names can only come from JSDocFunctionTypes.
Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType);
let functionType = <JSDocFunctionType>node.parent;
let index = indexOf(functionType.parameters, node);
const functionType = <JSDocFunctionType>node.parent;
const index = indexOf(functionType.parameters, node);
return "arg" + index;
case SyntaxKind.JSDocTypedefTag:
const parentNode = node.parent && node.parent.parent;
Expand Down
16 changes: 8 additions & 8 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5019,7 +5019,7 @@ namespace ts {
// If this is a JSDoc construct signature, then skip the first parameter in the
// parameter list. The first parameter represents the return type of the construct
// signature.
for (let i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) {
for (let i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
const param = declaration.parameters[i];

Copy link
Contributor

Choose a reason for hiding this comment

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

for (let i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {

let paramSymbol = param.symbol;
Expand Down Expand Up @@ -5118,7 +5118,7 @@ namespace ts {
function getSignaturesOfSymbol(symbol: Symbol): Signature[] {
if (!symbol) return emptyArray;
const result: Signature[] = [];
for (let i = 0, len = symbol.declarations.length; i < len; i++) {
for (let i = 0; i < symbol.declarations.length; i++) {
const node = symbol.declarations[i];
switch (node.kind) {
Copy link
Contributor

Choose a reason for hiding this comment

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

switch to for..of?

Copy link
Contributor Author

@saschanaz saschanaz Dec 19, 2016

Choose a reason for hiding this comment

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

Inner lines of code use i for some purpose. It seems I can still switch to for-of in this case but should I do it?

case SyntaxKind.FunctionType:
Expand Down Expand Up @@ -5768,8 +5768,8 @@ namespace ts {
}

function isSubtypeOfAny(candidate: Type, types: Type[]): boolean {
for (let i = 0, len = types.length; i < len; i++) {
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
for (const type of types) {
if (candidate !== type && isTypeSubtypeOf(candidate, type)) {
return true;
}
}
Expand Down Expand Up @@ -7911,7 +7911,7 @@ namespace ts {
return Ternary.False;
}
let result = Ternary.True;
for (let i = 0, len = sourceSignatures.length; i < len; i++) {
for (let i = 0; i < sourceSignatures.length; i++) {
const related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo);
if (!related) {
return Ternary.False;
Expand Down Expand Up @@ -18044,7 +18044,7 @@ namespace ts {
/** Check each type parameter and check that type parameters have no duplicate type parameter declarations */
function checkTypeParameters(typeParameterDeclarations: TypeParameterDeclaration[]) {
if (typeParameterDeclarations) {
for (let i = 0, n = typeParameterDeclarations.length; i < n; i++) {
for (let i = 0; i < typeParameterDeclarations.length; i++) {
const node = typeParameterDeclarations[i];
checkTypeParameter(node);

Expand Down Expand Up @@ -18324,7 +18324,7 @@ namespace ts {
// TypeScript 1.0 spec (April 2014):
// When a generic interface has multiple declarations, all declarations must have identical type parameter
// lists, i.e. identical type parameter names with identical constraints in identical order.
for (let i = 0, len = list1.length; i < len; i++) {
for (let i = 0; i < list1.length; i++) {
const tp1 = list1[i];
const tp2 = list2[i];
if (tp1.name.text !== tp2.name.text) {
Expand Down Expand Up @@ -20761,7 +20761,7 @@ namespace ts {
case SyntaxKind.PublicKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.PrivateKeyword:
let text = visibilityToString(modifierToFlag(modifier.kind));
const text = visibilityToString(modifierToFlag(modifier.kind));

if (modifier.kind === SyntaxKind.ProtectedKeyword) {
lastProtected = modifier;
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ namespace ts {
break;
case "boolean":
// boolean flag has optional value true, false, others
let optValue = args[i];
const optValue = args[i];
options[opt.name] = optValue !== "false";
// consume next argument as boolean flag value
if (optValue === "false" || optValue === "true") {
Expand Down Expand Up @@ -778,7 +778,7 @@ namespace ts {
break;
default:
const value = options[name];
let optionDefinition = optionsNameMap[name.toLowerCase()];
const optionDefinition = optionsNameMap[name.toLowerCase()];
if (optionDefinition) {
const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition);
if (!customTypeMap) {
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace ts {
*/
export function forEach<T, U>(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined {
if (array) {
for (let i = 0, len = array.length; i < len; i++) {
for (let i = 0; i < array.length; i++) {
const result = callback(array[i], i);
if (result) {
return result;
Expand All @@ -143,7 +143,7 @@ namespace ts {
*/
export function every<T>(array: T[], callback: (element: T, index: number) => boolean): boolean {
if (array) {
for (let i = 0, len = array.length; i < len; i++) {
for (let i = 0; i < array.length; i++) {
if (!callback(array[i], i)) {
return false;
}
Expand All @@ -155,7 +155,7 @@ namespace ts {

/** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */
export function find<T>(array: T[], predicate: (element: T, index: number) => boolean): T | undefined {
for (let i = 0, len = array.length; i < len; i++) {
for (let i = 0; i < array.length; i++) {
const value = array[i];
if (predicate(value, i)) {
return value;
Expand All @@ -169,7 +169,7 @@ namespace ts {
* This is like `forEach`, but never returns undefined.
*/
export function findMap<T, U>(array: T[], callback: (element: T, index: number) => U | undefined): U {
for (let i = 0, len = array.length; i < len; i++) {
for (let i = 0; i < array.length; i++) {
const result = callback(array[i], i);
if (result) {
return result;
Expand All @@ -191,7 +191,7 @@ namespace ts {

export function indexOf<T>(array: T[], value: T): number {
if (array) {
for (let i = 0, len = array.length; i < len; i++) {
for (let i = 0; i < array.length; i++) {
if (array[i] === value) {
return i;
}
Expand All @@ -201,7 +201,7 @@ namespace ts {
}

export function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number {
for (let i = start || 0, len = text.length; i < len; i++) {
for (let i = start || 0; i < text.length; i++) {
if (contains(charCodes, text.charCodeAt(i))) {
return i;
}
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1678,8 +1678,8 @@ namespace ts {
// Method declarations are not necessarily reusable. An object-literal
// may have a method calls "constructor(...)" and we must reparse that
// into an actual .ConstructorDeclaration.
let methodDeclaration = <MethodDeclaration>node;
let nameIsConstructor = methodDeclaration.name.kind === SyntaxKind.Identifier &&
const methodDeclaration = <MethodDeclaration>node;
const nameIsConstructor = methodDeclaration.name.kind === SyntaxKind.Identifier &&
(<Identifier>methodDeclaration.name).originalKeywordKind === SyntaxKind.ConstructorKeyword;

return !nameIsConstructor;
Expand Down Expand Up @@ -7404,7 +7404,7 @@ namespace ts {
if (position >= array.pos && position < array.end) {
// position was in this array. Search through this array to see if we find a
// viable element.
for (let i = 0, n = array.length; i < n; i++) {
for (let i = 0; i < array.length; i++) {
const child = array[i];
if (child) {
if (child.pos === position) {
Expand Down
Loading