Fix remaining lint errors (#19219)

This commit is contained in:
Andy 2017-08-21 14:14:31 -07:00 committed by GitHub
parent 3fcde354de
commit 1b54a38a43
80 changed files with 256 additions and 202 deletions

View File

@ -14,9 +14,7 @@ let obj5 = new ActiveXObject('ADODB.Stream');
let pathToExcelFile = 'C:\\path\\to\\excel\\file.xlsx';
let conn = new ActiveXObject('ADODB.Connection');
conn.Provider = 'Microsoft.ACE.OLEDB.12.0';
conn.ConnectionString =
'Data Source="' + pathToExcelFile + '";' +
'Extended Properties="Excel 12.0;HDR=Yes"';
conn.ConnectionString = `Data Source="${pathToExcelFile}";Extended Properties="Excel 12.0;HDR=Yes"`;
conn.Open();
// create a Command to access the data

View File

@ -40,9 +40,9 @@ function showFileAttributes(file: Scripting.File) {
function showFreeSpace(drvPath: string) {
const fso = new ActiveXObject('Scripting.FileSystemObject');
const d = fso.GetDrive(fso.GetDriveName(drvPath));
let s = 'Drive ' + drvPath + ' - ';
let s = `Drive ${drvPath} - `;
s += d.VolumeName + '<br>';
s += 'Free Space: ' + d.FreeSpace / 1024 + ' Kbytes';
s += `Free Space: ${d.FreeSpace / 1024} Kbytes`;
return (s);
}

View File

@ -37,14 +37,14 @@ let e = new Enumerator<WIA.Property>(dev.Properties); // no foreach over Active
e.moveFirst();
while (!e.atEnd()) {
const p = e.item();
let s = p.Name + ' (' + p.PropertyID + ') = ';
let s = `${p.Name} (${p.PropertyID}) = `;
if (p.IsVector) {
s += '[vector of data]';
} else {
s += p.Value;
if (p.SubType !== WIA.WiaSubType.UnspecifiedSubType) {
if (p.Value !== p.SubTypeDefault) {
s += ' (Default = ' + p.SubTypeDefault + ')';
s += ` (Default = ${p.SubTypeDefault})`;
}
}
}
@ -70,7 +70,7 @@ while (!e.atEnd()) {
s += ']';
break;
case WIA.WiaSubType.RangeSubType:
s += ' [valid values in the range from ' + p.SubTypeMin + ' to ' + p.SubTypeMax + ' in increments of ' + p.SubTypeStep + ']';
s += ` [valid values in the range from ${p.SubTypeMin} to ${p.SubTypeMax} in increments of ${p.SubTypeStep}]`;
break;
}
}

View File

@ -36,7 +36,7 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
let expr1 = new Expression("a").add("b").add("c");
let expr2 = new Expression("c").subtract("b");
let expr3 = expr1.subtract(expr2);
expr1.toString() + " - (" + expr2.toString() + ") = " + expr3.toString();
`${expr1.toString()} - (${expr2.toString()}) = ${expr3.toString()}`;
expr1 = new Expression("x");
expr1 = expr1.add(2);
@ -46,7 +46,7 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
expr2 = expr2.multiply(new Fraction(1, 3));
expr2 = expr2.add(4);
expr3 = expr1.multiply(expr2);
"(" + expr1.toString() + ")(" + expr2.toString() + ") = " + expr3.toString();
`(${expr1.toString()})(${expr2.toString()}) = ${expr3.toString()}`;
x = new Expression("x").divide(2).divide(new Fraction(1, 5));
x.toString();
@ -58,7 +58,7 @@ import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
sum.toString();
exp = new Expression("x").add(2);
const exp3 = exp.pow(3);
"(" + exp.toString() + ")^3 = " + exp3.toString();
`(${exp.toString()})^3 = ${exp3.toString()}`;
let expr = new Expression("x");
expr = expr.multiply(2);

View File

@ -620,7 +620,7 @@ function test_angular_forEach() {
const log: string[] = [];
angular.forEach(values, (value, key, obj) => {
obj[key] = value;
this.push(key + ': ' + value);
this.push(`${key}: ${value}`);
}, log);
// expect(log).toEqual(['name: misko', 'gender: male']);
}

View File

@ -35,7 +35,7 @@ new Awesomplete('input[type="email"]', {
"hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
"live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk"],
data: (text: string, input: string) => {
return input.slice(0, input.indexOf("@")) + "@" + text;
return `${input.slice(0, input.indexOf("@"))}@${text}`;
},
filter: Awesomplete.FILTER_STARTSWITH
});
@ -47,7 +47,7 @@ new Awesomplete('input[data-multiple]', {
replace: (text: string) => {
const before = this.input.value.match(/^.+,\s*|/)[0];
this.input.value = before + text + ", ";
this.input.value = `${before}${text}, `;
}
});

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"callable-types": false
// TODOs
"callable-types": false,
"no-object-literal-type-assertion": false
}
}

View File

@ -1,7 +1,7 @@
import * as Database from 'better-sqlite3';
let integer = Database.Integer(1);
let err = new Database.SqliteError('ok', 'ok');
const integer = Database.Integer(1);
const err = new Database.SqliteError('ok', 'ok');
let db = Database('.');
db = new Database('.', {memory: true});
@ -15,7 +15,7 @@ db.register({name: 'noop', deterministic: true, varargs: true}, () => {});
db.defaultSafeIntegers();
db.defaultSafeIntegers(true);
let stmt = db.prepare('SELECT * FROM test WHERE name == ?;');
const stmt = db.prepare('SELECT * FROM test WHERE name == ?;');
stmt.get(['name']);
stmt.all({name: 'name'});
stmt.each('name', (row: {name: string}) => {});
@ -26,7 +26,7 @@ stmt.bind('name');
stmt.safeIntegers();
stmt.safeIntegers(true);
let trans = db.transaction(['INSERT INTO test(name) VALUES(?);']);
const trans = db.transaction(['INSERT INTO test(name) VALUES(?);']);
trans.run('name');
trans.bind('name');
trans.run();

View File

@ -1,6 +1,6 @@
// Type definitions for better-sqlite3 3.1
// Project: http://github.com/JoshuaWise/better-sqlite3
// Definitions by: Ben Davies <https://github.com/Morfent/>
// Definitions by: Ben Davies <https://github.com/Morfent>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />

View File

@ -12,7 +12,7 @@ $(() => {
$('#ex2').slider({});
const RGBChange = () => {
$('#RGB').css('background', 'rgb(' + r.getValue() + ',' + g.getValue() + ',' + b.getValue() + ')');
$('#RGB').css('background', `rgb(${r.getValue()},${g.getValue()},${b.getValue()})`);
};
const r = $('#R').slider()

View File

@ -6,7 +6,7 @@ import { Chart, ChartData } from 'chart.js';
const chart: Chart = new Chart(new CanvasRenderingContext2D(), {
type: 'bar',
data: <ChartData> {
data: {
labels: ['group 1'],
datasets: [
{

View File

@ -57,7 +57,7 @@ historyApiFallback({
{
from: /^\/libs\/(.*)$/,
to(context) {
return '/' + context.match[2] + '/' + context.match[3];
return `/${context.match[2]}/${context.match[3]}`;
}
}
]

View File

@ -104,13 +104,13 @@ function sampleWithPRAGMA() {
});
tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], (tx, res) => {
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
console.log(`insertId: ${res.insertId} -- probably 1`);
console.log(`rowsAffected: ${res.rowsAffected} -- should be 1`);
db.transaction(tx => {
tx.executeSql("select count(id) as cnt from test_table;", [], (tx, res) => {
console.log("res.rows.length: " + res.rows.length + " -- should be 1");
console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1");
console.log(`res.rows.length: ${res.rows.length} -- should be 1`);
console.log(`res.rows.item(0).cnt: ${res.rows.item(0).cnt} -- should be 1`);
});
});
@ -135,12 +135,12 @@ function sampleWithTransactionLevelNesting() {
tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)');
tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], (tx, res) => {
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
console.log(`insertId: ${res.insertId} -- probably 1`);
console.log(`rowsAffected: ${res.rowsAffected} -- should be 1`);
tx.executeSql("select count(id) as cnt from test_table;", [], (tx, res) => {
console.log("res.rows.length: " + res.rows.length + " -- should be 1");
console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1");
console.log(`res.rows.length: ${res.rows.length} -- should be 1`);
console.log(`res.rows.item(0).cnt: ${res.rows.item(0).cnt} -- should be 1`);
});
}, (tx, e) => {
console.log("ERROR: " + e.message);

View File

@ -66,7 +66,7 @@ tape("binary", (t) => {
const binary = cwise({
args: ["array", "array", "scalar", "shape", "index"],
body(a: number, b: number, t: tape.Test, s: number[], idx: number) {
if (!(a === 0)) t.fail("idx:" + idx + ", shape:" + s + ",a:" + a);
if (!(a === 0)) t.fail(`idx:${idx}, shape:${s},a:${a}`);
a = b + 1001;
}
});
@ -80,7 +80,7 @@ tape("binary", (t) => {
binary(P, Q, t);
for (let i = 0; i < P.shape[0]; ++i) {
if (!(P.get(i) === i + 1001)) {
t.fail(testName + "; encountered " + P.get(i) + " instead of " + (i + 1001) + " at " + i);
t.fail(`${testName}; encountered ${P.get(i)} instead of ${(i + 1001)} at ${i}`);
return;
}
}
@ -128,7 +128,7 @@ tape("binary", (t) => {
for (let i = 0; i < P.shape[0]; ++i) {
for (let j = 0; j < P.shape[1]; ++j) {
if (!(P.get(i, j) === i * 1000 + j + 1001)) {
t.fail(testName + "; encountered " + P.get(i, j) + " instead of " + (i * 1000 + j + 1001) + " at (" + i + "," + j + ")");
t.fail(`${testName}; encountered ${P.get(i, j)} instead of ${(i * 1000 + j + 1001)} at (" + i + "," + j + ")`);
return;
}
}
@ -163,7 +163,7 @@ function bundleCasesFrom(i: number) {
if (i >= cases.length) return;
const b = browserify();
b.ignore("tape");
b.add(__dirname + "/" + cases[i] + ".js");
b.add(`${__dirname}/${cases[i]}.js`);
b.transform(path.normalize(__dirname + "/../cwise.js"));
tape(cases[i], (t) => { // Without nested tests, the asynchronous nature of bundle causes issues with tape...
b.bundle((err, src) => {
@ -209,7 +209,7 @@ tape("fill", (t) => {
for (let i = 0; i < xlen; i++) {
for (let j = 0; j < ylen; j++) {
t.equals(array.get(i, j), 0, 'fill (' + i + ',' + j + ')');
t.equals(array.get(i, j), 0, `fill (${i},${j})`);
}
}
@ -219,7 +219,7 @@ tape("fill", (t) => {
for (let i = 0; i < xlen; i++) {
for (let j = 0; j < ylen; j++) {
t.equals(array.get(i, j), 10 * (i + j), 'fill (' + i + ',' + j + ')');
t.equals(array.get(i, j), 10 * (i + j), `fill (${i},${j})`);
}
}
@ -231,7 +231,7 @@ tape("offset", (t) => {
const binary = cwise({
args: ["array", "array", { offset: [1], array: 1 }, "scalar", "shape", "index"],
body(a, b, c, t, s, idx) {
if (!(a === 0)) t.fail("idx:" + idx + ", shape:" + s + ",a:" + a);
if (!(a === 0)) t.fail(`idx:${idx}, shape:${s},a:${a}`);
a = c + b + 1000;
}
});
@ -246,7 +246,7 @@ tape("offset", (t) => {
binary(P, Q.hi(Q.shape[0] - 1), t);
for (let i = 0; i < P.shape[0]; ++i) {
if (!(P.get(i) === 2 * i + 1001)) {
t.fail(testName + "; encountered " + P.get(i) + " instead of " + (2 * i + 1001) + " at " + i);
t.fail(`${testName}; encountered ${P.get(i)} instead of ${2 * i + 1001} at ${i}`);
return;
}
}
@ -292,7 +292,7 @@ tape("unary", (t) => {
unary(arr);
for (let i = 0; i < arr.shape[0]; ++i) {
if (!(arr.get(i) === i + 1)) {
t.fail(testName + "; encountered " + arr.get(i) + " instead of " + (i + 1) + " at " + i);
t.fail(`${testName}; encountered ${arr.get(i)} instead of ${i + 1} at ${i}`);
return;
}
}
@ -336,7 +336,7 @@ tape("unary", (t) => {
for (let i = 0; i < arr.shape[0]; ++i) {
for (let j = 0; j < arr.shape[1]; ++j) {
if (!(arr.get(i, j) === 1 + i + j * arr.shape[0])) {
t.fail(testName + "; encountered " + arr.get(i, j) + " instead of " + (1 + i + j * arr.shape[0]) + " at (" + i + "," + j + ")");
t.fail(`${testName}; encountered ${arr.get(i, j)} instead of ${1 + i + j * arr.shape[0]} at (${i},${j})`);
return;
}
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false
}
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false
}
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false,
"max-line-length": [false, 200]
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false
}
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false,
"max-line-length": [false, 145]
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false
}
}

View File

@ -484,7 +484,7 @@ body = body
const datum: BodyDatum = d;
const index: number = i;
const group: HTMLBodyElement[] | d3Selection.ArrayLike<HTMLBodyElement> = g;
return '<div> Body Background Color: ' + this.bgColor + ', Foo Datum: ' + d.foo + '</div>'; // this context HTMLBodyElement, datum BodyDatum
return `<div> Body Background Color: ${this.bgColor}, Foo Datum: ${d.foo}</div>`; // this context HTMLBodyElement, datum BodyDatum
});
// ---------------------------------------------------------------------------------------
@ -993,7 +993,7 @@ let customListener: (this: HTMLBodyElement, finalOpponent: string) => string;
customListener = finalOpponent => {
const e = <SuccessEvent> d3Selection.event;
return e.team + ' defeated ' + finalOpponent + ' in the EURO 2016 Cup. Who would have thought!!!';
return `${e.team} defeated ${finalOpponent} in the EURO 2016 Cup. Who would have thought!!!`;
};
const resultText: string = d3Selection.customEvent(successEvent, customListener, body.node(), 'Wales');

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false
}
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false,
"callable-types": false
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false
}
}

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-this-assignment": false,
"unified-signatures": false
}
}

View File

@ -1,18 +1,18 @@
const headertmpl = "<h1>{{=it.title}}</h1>";
const pagetmpl = "<h2>Here is the page using a header template< / h2 >\n"
+ "{{#def.header}}\n"
+ "{{=it.name}}";
const pagetmpl = `<h2>Here is the page using a header template< / h2 >
{{#def.header}}
{{=it.name}}`;
const customizableheadertmpl = "{{#def.header}}"
+ "\n{{#def.mycustominjectionintoheader || ''} }";
const customizableheadertmpl = `{{#def.header}}
{{#def.mycustominjectionintoheader || ''} }`;
const pagetmplwithcustomizableheader = "<h2>Here is the page with customized header template</h2>\n"
+ "{{##def.mycustominjectionintoheader:\n"
+ " <div>{{=it.title}} is not {{=it.name}}</div>\n"
+ "#}}\n"
+ "{{#def.customheader}}\n"
+ "{{=it.name}}";
const pagetmplwithcustomizableheader = `<h2>Here is the page with customized header template</h2>
{{##def.mycustominjectionintoheader:
<div>{{=it.title}} is not {{=it.name}}</div>
#}}
{{#def.customheader}}
{{=it.name}}`;
const def = {
header: headertmpl,

View File

@ -79,7 +79,7 @@ const selectOptions: DropkickOptions = {
open(this: Dropkick) {
const optionsList = (<any> this).data.elem.lastChild; // undocumented but useful data field
if (optionsList.scrollWidth > optionsList.offsetWidth) {
optionsList.style.width = optionsList.scrollWidth + 25 + 'px';
optionsList.style.width = `${optionsList.scrollWidth + 25}px`;
}
},
change: () => {

View File

@ -418,7 +418,7 @@ $('#calendar').fullCalendar({
$('#calendar').fullCalendar({
dayClick(date, jsEvent, view) {
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
alert(`Coordinates: ${jsEvent.pageX},${jsEvent.pageY}`);
alert('Current view: ' + view.name);
@ -430,7 +430,7 @@ $('#calendar').fullCalendar({
$('#calendar').fullCalendar({
eventClick(calEvent, jsEvent, view) {
alert('Event: ' + calEvent.title);
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
alert(`Coordinates: ${jsEvent.pageX},${jsEvent.pageY}`);
alert('View: ' + view.name);
// change the border color just for fun
@ -649,7 +649,7 @@ $('#my-draggable').draggable({
$('#calendar').fullCalendar({
droppable: true,
drop(date, allDay) {
alert("Dropped on " + date + " with allDay=" + allDay);
alert(`Dropped on ${date} with allDay=${allDay}`);
}
});

View File

@ -5,5 +5,5 @@ getStdin().then(str => {
});
getStdin.buffer().then(buffer => {
console.log("Length " + buffer.length + buffer.toString());
console.log(`Length ${buffer.length}${buffer.toString()}`);
});

View File

@ -14,13 +14,13 @@ interface MyCustomResult {
class LinkComponent extends React.Component<CustomColumnComponentProps<MyCustomResult>> {
render() {
const url = "speakers/" + this.props.rowData.test + "/" + this.props.data;
const url = `speakers/${this.props.rowData.test}/${this.props.data}`;
return <a href={url}>{this.props.data}</a>;
}
}
const StatelessFunctionComponent = (props: CustomColumnComponentProps<MyCustomResult>) => {
const url = "speakers/" + props.rowData.test + "/" + props.data;
const url = `speakers/${props.rowData.test}/${props.data}`;
return <a href={url}>{props.data}</a>;
};

View File

@ -18,13 +18,13 @@ interface MyCustomResult {
class LinkComponent extends React.Component<CustomColumnComponentProps<MyCustomResult>> {
render() {
const url = "speakers/" + this.props.rowData.test + "/" + this.props.data;
const url = `speakers/${this.props.rowData.test}/${this.props.data}`;
return <a href={url}>{this.props.data}</a>;
}
}
const StatelessFunctionComponent = (props: CustomColumnComponentProps<MyCustomResult>) => {
const url = "speakers/" + props.rowData.test + "/" + props.data;
const url = `speakers/${props.rowData.test}/${props.data}`;
return <a href={url}>{props.data}</a>;
};

View File

@ -201,12 +201,12 @@ Hoek.stringify(a); // Returns '[Cannot display object: Converting circular
const timerObj = new Hoek.Timer();
console.log("Time is now: " + timerObj.ts);
console.log("Elapsed time from initialization: " + timerObj.elapsed() + 'milliseconds');
console.log(`Elapsed time from initialization: ${timerObj.elapsed()}milliseconds`);
// Bench
const benchObj = new Hoek.Bench();
console.log("Elapsed time from initialization: " + benchObj.elapsed() + 'milliseconds');
console.log(`Elapsed time from initialization: ${benchObj.elapsed()}milliseconds`);
// base64urlEncode(value)

View File

@ -5,4 +5,4 @@ const prefixer = new Prefixer();
const prefixed = prefixer.prefix({
fontSize: '16',
flexDirection: 'column'
} as CSSStyleDeclaration);
});

View File

@ -16,7 +16,7 @@ function test_validate() {
if (errors) {
const message = errors === 1
? 'You missed 1 field. It has been highlighted'
: 'You missed ' + errors + ' fields. They have been highlighted';
: `You missed ${errors} fields. They have been highlighted`;
$("div.error span").html(message);
$("div.error").show();
} else {
@ -124,7 +124,7 @@ function test_validate() {
});
$(".selector").validate({
showErrors: (errorMap: JQueryValidation.ErrorDictionary, errorList: JQueryValidation.ErrorListItem[]) => {
$("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below.");
$("#summary").html(`Your form contains ${this.numberOfInvalids()} errors, see details below.`);
this.defaultShowErrors();
}
});
@ -154,12 +154,12 @@ function test_validate() {
$(".selector").validate({
highlight: (element: HTMLInputElement, errorClass, validClass) => {
$(element).addClass(errorClass).removeClass(validClass);
$(element.form).find("label[for=" + element.id + "]")
$(element.form).find(`label[for=${element.id}]`)
.addClass(errorClass);
},
unhighlight: (element: HTMLInputElement, errorClass, validClass) => {
$(element).removeClass(errorClass).addClass(validClass);
$(element.form).find("label[for=" + element.id + "]")
$(element.form).find(`label[for=${element.id}]`)
.removeClass(errorClass);
}
});

View File

@ -143,7 +143,7 @@ const configurableRoundingFormatter = (maxDecimals: number) => {
const pow = Math.pow(10, maxDecimals);
const rounded = Math.round(scalar * pow) / pow;
return rounded + ' ' + units;
return `${rounded} ${units}`;
};
};
@ -1225,7 +1225,7 @@ describe("js-quantities", () => {
const pow = Math.pow(10, maxDecimals);
const rounded = Math.round(scalar * pow) / pow;
return rounded + " " + units;
return `${rounded} ${units}`;
};
};

View File

@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-empty-interface": false
// TODOs
"no-empty-interface": false,
"no-object-literal-type-assertion": false
}
}

View File

@ -28,7 +28,7 @@ const serverWithCustomConnection = JsonRpcWs.createServer<CustomConnection>();
serverWithCustomConnection.expose('join', function(params: { room: string }) {
this.rooms = this.rooms || [];
this.rooms.push(params.room);
console.log(this.id + ' joined ' + params.room);
console.log(`${this.id} joined ${params.room}`);
});
serverWithCustomConnection.start({ port: 8080 }, () => {

View File

@ -1 +1,7 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-object-literal-type-assertion": false
}
}

View File

@ -77,8 +77,8 @@ const developmentExtendedFormatLine: ExtendedFormatFn = (tokens, req: IncomingMe
developmentExtendedFormatLine.memoizer = {};
}
fn = developmentExtendedFormatLine.memoizer[color] = morgan.compile('\x1b[0m:method :url \x1b['
+ color + 'm:status \x1b[0m:response-time ms - :res[content-length]\x1b[0m :user-agent');
fn = developmentExtendedFormatLine.memoizer[color] = morgan.compile(
`\x1b[0m:method :url \x1b[${color}m:status \x1b[0m:response-time ms - :res[content-length]\x1b[0m :user-agent`);
}
return fn(tokens, req, res);

View File

@ -1 +1,7 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-object-literal-type-assertion": false
}
}

View File

@ -32,8 +32,7 @@ function main(): void {
return todoDb.select().from(itemSchema).where(column.eq(false)).exec();
}).then((results) => {
results.forEach((row) => {
document.body.textContent = (row as any).description + ' before ' +
(row as any).deadline;
document.body.textContent = `${(row as any).description} before ${(row as any).deadline}`;
});
return todoDb.delete().from(itemSchema);

View File

@ -16,7 +16,7 @@ const marker = L.marker(new L.LatLng([0, 0]), {
// every time the marker is dragged, update the coordinates container
marker.on('dragend', () => {
const m = marker.getLatLng();
coordinates.innerHTML = 'Latitude: ' + m.lat + '<br />Longitude: ' + m.lng;
coordinates.innerHTML = `Latitude: ${m.lat}<br />Longitude: ${m.lng}`;
});
// Build a marker from a simple GeoJSON object:

View File

@ -13,6 +13,7 @@ md.use(MarkdownItContainer, 'spoiler', {
if (tokens[index].nesting === 1) {
return (
// tslint:disable-next-line prefer-template
'<div class="markdown__spoiler">\n' +
'<div class="markdown__spoiler-title" onclick="' + onClick + '">\n' +
md.utils.escapeHtml(match && match[1] || '') + '\n' +

View File

@ -1,10 +1,10 @@
// Test global mithril types
const comp = {
const comp: m.Comp<{},{}> = {
view() {
return m('span', "Test")
}
} as m.Comp<{},{}>
};
m.mount(document.getElementById('comp')!, comp)

View File

@ -366,13 +366,13 @@ const FRAME_BUDGET = 100;
class User {
name: string;
constructor(data: any) {
this.name = data.firstName + " " + data.lastName;
this.name = `${data.firstName} ${data.lastName}`;
}
}
// End rewrite to TypeScript
// function User(data) {
// this.name = data.firstName + " " + data.lastName
// this.name = `${data.firstName} ${data.lastName}`
// }
m.request<User[]>({
@ -513,7 +513,7 @@ const FRAME_BUDGET = 100;
const view = () => m(".container", cells.map(i =>
m(".slice", {
style: {backgroundPosition: (i % 10 * 11) + "% " + (Math.floor(i / 10) * 11) + "%"},
style: {backgroundPosition: `${i % 10 * 11}% ${Math.floor(i / 10) * 11}%`},
onbeforeremove: exit
})));
@ -684,7 +684,7 @@ const FRAME_BUDGET = 100;
m("label[for='toggle-all']", {onclick: ui.toggleAll}, "Mark all as complete"),
m("ul#todo-list", [
state.todosByStatus.map((todo: any) => {
return m("li", {class: (todo.completed ? "completed" : "") + " " + (todo === state.editing ? "editing" : "")}, [
return m("li", {class: `${todo.completed ? "completed" : ""} ${todo === state.editing ? "editing" : ""}`}, [
m(".view", [
m("input.toggle[type='checkbox']", { checked: todo.completed, onclick: () => { ui.toggle(todo); } }),
m("label", { ondblclick: () => { state.dispatch("edit", [todo]); } }, todo.title),

View File

@ -177,10 +177,11 @@ interface State {
count: number;
}
export default {
// Using the Comp type will apply the State intersection type for us.
const comp: Comp<Attrs, State> = {
count: 0,
view({attrs}) {
return m('span', `name: ${attrs.name}, count: ${this.count}`);
}
} as Comp<Attrs, State>;
// Using the Comp type will apply the State intersection type for us.
};
export default comp;

View File

@ -23,7 +23,7 @@ m.mount(document.getElementById('comp0')!, null);
// 1.
// Simple example. Vnode type for component methods is inferred.
//
function comp1() {
function comp1(): Component<{}, {}> {
return {
oncreate({dom}) {
// vnode.dom type inferred
@ -31,7 +31,7 @@ function comp1() {
view(vnode) {
return m('span', "Test");
}
} as Component<{}, {}>;
};
}
///////////////////////////////////////////////////////////

View File

@ -8,11 +8,11 @@ const component1 = {
}
};
const component2 = {
const component2: Component<{title: string}, {}> = {
view({attrs: {title}}) {
return h('h1', title);
}
} as Component<{title: string}, {}>;
};
interface Attrs {
id: string;

View File

@ -1,7 +1,7 @@
declare const $: any;
window.alert = (thing?: string) => {
$('#content').append('<div>' + thing + '</div>');
$('#content').append(`<div>${thing}</div>`);
};
$(() => {
@ -110,7 +110,7 @@ Modernizr.prefixedCSSValue('background', 'linear-gradient(left, red, red)');
let rule = Modernizr._prefixes.join('transform: rotate(20deg); ');
rule === 'transform: rotate(20deg); webkit-transform: rotate(20deg); moz-transform: rotate(20deg); o-transform: rotate(20deg); ms-transform: rotate(20deg);';
rule = 'display:' + Modernizr._prefixes.join('flex; display:') + 'flex';
rule = `display:${Modernizr._prefixes.join('flex; display:')}flex`;
rule === 'display:flex; display:-webkit-flex; display:-moz-flex; display:-o-flex; display:-ms-flex; display:flex';
Modernizr.testAllProps('boxSizing'); // true

View File

@ -1 +1,6 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
"no-object-literal-type-assertion": false
}
}

View File

@ -1,8 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"only-arrow-functions": [
false
]
}
// TODOs
"no-object-literal-type-assertion": false,
"only-arrow-functions": false
}
}

View File

@ -14,16 +14,15 @@ emptyKey.generateKeyPair(512, 65537);
const newKey = new NodeRSA({ b: 512 });
const keyFromPEM = new NodeRSA(
'-----BEGIN RSA PRIVATE KEY-----\n' +
'MIIBOQIBAAJAVY6quuzCwyOWzymJ7C4zXjeV/232wt2ZgJZ1kHzjI73wnhQ3WQcL\n' +
'DFCSoi2lPUW8/zspk0qWvPdtp6Jg5Lu7hwIDAQABAkBEws9mQahZ6r1mq2zEm3D/\n' +
'VM9BpV//xtd6p/G+eRCYBT2qshGx42ucdgZCYJptFoW+HEx/jtzWe74yK6jGIkWJ\n' +
'AiEAoNAMsPqwWwTyjDZCo9iKvfIQvd3MWnmtFmjiHoPtjx0CIQCIMypAEEkZuQUi\n' +
'pMoreJrOlLJWdc0bfhzNAJjxsTv/8wIgQG0ZqI3GubBxu9rBOAM5EoA4VNjXVigJ\n' +
'QEEk1jTkp8ECIQCHhsoq90mWM/p9L5cQzLDWkTYoPI49Ji+Iemi2T5MRqwIgQl07\n' +
'Es+KCn25OKXR/FJ5fu6A6A+MptABL3r8SEjlpLc=\n' +
'-----END RSA PRIVATE KEY-----'
);
`-----BEGIN RSA PRIVATE KEY-----
MIIBOQIBAAJAVY6quuzCwyOWzymJ7C4zXjeV/232wt2ZgJZ1kHzjI73wnhQ3WQcL
DFCSoi2lPUW8/zspk0qWvPdtp6Jg5Lu7hwIDAQABAkBEws9mQahZ6r1mq2zEm3D/
VM9BpV//xtd6p/G+eRCYBT2qshGx42ucdgZCYJptFoW+HEx/jtzWe74yK6jGIkWJ
AiEAoNAMsPqwWwTyjDZCo9iKvfIQvd3MWnmtFmjiHoPtjx0CIQCIMypAEEkZuQUi
pMoreJrOlLJWdc0bfhzNAJjxsTv/8wIgQG0ZqI3GubBxu9rBOAM5EoA4VNjXVigJ
QEEk1jTkp8ECIQCHhsoq90mWM/p9L5cQzLDWkTYoPI49Ji+Iemi2T5MRqwIgQl07
Es+KCn25OKXR/FJ5fu6A6A+MptABL3r8SEjlpLc=
-----END RSA PRIVATE KEY-----`);
const keyData = '-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----';
key.importKey(keyData, 'pkcs8');

View File

@ -44,12 +44,11 @@ function test_application() {
});
// getGroups
application.getGroups(allGroups => {
console.log("There are a total of " + allGroups.length + " groups.");
console.log(`There are a total of ${allGroups.length} groups.`);
let groupCounter = 1;
allGroups.forEach(windowGroup => {
console.log("Group " + groupCounter + " contains " +
windowGroup.length + " windows.");
console.log(`Group ${groupCounter} contains ${windowGroup.length} windows.`);
++groupCounter;
});
});
@ -122,7 +121,7 @@ function test_application() {
});
// setTrayIcon
application.setTrayIcon("https://developer.openf.in/download/openfin.png", clickInfo => {
console.log("The mouse has clicked at (" + clickInfo.x + "," + clickInfo.y + ")");
console.log(`The mouse has clicked at (${clickInfo.x}, ${clickInfo.y})`);
});
// terminate
application.terminate();
@ -157,11 +156,11 @@ function test_external_application() {
function test_inter_application_bus() {
// addSubscribeListener
fin.desktop.InterApplicationBus.addSubscribeListener((uuid, topic, name) => {
console.log("The application " + uuid + " has subscribed to " + topic);
console.log(`The application ${uuid} has subscribed to ${topic}`);
});
// addUnsubscribeListener
fin.desktop.InterApplicationBus.addUnsubscribeListener((uuid, topic, name) => {
console.log("The application " + uuid + " has unsubscribed to " + topic);
console.log(`The application ${uuid} has unsubscribed to ${topic}`);
});
// removeSubscribeListener
const aRegisteredListener = (uuid: string, topic: string, name: string) => { };
@ -180,7 +179,7 @@ function test_inter_application_bus() {
});
// subscribe
fin.desktop.InterApplicationBus.subscribe("*", "a topic", (message, uuid, name) => {
console.log("The application " + uuid + " sent this message: " + message);
console.log(`The application ${uuid} sent this message: ${message}`);
});
// unsubscribe
const aRegisteredMessageListener = (message: any, senderUuid: string) => {
@ -305,10 +304,7 @@ function test_system() {
// getLogList
fin.desktop.System.getLogList(logList => {
logList.forEach(logInfo => {
console.log("The filename of the log is " +
logInfo.name + ", the size is " +
logInfo.size + ", and the date of creation is " +
logInfo.date);
console.log(`The filename of the log is ${logInfo.name}, the size is ${logInfo.size}, and the date of creation is ${logInfo.date}`);
});
});
// getMonitorInfo
@ -317,12 +313,12 @@ function test_system() {
});
// getMousePosition
fin.desktop.System.getMousePosition(mousePosition => {
console.log("The mouse is located at left: " + mousePosition.left + ", top: " + mousePosition.top);
console.log(`The mouse is located at left: ${mousePosition.left}, top: ${mousePosition.top}`);
});
// getProcessList
fin.desktop.System.getProcessList(list => {
list.forEach(process => {
console.log("UUID: " + process.uuid + ", Application Name: " + process.name);
console.log(`UUID: ${process.uuid}, Application Name: ${process.name}`);
});
});
// getProxySettings
@ -612,10 +608,7 @@ function test_window() {
finWindow.focus();
// getBounds
finWindow.getBounds(bounds => {
console.log("top: " + bounds.top +
"left: " + bounds.left +
"height: " + bounds.height +
"width: " + bounds.width);
console.log(`top: ${bounds.top} left: ${bounds.left} height: ${bounds.height} width: ${bounds.width}`);
});
// getOptions
finWindow.getOptions(options => {

View File

@ -21,7 +21,7 @@ const names2 = [
];
pReduce<string | number, string>(names2, (allNames, name) => {
return Promise.resolve(allNames + ',' + name);
return Promise.resolve(`${allNames},${name}`);
}, '').then(allNames => {
const str: string = allNames;
});

View File

@ -167,7 +167,7 @@ popover.setList([
popover.setList(['a', 'b', 'c'], item => {
const text = typeof item === 'string' ? item : item.text;
const value = typeof item === 'string' ? item : item.value;
return '<li><a class="padded-list" data-value="' + value + '">' + text + '</a></li>';
return `<li><a class="padded-list" data-value="${value}">${text}</a></li>`;
});
popover.attachButton('.button-trigger-popover', true);

View File

@ -1 +1,7 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-object-literal-type-assertion": false
}
}

View File

@ -6,7 +6,7 @@ import Entry = webdriver.logging.Entry;
function colored(entries: Entry[]) {
const colors: any = { INFO: 35 /* magenta */, WARNING: 33 /* yellow */, SEVERE: 31 /* red */};
entries.forEach((entry: Entry) => {
console.log('\u001b[' + (colors[entry.level.name] || 37) + 'm' + [entry.level.name, entry.message].join(': ') + '\u001b[39m');
console.log(`\u001b[${colors[entry.level.name] || 37}m${[entry.level.name, entry.message].join(': ')}\u001b[39m`);
});
}

View File

@ -68,7 +68,7 @@ const uploadBegin: RNFS.UploadCallbackBegin = (response) => {
const uploadProgress: RNFS.UploadCallbackProgress = (response) => {
const percentage = Math.floor((response.totalBytesSent / response.totalBytesExpectedToSend) * 100);
console.log('UPLOAD IS ' + percentage + '% DONE!');
console.log(`UPLOAD IS ${percentage}% DONE!`);
};
// upload files

View File

@ -1 +1,7 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-object-literal-type-assertion": false
}
}

View File

@ -12,6 +12,7 @@
"no-misused-new": false,
"no-consecutive-blank-lines": false,
"no-empty-interface": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-var": false,
"prefer-declare-function": false,

View File

@ -9,7 +9,7 @@ import SwipeableViews,
} from 'react-swipeable-views';
const onChangeIndex: OnChangeIndexCallback = (indexNew: number, indexLatest: number) => {
console.log('New index: ' + indexNew + ', latest index' + indexLatest);
console.log(`New index: ${indexNew}, latest index ${indexLatest}`);
};
const onSwitching: OnSwitchingCallback = (index: number, type: OnSwitchingCallbackTypeDescriptor) => {

View File

@ -55,7 +55,7 @@ readlineSync.promptCL((command: string, arg1: string, arg2: string) => {
if (command === 'add') {
console.log(arg1 + ' is added.');
} else if (command === 'copy') {
console.log(arg1 + ' is copied to ' + arg2 + '.');
console.log(`${arg1} is copied to ${arg2}.`);
}
});
@ -64,12 +64,12 @@ readlineSync.promptCL({
console.log(element + ' is added.');
},
copy: (from: string, to: string) => {
console.log(from + ' is copied to ' + to + '.');
console.log(`${from} is copied to ${to}.`);
}
});
readlineSync.promptLoop((input: string) => {
console.log('-- You said "' + input + '"');
console.log(`-- You said "${input}"`);
return input === 'bye';
});
@ -78,7 +78,7 @@ readlineSync.promptCLLoop({
console.log(element + ' is added.');
},
copy: (from: string, to: string) => {
console.log(from + ' is copied to ' + to + '.');
console.log(`${from} is copied to ${to}.`);
},
bye: () => true
});

View File

@ -11,7 +11,7 @@ riot.settings.asyncRenderTimeout = 100500;
// util.tmpl
riot.util.tmpl.errorHandler = (err: riot.TemplateError) => {
console.error(err.message + ' in ' + err.riotData.tagName);
console.error(`${err.message} in ${err.riotData.tagName}`);
};
// util.vdom

View File

@ -63,7 +63,7 @@ class Item {
a() {
const first = self.name.charAt(0);
return (first.match(/[aeiouy]/i) ? "an" : "a") + " " + this.name;
return `${first.match(/[aeiouy]/i) ? "an" : "a"} ${this.name}`;
}
the() {
@ -465,7 +465,7 @@ cellular.create(display.DEBUG);
display = new ROT.Display({ width: w, height: h, fontSize: 4 });
SHOW(display.getContainer());
cellular.connect(display.DEBUG, 0, (from, to) => {
SHOW("Connection was made " + from + " to " + to);
SHOW(`Connection was made ${from} to ${to}`);
});
// Map creation / Dungeon
@ -531,13 +531,13 @@ SHOW(display.getContainer());
/* create a map */
let data_uniform: any = {};
new ROT.Map.Uniform().create((x: number, y: number, type: number) => {
data_uniform[x + "," + y] = type;
data_uniform[`${x},${y}`] = type;
display.DEBUG(x, y, type);
});
/* input callback */
let lightPasses = (x: number, y: number) => {
const key = x + "," + y;
const key = `${x},${y}`;
if (key in data_uniform) { return (data_uniform[key] === 0); }
return false;
};
@ -547,7 +547,7 @@ let fov = new ROT.FOV.PreciseShadowcasting(lightPasses);
/* output callback */
fov.compute(50, 22, 10, (x, y, r, visibility) => {
const ch = (r ? "" : "@");
const color = (data_uniform[x + "," + y] ? "#aa0" : "#660");
const color = (data_uniform[`${x},${y}`] ? "#aa0" : "#660");
display.draw(x, y, ch, "#fff", color);
});
@ -563,13 +563,13 @@ SHOW(display.getContainer());
/* create a map */
data_uniform = {};
new ROT.Map.Uniform().create((x: number, y: number, type: number) => {
data_uniform[x + "," + y] = type;
data_uniform[`${x},${y}`] = type;
display.DEBUG(x, y, type);
});
/* input callback */
lightPasses = (x: number, y: number) => {
const key = x + "," + y;
const key = `${x},${y}`;
if (key in data_uniform) { return (data_uniform[key] === 0); }
return false;
};
@ -579,21 +579,21 @@ const fov2 = new ROT.FOV.RecursiveShadowcasting(lightPasses);
/* output callback for mob with bad vision */
fov2.compute90(50, 22, 10, DIR_WEST, (x: number, y: number, r: number, visibility: number) => {
const ch = (r ? "1" : "@");
const color = (data_uniform[x + "," + y] ? "#aa0" : "#660");
const color = (data_uniform[`${x},${y}`] ? "#aa0" : "#660");
display.draw(x, y, ch, "#fff", color);
});
/* output callback for second mob with better vision */
fov2.compute180(57, 14, 10, DIR_NORTH, (x: number, y: number, r: number, visibility: number) => {
const ch = (r ? "2" : "@");
const color = (data_uniform[x + "," + y] ? "#aa0" : "#660");
const color = (data_uniform[`${x},${y}`] ? "#aa0" : "#660");
display.draw(x, y, ch, "#fff", color);
});
/* output callback for third mob with supernatural vision */
fov2.compute(65, 5, 10, (x: number, y: number, r: number, visibility: number) => {
const ch = (r ? "3" : "@");
const color = (data_uniform[x + "," + y] ? "#aa0" : "#660");
const color = (data_uniform[`${x},${y}`] ? "#aa0" : "#660");
display.draw(x, y, ch, "#fff", color);
});
@ -652,7 +652,7 @@ const lightData: { [key: string]: [number, number, number] } = {};
/* build a map */
cellular = new ROT.Map.Cellular().randomize(0.5);
const createCallback = (x: number, y: number, value: number) => {
mapData[x + "," + y] = value;
mapData[`${x},${y}`] = value;
};
for (let i = 0; i < 4; i++) {
cellular.create(createCallback);
@ -660,13 +660,13 @@ for (let i = 0; i < 4; i++) {
/* prepare a FOV algorithm */
lightPasses = (x: number, y: number) => {
return (mapData[x + "," + y] === 1);
return (mapData[`${x},${y}`] === 1);
};
fov = new ROT.FOV.PreciseShadowcasting(lightPasses, { topology: 4 });
/* prepare a lighting algorithm */
const reflectivity = (x: number, y: number) => {
return (mapData[x + "," + y] === 1 ? 0.3 : 0);
return (mapData[`${x},${y}`] === 1 ? 0.3 : 0);
};
const lighting = new ROT.Lighting(reflectivity, { range: 12, passes: 2 });
lighting.setFOV(fov);
@ -675,7 +675,7 @@ lighting.setLight(20, 20, [240, 60, 60]);
lighting.setLight(45, 25, [200, 200, 200]);
const lightingCallback = (x: number, y: number, color: [number, number, number]) => {
lightData[x + "," + y] = color;
lightData[`${x},${y}`] = color;
};
lighting.compute(lightingCallback);
@ -711,13 +711,13 @@ SHOW(display.getContainer());
const uni_data: any = {};
let uni_map = new ROT.Map.Uniform(w, h);
uni_map.create((x, y, value) => {
uni_data[x + "," + y] = value;
uni_data[`${x},${y}`] = value;
display.DEBUG(x, y, value);
});
/* input callback informs about map structure */
let passableCallback = (x: number, y: number) => {
return (uni_data[x + "," + y] === 0);
return (uni_data[`${x},${y}`] === 0);
};
/* prepare path to given coords */
@ -747,13 +747,13 @@ SHOW(display.getContainer());
/* generate map and store its data */
uni_map = new ROT.Map.Uniform(w, h);
uni_map.create((x: number, y: number, value: number) => {
uni_data[x + "," + y] = value;
uni_data[`${x},${y}`] = value;
display.DEBUG(x, y, value);
});
/* input callback informs about map structure */
passableCallback = (x: number, y: number) => {
return (uni_data[x + "," + y] === 0);
return (uni_data[`${x},${y}`] === 0);
};
/* prepare path to given coords */
@ -786,7 +786,7 @@ for (let j = 0; j < h; j++) {
const r = ~~(val > 0 ? val : 0);
const g = ~~(val < 0 ? -val : 0);
display.draw(i, j, "", "", "rgb(" + r + "," + g + ",0)");
display.draw(i, j, "", "", `rgb(${r},${g},0)`);
}
}
// ----
@ -801,7 +801,7 @@ for (let j = 0; j < h; j++) {
const r = ~~(val > 0 ? val : 0);
const g = ~~(val < 0 ? -val : 0);
display.draw(i, j, "", "", "rgb(" + r + "," + g + ",0)");
display.draw(i, j, "", "", `rgb(${r},${g},0)`);
}
}
@ -1014,7 +1014,7 @@ SHOW(display.getContainer());
for (let y = 0; y < 4; y++) {
for (let x = y % 2; x < 10; x += 2) {
const bg = ["#333", "#666", "#999", "#ccc", "#fff"].random();
display.draw(x, y, x + "," + y, "#000", bg);
display.draw(x, y, `${x},${y}`, "#000", bg);
}
}
@ -1061,13 +1061,13 @@ cell_map = new ROT.Map.Cellular(w, h, {
cell_map.randomize(0.48);
cell_map.create(); /* two iterations */
cell_map.create((x: number, y: number, value: number) => {
cell_data[x + "," + y] = value;
cell_data[`${x},${y}`] = value;
display.DEBUG(x, y, value);
});
/* input callback informs about map structure */
passableCallback = (x: number, y: number) => {
return (cell_data[x + "," + y] === 0);
return (cell_data[`${x},${y}`] === 0);
};
/* prepare path to given coords */
@ -1098,13 +1098,13 @@ cell_map = new ROT.Map.Cellular(undefined, undefined, {
});
cell_map.randomize(0.4);
cell_map.create((x: number, y: number, value: number) => {
cell_data[x + "," + y] = value;
cell_data[`${x},${y}`] = value;
display.DEBUG(x, y, value);
});
/* input callback */
lightPasses = (x: number, y: number) => {
const key = x + "," + y;
const key = `${x},${y}`;
if (key in cell_data) { return (cell_data[key] === 0); }
return false;
};
@ -1114,6 +1114,6 @@ fov = new ROT.FOV.PreciseShadowcasting(lightPasses, { topology: 6 });
/* output callback */
fov.compute(20, 14, 6, (x, y, r, vis) => {
const ch = (r ? "" : "@");
const color = (cell_data[x + "," + y] ? "#aa0" : "#660");
const color = (cell_data[`${x},${y}`] ? "#aa0" : "#660");
display.draw(x, y, ch, "#fff", color);
});

View File

@ -1,7 +1,9 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODOs
"max-line-length": false,
"no-object-literal-type-assertion": false,
"no-single-declare-module": false
}
}

View File

@ -28,7 +28,7 @@ function readAllRows() {
console.log("readAllRows lorem");
db.all("SELECT rowid AS id, info FROM lorem", (err, rows) => {
rows.forEach(row => {
console.log(row.id + ": " + row.info);
console.log(`${row.id}: ${row.info}`);
});
readSomeRows();
});
@ -37,7 +37,7 @@ function readAllRows() {
function readSomeRows() {
console.log("readAllRows lorem");
db.each("SELECT rowid AS id, info FROM lorem WHERE rowid < ? ", 5, (err, row) => {
console.log(row.id + ": " + row.info);
console.log(`${row.id}: ${row.info}`);
}, closeDb);
}
@ -62,7 +62,7 @@ db.serialize(() => {
stmt.finalize();
db.each("SELECT rowid AS id, info FROM lorem", (err, row) => {
console.log(row.id + ": " + row.info);
console.log(`${row.id}: ${row.info}`);
});
});

View File

@ -34,7 +34,7 @@ agent
if (res.error) {
console.log('oh no ' + res.error.message);
} else {
console.log('got ' + res.status + ' response');
console.log(`got ${res.status} response`);
}
});
@ -229,7 +229,7 @@ const reqUrl: string = req.url;
const reqMethod: string = req.method;
const reqCookies: string = req.cookies;
console.log(reqMethod + ' request to ' + reqUrl + ' cookies ' + reqCookies);
console.log(`${reqMethod} request to ${reqUrl} cookies ${reqCookies}`);
// Basic authentication
request.get('http://tobi:learnboost@local').end(callback);

View File

@ -241,23 +241,23 @@ function dynamicSlides() {
document.querySelector('.prepend-2-slides').addEventListener('click', e => {
e.preventDefault();
swiper.prependSlide([
'<div class="swiper-slide">Slide ' + (--prependNumber) + '</div>',
'<div class="swiper-slide">Slide ' + (--prependNumber) + '</div>'
`<div class="swiper-slide">Slide ${--prependNumber}</div>`,
`<div class="swiper-slide">Slide ${--prependNumber}</div>`
]);
});
document.querySelector('.prepend-slide').addEventListener('click', e => {
e.preventDefault();
swiper.prependSlide('<div class="swiper-slide">Slide ' + (--prependNumber) + '</div>');
swiper.prependSlide(`<div class="swiper-slide">Slide ${--prependNumber}</div>`);
});
document.querySelector('.append-slide').addEventListener('click', e => {
e.preventDefault();
swiper.appendSlide('<div class="swiper-slide">Slide ' + (++appendNumber) + '</div>');
swiper.appendSlide(`<div class="swiper-slide">Slide ${++appendNumber}</div>`);
});
document.querySelector('.append-2-slides').addEventListener('click', e => {
e.preventDefault();
swiper.appendSlide([
'<div class="swiper-slide">Slide ' + (++appendNumber) + '</div>',
'<div class="swiper-slide">Slide ' + (++appendNumber) + '</div>'
`<div class="swiper-slide">Slide ${++appendNumber}</div>`,
`<div class="swiper-slide">Slide ${++appendNumber}</div>`
]);
});
}
@ -363,7 +363,7 @@ function customPagination() {
pagination: '.swiper-pagination',
paginationClickable: true,
paginationBulletRender(swiper, index, className) {
return '<span class="' + className + '">' + (index + 1) + '</span>';
return `<span class="${className}">${index + 1}</span>`;
}
});
}

View File

@ -22,13 +22,13 @@ toMarkdown(`
{
filter: 'code',
replacement(innerHTML) {
return '`' + innerHTML + '`';
return `\`${innerHTML}\``;
}
},
{
filter: ['em', 'i'],
replacement(innerHTML) {
return '*' + innerHTML + '*';
return `*${innerHTML}*`;
}
},
{
@ -37,7 +37,7 @@ toMarkdown(`
&& /italic/i.test(node.style.fontStyle!);
},
replacement(innerHTML) {
return '*' + innerHTML + '*';
return `*${innerHTML}*`;
}
},
{
@ -46,7 +46,7 @@ toMarkdown(`
&& /italic/i.test(node.style.fontStyle!);
},
replacement(innerHTML, node) {
return innerHTML + ' (node: `' + node.nodeName + '`)';
return `${innerHTML}(node: \`${node.nodeName}\`)`;
}
}
]

View File

@ -1,3 +1,7 @@
{
"extends": "dtslint/dt.json"
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-object-literal-type-assertion": false
}
}

View File

@ -873,7 +873,7 @@ describe('symlink stream', () => {
});
['end', 'finish'].forEach(eventName => {
it('should emit ' + eventName + ' event', done => {
it(`should emit ${eventName} event`, done => {
const srcPath = path.join(__dirname, './fixtures/test.coffee');
const stream = vfs.symlink('./out-fixtures/', { cwd: __dirname });

View File

@ -197,7 +197,7 @@ str = v.replace();
str = v.replace('swan', 'wa', 'u');
str = v.replace('domestic duck', /domestic\s/, '');
str = v.replace('nice duck', /(nice)(duck)/, (match: string, nice: string, duck: string) => {
return 'the ' + duck + ' is ' + nice;
return `the ${duck} is ${nice}`;
});
str = v.replaceAll();

View File

@ -35,7 +35,7 @@ let waypoint3 = new Waypoint({
let waypoint4 = new Waypoint({
element: document.getElementById('element-waypoint')!,
handler(direction) {
notify(this.element.id + ' triggers at ' + this.triggerPoint);
notify(`${this.element.id} triggers at ${this.triggerPoint}`);
},
offset: '75%'
});

View File

@ -28,9 +28,7 @@ function test_AnimationsApiNext() {
function buildFadeOut(target: HTMLElement) {
const angle = Math.pow((Math.random() * 16) - 6, 3);
const offset = (Math.random() * 20) - 10;
const transform = 'translate(' + offset + 'em, 20em) ' +
'rotate(' + angle + 'deg) ' +
'scale(0)';
const transform = `translate(${offset}em, 20em) rotate(${angle}deg) scale(0)`;
const steps = [
{ visibility: 'visible', opacity: 1, transform: 'none' },
{ visibility: 'visible', opacity: 0, transform }
@ -43,13 +41,13 @@ function test_AnimationsApiNext() {
const effectNode = document.createElement('div');
effectNode.className = 'circleEffect';
const bounds = document.documentElement.getBoundingClientRect();
effectNode.style.left = bounds.left + bounds.width / 2 + 'px';
effectNode.style.top = bounds.top + bounds.height / 2 + 'px';
effectNode.style.left = `${bounds.left + bounds.width / 2}px`;
effectNode.style.top = `${bounds.top + bounds.height / 2}px`;
const header = document.querySelector('header');
if (header) {
header.appendChild(effectNode);
}
const newColor = 'hsl(' + Math.round(Math.random() * 255) + ', 46%, 42%)';
const newColor = `hsl(${Math.round(Math.random() * 255)}, 46%, 42%)`;
effectNode.style.background = newColor;
const scaleSteps = [{ transform: 'scale(0)' }, { transform: 'scale(1)' }];
const timing: AnimationEffectTiming = { duration: 2500, easing: 'ease-in-out', fill: "backwards" };

View File

@ -30,7 +30,7 @@ debug(`wasmDataU8[7]=${wasmDataU8[7].toString(16)}`);
// Validate
let valid = WebAssembly.validate(wasmDataU8);
debug("wasmDataU8 is " + (valid ? "" : "not ") + "a valid wasm wasmModule");
debug(`wasmDataU8 is ${valid ? "" : "not "}a valid wasm wasmModule`);
// Module
let wasmModule = new WebAssembly.Module(wasmDataU8);

View File

@ -99,7 +99,7 @@ webdriverio
.init()
.url("https://news.ycombinator.com/")
.selectorExecute("//div", (inputs: HTMLElement[], message: string) => {
return inputs.length + " " + message;
return `${inputs.length} ${message}`;
}, "divs on the page")
.then((res: string) => {
console.log(res);

View File

@ -1 +1,6 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
"no-object-literal-type-assertion": false
}
}

View File

@ -49,7 +49,7 @@ declare namespace wx {
*
* @param x
*/
function ready(x: () => void ): void;
function ready(x: () => void): void;
/**
*

View File

@ -36,7 +36,7 @@ grids.forEach((gridControl: Xrm.Page.GridControl) => {
/// Demonstrate generic overload vs typecast
const lookupAttribute = Xrm.Page.getControl("customerid");
const lookupAttribute = <Xrm.Page.LookupControl> Xrm.Page.getControl("customerid");
const lookupAttribute2 = Xrm.Page.getControl<Xrm.Page.LookupControl>("customerid");
/// Demonstrate ES6 String literal syntax

View File

@ -192,15 +192,15 @@ let count = 0;
$('#draggableBtn').draggable({
container: '#draggableBox',
before: () => {
console.log(count++ + ': ' + '[开始] 拖动...\n');
console.log(`${count++}: [开始] 拖动...\n`);
return true;
},
drag: (e: DraggableEvent) => {
console.log(count++ + ': ' + '拖动: pos = ' + JSON.stringify(e.pos) + ', offset = ' + JSON.stringify(e.offset) + '\n');
console.log(`${count++}: 拖动: pos = ${JSON.stringify(e.pos)}, offset = ${JSON.stringify(e.offset)}\n`);
// console.log('(' + e.pos.left + ', ' + e.pos.top + ')');
},
finish: (e: DraggableEvent) => {
console.log(count++ + ': ' + '[完毕]pos = ' + JSON.stringify(e.pos) + ', offset = ' + JSON.stringify(e.offset) + '\n');
console.log(`${count++}: [完毕]pos = ${JSON.stringify(e.pos)}, offset = ${JSON.stringify(e.offset)}\n`);
}
});
@ -218,8 +218,8 @@ $('#multiDroppableContainer').droppable({
if (event.target && event.element) {
const elementId = event.element.find('.btn-droppable-id').text();
let msg = '真棒!';
event.target.addClass('panel-success').find('.panel-heading').text('成功将【按钮#' + elementId + '】拖到目的地。');
msg += '成功拖动【按钮#' + elementId + '】到区域 ' + event.target.find('.area-name').text();
event.target.addClass('panel-success').find('.panel-heading').text(`成功将【按钮#${elementId}】拖到目的地。`);
msg += `成功拖动【按钮#${elementId}】到区域${event.target.find('.area-name').text()}`;
$.zui.messager.show(msg);
}