Skip to content

Commit

Permalink
Update eslint and @typescript-eslint (denoland/std#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored and ry committed Oct 5, 2019
1 parent 2f90225 commit 96fe2d1
Show file tree
Hide file tree
Showing 54 changed files with 204 additions and 188 deletions.
4 changes: 2 additions & 2 deletions .ci/template.linux.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
steps:
- bash: npm install eslint@5.16.0 typescript@$(TS_VERSION) @typescript-eslint/eslint-plugin@1.13.0 @typescript-eslint/parser@1.13.0 eslint-config-prettier
- bash: npm install eslint@$(ESLINT_VERSION) typescript@$(TS_VERSION) @typescript-eslint/eslint-plugin@$(TS_ESLINT_VERSION) @typescript-eslint/parser@$(TS_ESLINT_VERSION) eslint-config-prettier
- template: ./template.unix.yml
- bash: npx eslint **/*.ts --max-warnings=0
- bash: npx eslint "**/*.ts" --max-warnings=0
- template: ./template.common.yml
8 changes: 5 additions & 3 deletions .ci/template.mac.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
steps:
- bash: npm install -g functional-red-black-tree
- bash: npm -g install [email protected] typescript@$(TS_VERSION) @typescript-eslint/[email protected] @typescript-eslint/[email protected] eslint-config-prettier
- task: NodeTool@0
inputs:
versionSpec: '10.x'
- bash: npm install eslint@$(ESLINT_VERSION) typescript@$(TS_VERSION) @typescript-eslint/eslint-plugin@$(TS_ESLINT_VERSION) @typescript-eslint/parser@$(TS_ESLINT_VERSION) eslint-config-prettier
- template: ./template.unix.yml
- bash: eslint **/*.ts --max-warnings=0
- bash: npx eslint "**/*.ts" --max-warnings=0
- template: ./template.common.yml
6 changes: 3 additions & 3 deletions .ci/template.windows.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
steps:
- bash: npm install eslint@5.16.0 typescript@$(TS_VERSION) @typescript-eslint/eslint-plugin@1.13.0 @typescript-eslint/parser@1.13.0 eslint-config-prettier
- bash: npm install eslint@$(ESLINT_VERSION) typescript@$(TS_VERSION) @typescript-eslint/eslint-plugin@$(TS_ESLINT_VERSION) @typescript-eslint/parser@$(TS_ESLINT_VERSION) eslint-config-prettier
- powershell: iwr https://deno.land/x/install/install.ps1 -out install.ps1; .\install.ps1 $(DENO_VERSION)
- bash: echo "##vso[task.prependpath]C:\Users\VssAdministrator\.deno\\bin"
- bash: npx eslint **/*.ts --max-warnings=0
- bash: npx eslint "**/*.ts" --max-warnings=0
- template: ./template.common.yml
parameters:
exe_suffix: ".exe"
exe_suffix: ".exe"
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/deno.d.ts
/prettier/vendor
**/testdata/

7 changes: 5 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
"project": "./tsconfig.json",
"createDefaultProgram": true
},
"plugins": ["@typescript-eslint"],
"extends": [
Expand All @@ -11,14 +12,16 @@
"prettier/@typescript-eslint"
],
"rules": {
"@typescript-eslint/array-type": ["error", "array-simple"],
"@typescript-eslint/array-type": ["error", { "default": "array-simple" }],
"@typescript-eslint/explicit-member-accessibility": ["off"],
"@typescript-eslint/no-non-null-assertion": ["off"],
"@typescript-eslint/no-parameter-properties": ["off"],
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "_" }
],
"@typescript-eslint/ban-ts-ignore": ["off"],
"@typescript-eslint/no-empty-function": ["off"],
"max-len": [
"error",
{
Expand Down
9 changes: 5 additions & 4 deletions archive/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function clean(length: number): Uint8Array {
}

function pad(num: number, bytes: number, base?: number): string {
var numString = num.toString(base || 8);
const numString = num.toString(base || 8);
return "000000000000".substr(numString.length + 12 - bytes) + numString;
}

Expand Down Expand Up @@ -328,7 +328,7 @@ export class Tar {
// set meta data
const info = opts.filePath && (await Deno.stat(opts.filePath));

let mode =
const mode =
opts.fileMode || (info && info.mode) || parseInt("777", 8) & 0xfff,
mtime =
opts.mtime ||
Expand Down Expand Up @@ -385,8 +385,9 @@ export class Tar {
getReader(): Deno.Reader {
const readers: Deno.Reader[] = [];
this.data.forEach((tarData): void => {
let { filePath, reader } = tarData,
headerArr = formatHeader(tarData);
let { reader } = tarData;
const { filePath } = tarData;
const headerArr = formatHeader(tarData);
readers.push(new Deno.Buffer(headerArr));
if (!reader) {
reader = new FileReader(filePath!);
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
variables:
DENO_VERSION: "v0.19.0"
TS_VERSION: "3.4.5"
ESLINT_VERSION: "6.5.1"
TS_ESLINT_VERSION: "2.3.2"

# TODO Try to get eslint to run under Deno, like prettier
jobs:
Expand Down
1 change: 1 addition & 0 deletions bundle/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { instantiate, load, ModuleMetaData } from "./utils.ts";
/* eslint-disable @typescript-eslint/no-namespace */
declare global {
namespace globalThis {
// eslint-disable-next-line no-var
var __results: [string, string] | undefined;
}
}
Expand Down
1 change: 1 addition & 0 deletions bundle/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Define = (
/* eslint-disable @typescript-eslint/no-namespace */
declare global {
namespace globalThis {
// eslint-disable-next-line no-var
var define: Define | undefined;
}
}
Expand Down
2 changes: 1 addition & 1 deletion datetime/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function currentDayOfYear(): number {
* @return IMF date formated string
*/
export function toIMF(date: Date): string {
function dtPad(v: string, lPad: number = 2): string {
function dtPad(v: string, lPad = 2): string {
return pad(v, lPad, { char: "0" });
}
const d = dtPad(date.getUTCDate().toString());
Expand Down
4 changes: 2 additions & 2 deletions encoding/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function read(
const tp = new TextProtoReader(reader);
let line: string;
let result: string[] = [];
let lineIndex = Startline;
const lineIndex = Startline;

const r = await tp.readLine();
if (r === Deno.EOF) return Deno.EOF;
Expand Down Expand Up @@ -229,7 +229,7 @@ export async function parse(
throw `Error number of fields line:${i}`;
}
i++;
let out: Record<string, unknown> = {};
const out: Record<string, unknown> = {};
for (let j = 0; j < e.length; j++) {
const h = headers[j];
if (h.parse) {
Expand Down
2 changes: 1 addition & 1 deletion encoding/hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function decode(
dst: Uint8Array,
src: Uint8Array
): [number, Error | void] {
var i = 0;
let i = 0;
for (; i < Math.floor(src.length / 2); i++) {
const [a, aOK] = fromHexChar(src[i * 2]);
if (!aOK) {
Expand Down
30 changes: 15 additions & 15 deletions encoding/toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class Parser {
return line.match(/'''/) ? true : false;
}

let merged = [],
acc = [],
const merged = [];
let acc = [],
isLiteral = false,
capture = false,
captureType = "",
Expand Down Expand Up @@ -123,14 +123,14 @@ class Parser {
this.tomlLines = merged;
}
_unflat(keys: string[], values: object = {}, cObj: object = {}): object {
let out: Record<string, unknown> = {};
const out: Record<string, unknown> = {};
if (keys.length === 0) {
return cObj;
} else {
if (Object.keys(cObj).length === 0) {
cObj = values;
}
let key: string | undefined = keys.pop();
const key: string | undefined = keys.pop();
if (key) {
out[key] = cObj;
}
Expand All @@ -152,7 +152,7 @@ class Parser {
delete this.context.currentGroup;
}
_split(str: string): string[] {
let out = [];
const out = [];
out.push(...str.split("\n"));
return out;
}
Expand Down Expand Up @@ -233,8 +233,8 @@ class Parser {
const reg = /([a-zA-Z0-9-_\.]*) (=)/gi;
let result;
while ((result = reg.exec(dataString))) {
let ogVal = result[0];
let newVal = ogVal
const ogVal = result[0];
const newVal = ogVal
.replace(result[1], `"${result[1]}"`)
.replace(result[2], ":");
dataString = dataString.replace(ogVal, newVal);
Expand Down Expand Up @@ -332,9 +332,9 @@ class Parser {
}
}
if (this._isDeclaration(line)) {
let kv = this._processDeclaration(line);
let key = kv.key;
let value = kv.value;
const kv = this._processDeclaration(line);
const key = kv.key;
const value = kv.value;
if (!this.context.currentGroup) {
this.context.output[key] = value;
} else {
Expand All @@ -360,7 +360,7 @@ class Parser {
let k = keys[i];
if (k) {
let v = obj[k];
let pathDeclaration = this._parseDeclarationName(k);
const pathDeclaration = this._parseDeclarationName(k);
delete obj[k];
if (pathDeclaration.length > 1) {
const shift = pathDeclaration.shift();
Expand Down Expand Up @@ -400,7 +400,7 @@ function joinKeys(keys: string[]): string {
}

class Dumper {
maxPad: number = 0;
maxPad = 0;
srcObject: object;
output: string[] = [];
constructor(srcObjc: object) {
Expand Down Expand Up @@ -507,11 +507,11 @@ class Dumper {
}
}
_dateDeclaration(keys: string[], value: Date): string {
function dtPad(v: string, lPad: number = 2): string {
function dtPad(v: string, lPad = 2): string {
return pad(v, lPad, { char: "0" });
}
let m = dtPad((value.getUTCMonth() + 1).toString());
let d = dtPad(value.getUTCDate().toString());
const m = dtPad((value.getUTCMonth() + 1).toString());
const d = dtPad(value.getUTCDate().toString());
const h = dtPad(value.getUTCHours().toString());
const min = dtPad(value.getUTCMinutes().toString());
const s = dtPad(value.getUTCSeconds().toString());
Expand Down
4 changes: 2 additions & 2 deletions examples/cat.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
async function cat(filenames: string[]): Promise<void> {
for (let filename of filenames) {
let file = await Deno.open(filename);
for (const filename of filenames) {
const file = await Deno.open(filename);
await Deno.copy(Deno.stdout, file);
file.close();
}
Expand Down
4 changes: 2 additions & 2 deletions examples/gist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ async function main(): Promise<void> {
});

if (res.ok) {
let resObj = await res.json();
const resObj = await res.json();
console.log("Success");
console.log(resObj["html_url"]);
} else {
let err = await res.text();
const err = await res.text();
console.error("Failure to POST", err);
}
}
Expand Down
2 changes: 1 addition & 1 deletion flags/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export function parse(
argv._.push(flags.strings["_"] || !isNumber(arg) ? arg : Number(arg));
}
if (options.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
argv._.push(...args.slice(i + 1));
break;
}
}
Expand Down
Loading

0 comments on commit 96fe2d1

Please sign in to comment.