Skip to content

Commit

Permalink
Apply stricter lint rules (DefinitelyTyped#19063)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy authored Aug 17, 2017
1 parent 3dfa2b2 commit 5d6c651
Show file tree
Hide file tree
Showing 484 changed files with 3,391 additions and 3,284 deletions.
28 changes: 14 additions & 14 deletions types/activex-scripting/activex-scripting-tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// source -- https://msdn.microsoft.com/en-us/library/ebkhfaaz.aspx

// Generates a string describing the drive type of a given Drive object.
let showDriveType = (drive: Scripting.Drive) => {
function showDriveType(drive: Scripting.Drive) {
switch (drive.DriveType) {
case Scripting.DriveTypeConst.Removable:
return 'Removeable';
Expand All @@ -16,15 +16,15 @@ let showDriveType = (drive: Scripting.Drive) => {
default:
return 'Unknown';
}
};
}

// Generates a string describing the attributes of a file or folder.
let showFileAttributes = (file: Scripting.File) => {
let attr = file.Attributes;
function showFileAttributes(file: Scripting.File) {
const attr = file.Attributes;
if (attr === 0) {
return 'Normal';
}
let attributeStrings: string[] = [];
const attributeStrings: string[] = [];
if (attr & Scripting.FileAttribute.Directory) { attributeStrings.push('Directory'); }
if (attr & Scripting.FileAttribute.ReadOnly) { attributeStrings.push('Read-only'); }
if (attr & Scripting.FileAttribute.Hidden) { attributeStrings.push('Hidden'); }
Expand All @@ -34,27 +34,27 @@ let showFileAttributes = (file: Scripting.File) => {
if (attr & Scripting.FileAttribute.Alias) { attributeStrings.push('Alias'); }
if (attr & Scripting.FileAttribute.Compressed) { attributeStrings.push('Compressed'); }
return attributeStrings.join(',');
};
}

// source --https://msdn.microsoft.com/en-us/library/ts2t8ybh(v=vs.84).aspx
let showFreeSpace = (drvPath: string) => {
let fso = new ActiveXObject('Scripting.FileSystemObject');
let d = fso.GetDrive(fso.GetDriveName(drvPath));
function showFreeSpace(drvPath: string) {
const fso = new ActiveXObject('Scripting.FileSystemObject');
const d = fso.GetDrive(fso.GetDriveName(drvPath));
let s = 'Drive ' + drvPath + ' - ';
s += d.VolumeName + '<br>';
s += 'Free Space: ' + d.FreeSpace / 1024 + ' Kbytes';
return (s);
};
}

// source -- https://msdn.microsoft.com/en-us/library/kaf6yaft(v=vs.84).aspx
let getALine = (filespec: string) => {
let fso = new ActiveXObject('Scripting.FileSystemObject');
let file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false);
function getALine(filespec: string) {
const fso = new ActiveXObject('Scripting.FileSystemObject');
const file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false);

let s = '';
while (!file.AtEndOfLine) {
s += file.Read(1);
}
file.Close();
return (s);
};
}
10 changes: 5 additions & 5 deletions types/activex-wia/activex-wia-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let img = commonDialog.ShowAcquireImage();
// when DefinitelyTyped supports Typescript 2.4 -- end of July 2017, replace these:
let jpegFormatID = '{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}';
if (img.FormatID !== jpegFormatID) {
let ip = new ActiveXObject('WIA.ImageProcess');
const ip = new ActiveXObject('WIA.ImageProcess');
ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID);
ip.Filters.Item(1).Properties.Item('FormatID').Value = jpegFormatID;
img = ip.Apply(img);
Expand All @@ -24,8 +24,8 @@ if (img.FormatID !== jpegFormatID) {
let dev = commonDialog.ShowSelectDevice();
if (dev.Type === WIA.WiaDeviceType.CameraDeviceType) {
// when DefinitelyTyped supports Typescript 2.4 -- end of July 2017, replace these:
let commandID = '{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}';
let itm = dev.ExecuteCommand(commandID);
const commandID = '{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}';
const itm = dev.ExecuteCommand(commandID);

// with this:
// let itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture);
Expand All @@ -36,7 +36,7 @@ dev = commonDialog.ShowSelectDevice();
let e = new Enumerator<WIA.Property>(dev.Properties); // no foreach over ActiveX collections
e.moveFirst();
while (!e.atEnd()) {
let p = e.item();
const p = e.item();
let s = p.Name + ' (' + p.PropertyID + ') = ';
if (p.IsVector) {
s += '[vector of data]';
Expand All @@ -60,7 +60,7 @@ while (!e.atEnd()) {
} else {
s += ' [valid values include: ';
}
let count = p.SubTypeValues.Count;
const count = p.SubTypeValues.Count;
for (let i = 1; i <= count; i++) {
s += p.SubTypeValues.Item(i);
if (i < count) {
Expand Down
2 changes: 1 addition & 1 deletion types/alertify/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Type definitions for alertify 0.3.11
// Project: http://fabien-d.github.io/alertify.js/
// Definitions by: John Jeffery <http://github.com/jjeffery>
// Definitions by: John Jeffery <https://github.com/jjeffery>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare var alertify: alertify.IAlertifyStatic;
Expand Down
4 changes: 2 additions & 2 deletions types/alexa-sdk/alexa-sdk-tests.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as Alexa from "alexa-sdk";

const handler = (event: Alexa.RequestBody<Alexa.Request>, context: Alexa.Context, callback: () => void) => {
let alexa = Alexa.handler(event, context);
const alexa = Alexa.handler(event, context);
alexa.resources = {};
alexa.registerHandlers(handlers);
alexa.execute();
};

let handlers: Alexa.Handlers<Alexa.Request> = {
const handlers: Alexa.Handlers<Alexa.Request> = {
'LaunchRequest': function() {
this.emit('SayHello');
},
Expand Down
62 changes: 31 additions & 31 deletions types/algebra.js/algebra.js-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
expr = expr.subtract(3);
expr = expr.add("x");
expr.toString();
let eq = new Equation(expr, 4);
const eq = new Equation(expr, 4);
eq.toString();
let x = eq.solveFor("x");
const x = eq.solveFor("x");
x.toString();
}
{
Expand All @@ -29,7 +29,7 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
x.toString();
x = x.add("y");
x.toString();
let otherExp = new Expression("x").add(6);
const otherExp = new Expression("x").add(6);
x = x.add(otherExp);
x.toString();

Expand All @@ -54,10 +54,10 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
exp = exp.add("y");
exp = exp.add(3);
exp.toString();
let sum = exp.summation("x", 3, 6);
const sum = exp.summation("x", 3, 6);
sum.toString();
exp = new Expression("x").add(2);
let exp3 = exp.pow(3);
const exp3 = exp.pow(3);
"(" + exp.toString() + ")^3 = " + exp3.toString();

let expr = new Expression("x");
Expand All @@ -66,14 +66,14 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
expr = expr.add("y");
expr = expr.add(new Fraction(1, 3));
expr.toString();
let answer1 = expr.eval({ x: 2 });
let answer2 = expr.eval({ x: 2, y: new Fraction(3, 4) });
const answer1 = expr.eval({ x: 2 });
const answer2 = expr.eval({ x: 2, y: new Fraction(3, 4) });
answer1.toString();
answer2.toString();
expr = new Expression("x").add(2);
expr.toString();
let sub = new Expression("y").add(4);
let answer = expr.eval({ x: sub });
const sub = new Expression("y").add(4);
const answer = expr.eval({ x: sub });
answer.toString();
exp = new Expression("x").add(2);
exp.toString();
Expand All @@ -91,23 +91,23 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
exp.toString();
exp = exp.simplify();
exp.toString();
let z = new Expression("z");
let eq1 = new Equation(z.subtract(4).divide(9), z.add(6));
const z = new Expression("z");
const eq1 = new Equation(z.subtract(4).divide(9), z.add(6));
eq1.toString();
let eq2 = new Equation(z.add(4).multiply(9), 6);
const eq2 = new Equation(z.add(4).multiply(9), 6);
eq2.toString();
let eq3 = new Equation(z.divide(2).multiply(7), new Fraction(1, 4));
const eq3 = new Equation(z.divide(2).multiply(7), new Fraction(1, 4));
eq3.toString();
}
{
let x1 = parse("1/5 * x + 2/15");
let x2 = parse("1/7 * x + 4");
const x1 = parse("1/5 * x + 2/15");
const x2 = parse("1/7 * x + 4");
let eq = new Equation(x1 as Expression, x2 as Expression);
eq.toString();
let answer = eq.solveFor("x");
const answer = eq.solveFor("x");
"x = " + answer.toString();
let expr1 = parse("1/4 * x + 5/4");
let expr2 = parse("3 * y - 12/5");
const expr1 = parse("1/4 * x + 5/4");
const expr2 = parse("3 * y - 12/5");
eq = new Equation(expr1 as Expression, expr2 as Expression);
eq.toString();
let xAnswer = eq.solveFor("x");
Expand All @@ -116,14 +116,14 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
"y = " + yAnswer.toString();
let n1 = parse("x + 5") as Expression;
let n2 = parse("x - 3/4") as Expression;
let quad = new Equation(n1.multiply(n2), 0);
const quad = new Equation(n1.multiply(n2), 0);
quad.toString();
let answers = quad.solveFor("x");
"x = " + answers.toString();
n1 = parse("x + 2") as Expression;
n2 = parse("x + 3") as Expression;
let n3 = parse("x + 4") as Expression;
let cubic = new Equation(n1.multiply(n2).multiply(n3), 0);
const n3 = parse("x + 4") as Expression;
const cubic = new Equation(n1.multiply(n2).multiply(n3), 0);
cubic.toString();
answers = cubic.solveFor("x");
"x = " + answers.toString();
Expand All @@ -143,20 +143,20 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
exp.toString();
}
{
let eq = parse("x^2 + 4 * x + 4 = 0") as Equation;
const eq = parse("x^2 + 4 * x + 4 = 0") as Equation;
eq.toString();
let ans = eq.solveFor("x");
const ans = eq.solveFor("x");
"x = " + ans.toString();
let a = new Expression("x").pow(2);
let b = new Expression("x").multiply(new Fraction(5, 4));
let c = new Fraction(-21, 4);
let expr = a.add(b).add(c);
let quad = new Equation(expr, 0);
const a = new Expression("x").pow(2);
const b = new Expression("x").multiply(new Fraction(5, 4));
const c = new Fraction(-21, 4);
const expr = a.add(b).add(c);
const quad = new Equation(expr, 0);
toTex(quad);
let answers = quad.solveFor("x");
const answers = quad.solveFor("x");
toTex(answers);
let lambda = new Expression("lambda").add(3).divide(4);
let Phi = new Expression("Phi").subtract(new Fraction(1, 5)).add(lambda);
const lambda = new Expression("lambda").add(3).divide(4);
const Phi = new Expression("Phi").subtract(new Fraction(1, 5)).add(lambda);
toTex(lambda);
toTex(Phi);
}
36 changes: 23 additions & 13 deletions types/amplify/amplify-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,24 @@ amplify.request("twitter-mentions", { user: "amplifyjs" });
// Example:

const appEnvelopeDecoder: amplify.Decoder = (data, status, xhr, success, error) => {
if (data.status === "success") {
success(data.data);
} else if (data.status === "fail" || data.status === "error") {
error(data.message, data.status);
} else {
error(data.message, "fatal");
switch (data.status) {
case "success":
success(data.data);
break;
case "fail":
case "error":
error(data.message, data.status);
break;
default:
error(data.message, "fatal");
break;
}
};

// a new decoder can be added to the amplifyDecoders interface
declare module "amplify" {
interface Decoders {
appEnvelope: amplify.Decoder;
appEnvelope: Decoder;
}
}

Expand Down Expand Up @@ -213,12 +218,17 @@ amplify.request.define("decoderSingleExample", "ajax", {
url: "/myAjaxUrl",
type: "POST",
decoder(data, status, xhr, success, error) {
if (data.status === "success") {
success(data.data);
} else if (data.status === "fail" || data.status === "error") {
error(data.message, data.status);
} else {
error(data.message, "fatal");
switch (data.status) {
case "success":
success(data.data);
break;
case "fail":
case "error":
error(data.message, data.status);
break;
default:
error(data.message, "fatal");
break;
}
}
});
Expand Down
4 changes: 3 additions & 1 deletion types/amqplib/tslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-empty-interface": false
// All are TODOs
"no-empty-interface": false,
"prefer-const": false
}
}
2 changes: 1 addition & 1 deletion types/angular-block-ui/angular-block-ui-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ app.controller('Ctrl', ($scope: ng.IScope, blockUI: angular.blockUI.BlockUIServi
blockUI.reset();
blockUI.message("Hello Types");
blockUI.done();
let b: boolean = blockUI.isBlocking();
const b: boolean = blockUI.isBlocking();
});
2 changes: 1 addition & 1 deletion types/angular-block-ui/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ declare module 'angular' {
* @param {angular.IRequestConfig} config - the Angular request config object.
*
*/
requestFilter?(config: angular.IRequestConfig): (string | boolean);
requestFilter?(config: IRequestConfig): (string | boolean);

/**
* When the module is started it will inject the main block element
Expand Down
2 changes: 1 addition & 1 deletion types/angular-cookies/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Type definitions for Angular JS (ngCookies module) 1.4
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Anthony Ciccarello <http://github.com/aciccarello>
// Definitions by: Diego Vilar <https://github.com/diegovilar>, Anthony Ciccarello <https://github.com/aciccarello>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

Expand Down
12 changes: 6 additions & 6 deletions types/angular-gridster/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ declare module "angular" {
handles?: string[];

// optional callback fired when drag is started
start?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
start?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void;

// optional callback fired when item is resized
resize?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
resize?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void;

// optional callback fired when item is finished dragging
stop?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
stop?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void;
};

// options to pass to draggable handler
Expand All @@ -113,13 +113,13 @@ declare module "angular" {
handle?: string;

// optional callback fired when drag is started
start?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
start?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void;

// optional callback fired when item is moved,
drag?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
drag?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void;

// optional callback fired when item is finished dragging
stop?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
stop?(event: IAngularEvent, $element: IAugmentedJQuery, options: any): void;
};
}

Expand Down
2 changes: 1 addition & 1 deletion types/angular-material/angular-material-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ myApp.config((
return c * t * t + b;
},
easeFnIndeterminate(t, b, c, d) {
return c * Math.pow(2, 10 * (t / d - 1)) + b;
return c * Math.pow(2, (t / d - 1) * 10) + b;
}
});
});
Expand Down
Loading

0 comments on commit 5d6c651

Please sign in to comment.