This commit is contained in:
Alexander T 2019-06-20 10:51:29 +03:00
parent 882dfd265c
commit 38652d4cd7
10 changed files with 56 additions and 54 deletions

View file

@ -109,7 +109,7 @@
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-var": "off",
"no-var": "error",
"object-shorthand": "error",
"one-var": "off",
"prefer-const": "error",
@ -127,7 +127,8 @@
"overrides": [{
"files": ["src/lib/*.d.ts"],
"rules": {
"@typescript-eslint/interface-name-prefix": "off"
"@typescript-eslint/interface-name-prefix": "off",
"no-var": "off"
}
}]
}

View file

@ -167,14 +167,14 @@ namespace Commands {
listAuthors.description = "List known and unknown authors for a given spec, e.g. 'node authors.js listAuthors origin/release-2.6..origin/release-2.7'";
}
var args = process.argv.slice(2);
const args = process.argv.slice(2);
if (args.length < 1) {
console.log("Usage: node authors.js [command]");
console.log("List of commands: ");
Object.keys(Commands).forEach(k => console.log(` ${k}: ${(Commands as any)[k].description}`));
}
else {
var cmd: Function = (Commands as any)[args[0]];
const cmd: Function = (Commands as any)[args[0]];
if (cmd === undefined) {
console.log("Unknown command " + args[1]);
}

View file

@ -6,17 +6,17 @@ import cp = require("child_process");
import fs = require("fs");
// Slice off 'node bisect-test.js' from the command line args
var args = process.argv.slice(2);
const args = process.argv.slice(2);
function tsc(tscArgs: string, onExit: (exitCode: number) => void) {
var tsc = cp.exec("node built/local/tsc.js " + tscArgs,() => void 0);
const tsc = cp.exec("node built/local/tsc.js " + tscArgs,() => void 0);
tsc.on("close", tscExitCode => {
onExit(tscExitCode);
});
}
// TODO: Rewrite bisect script to handle the post-jake/gulp swap period
var jake = cp.exec("jake clean local", () => void 0);
const jake = cp.exec("jake clean local", () => void 0);
jake.on("close", jakeExitCode => {
if (jakeExitCode === 0) {
// See what we're being asked to do
@ -35,7 +35,7 @@ jake.on("close", jakeExitCode => {
else if (args[1] === "emits" || args[1] === "!emits") {
tsc(args[0], tscExitCode => {
fs.readFile(args[2], "utf-8", (err, data) => {
var doesContains = data.indexOf(args[3]) >= 0;
const doesContains = data.indexOf(args[3]) >= 0;
if (doesContains === (args[1] === "emits")) {
console.log("Good");
process.exit(0); // Good

View file

@ -20,8 +20,8 @@ class DeclarationsWalker {
}
static getExtraDeclarations(typeChecker: ts.TypeChecker, protocolFile: ts.SourceFile): string {
const walker = new DeclarationsWalker(typeChecker, protocolFile);
let text = "declare namespace ts.server.protocol {\n";
var walker = new DeclarationsWalker(typeChecker, protocolFile);
walker.visitTypeNodes(protocolFile);
text = walker.text
? `declare namespace ts.server.protocol {\n${walker.text}}`

View file

@ -1,4 +1,3 @@
declare var require: any;
const fs = require("fs");
const async = require("async");
const glob = require("glob");

View file

@ -7,7 +7,7 @@ interface Map<T> {
[key: string]: T;
}
declare var process: {
declare let process: {
argv: string[];
env: Map<string>;
exit(exitCode?: number): void;

View file

@ -130,13 +130,13 @@ namespace Word {
}
}
var sys = (function () {
var fileStream = new ActiveXObject("ADODB.Stream");
fileStream.Type = 2 /*text*/;
var binaryStream = new ActiveXObject("ADODB.Stream");
binaryStream.Type = 1 /*binary*/;
var args: string[] = [];
for (var i = 0; i < WScript.Arguments.length; i++) {
const sys = (function () {
const fileStream = new ActiveXObject("ADODB.Stream");
fileStream.Type = 2 /* text */;
const binaryStream = new ActiveXObject("ADODB.Stream");
binaryStream.Type = 1 /* binary */;
const args: string[] = [];
for (let i = 0; i < WScript.Arguments.length; i++) {
args[i] = WScript.Arguments.Item(i);
}
return {
@ -176,17 +176,17 @@ interface FindReplaceOptions {
function convertDocumentToMarkdown(doc: Word.Document): string {
var result = "";
var lastStyle: string;
var lastInTable: boolean;
var tableColumnCount: number;
var tableCellIndex: number;
var columnAlignment: number[] = [];
const columnAlignment: number[] = [];
let tableColumnCount: number;
let tableCellIndex: number;
let lastInTable: boolean;
let lastStyle: string;
let result = "";
function setProperties(target: any, properties: any) {
for (var name in properties) {
for (const name in properties) {
if (properties.hasOwnProperty(name)) {
var value = properties[name];
const value = properties[name];
if (typeof value === "object") {
setProperties(target[name], value);
}
@ -198,10 +198,10 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
}
function findReplace(findText: string, findOptions: FindReplaceOptions, replaceText: string, replaceOptions: FindReplaceOptions) {
var find = doc.range().find;
const find = doc.range().find;
find.clearFormatting();
setProperties(find, findOptions);
var replace = find.replacement;
const replace = find.replacement;
replace.clearFormatting();
setProperties(replace, replaceOptions);
find.execute(findText,
@ -219,12 +219,12 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
}
function fixHyperlinks() {
var count = doc.hyperlinks.count;
for (var i = 0; i < count; i++) {
var hyperlink = doc.hyperlinks.item(i + 1);
var address = hyperlink.address;
const count = doc.hyperlinks.count;
for (let i = 0; i < count; i++) {
const hyperlink = doc.hyperlinks.item(i + 1);
const address = hyperlink.address;
if (address && address.length > 0) {
var textToDisplay = hyperlink.textToDisplay;
const textToDisplay = hyperlink.textToDisplay;
hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")";
}
}
@ -235,7 +235,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
}
function writeTableHeader() {
for (var i = 0; i < tableColumnCount - 1; i++) {
for (let i = 0; i < tableColumnCount - 1; i++) {
switch (columnAlignment[i]) {
case 1:
write("|:---:");
@ -251,7 +251,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
}
function trimEndFormattingMarks(text: string) {
var i = text.length;
let i = text.length;
while (i > 0 && text.charCodeAt(i - 1) < 0x20) i--;
return text.substr(0, i);
}
@ -271,12 +271,13 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
function writeParagraph(p: Word.Paragraph) {
var range = p.range;
var text = range.text;
var style = p.style.nameLocal;
var inTable = range.tables.count > 0;
var level = 1;
var sectionBreak = text.indexOf("\x0C") >= 0;
const range = p.range;
const inTable = range.tables.count > 0;
const sectionBreak = range.text.indexOf("\x0C") >= 0;
let level = 1;
let style = p.style.nameLocal;
let text = range.text;
text = trimEndFormattingMarks(text);
if (text === "/") {
@ -285,7 +286,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
// hidden text and, if so, emit that instead. The hidden text is assumed to
// contain an appropriate markdown image link.
range.textRetrievalMode.includeHiddenText = true;
var fullText = range.text;
const fullText = range.text;
range.textRetrievalMode.includeHiddenText = false;
if (text !== fullText) {
text = "&emsp;&emsp;" + fullText.substr(1);
@ -307,7 +308,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
case "Heading":
case "Appendix":
var section = range.listFormat.listString;
const section = range.listFormat.listString;
write("####".substr(0, level) + ' <a name="' + section + '"/>' + section + " " + text + "\n\n");
break;
@ -358,7 +359,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
break;
case "TOC":
var strings = text.split("\t");
const strings = text.split("\t");
write(" ".substr(0, level * 2 - 2) + "* [" + strings[0] + " " + strings[1] + "](#" + strings[0] + ")\n");
break;
}
@ -371,11 +372,11 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
}
function writeDocument() {
var title = doc.builtInDocumentProperties.item(1) + "";
const title = doc.builtInDocumentProperties.item(1) + "";
if (title.length) {
write("# " + title + "\n\n");
}
for (var p = doc.paragraphs.first; p; p = p.next()) {
for (let p = doc.paragraphs.first; p; p = p.next()) {
writeParagraph(p);
}
writeBlockEnd();
@ -412,8 +413,8 @@ function main(args: string[]) {
sys.write("Syntax: word2md <inputfile> <outputfile>\n");
return;
}
var app: Word.Application = sys.createObject("Word.Application");
var doc = app.documents.open(args[0]);
const app: Word.Application = sys.createObject("Word.Application");
const doc = app.documents.open(args[0]);
sys.writeFile(args[1], convertDocumentToMarkdown(doc));
doc.close(/* saveChanges */ false);
app.quit();

View file

@ -1,5 +1,5 @@
namespace evaluator {
declare var Symbol: SymbolConstructor;
declare let Symbol: SymbolConstructor;
const sourceFile = vpath.combine(vfs.srcFolder, "source.ts");

View file

@ -1,9 +1,9 @@
// Block scoped definitions work poorly for global variables, temporarily enable var
/* tslint:disable:no-var-keyword */
/* eslint-disable no-var */
// this will work in the browser via browserify
var _chai: typeof chai = require("chai");
var assert: typeof _chai.assert = _chai.assert;
const _chai: typeof chai = require("chai");
const assert: typeof _chai.assert = _chai.assert;
{
// chai's builtin `assert.isFalse` is featureful but slow - we don't use those features,
// so we'll just overwrite it as an alterative to migrating a bunch of code off of chai
@ -32,6 +32,7 @@ var global: NodeJS.Global = Function("return this").call(undefined); // eslint-d
declare var window: {};
declare var XMLHttpRequest: new() => XMLHttpRequest;
interface XMLHttpRequest {
readonly readyState: number;
readonly responseText: string;
@ -44,7 +45,7 @@ interface XMLHttpRequest {
getResponseHeader(header: string): string | null;
overrideMimeType(mime: string): void;
}
/* tslint:enable:no-var-keyword prefer-const */
/* eslint-enable no-var */
namespace Utils {
export function encodeString(s: string): string {

View file

@ -6,7 +6,7 @@ interface PromiseConstructor {
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
}
/* @internal */
declare var Promise: PromiseConstructor;
declare let Promise: PromiseConstructor;
// These utilities are common to multiple language service features.
/* @internal */