Skip to content
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

chore: Implement strict mode #453

Merged
merged 29 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6e30522
add TS strict mode to CI
bartlomieju May 25, 2019
9b96923
strict - clean log/
bartlomieju May 25, 2019
742c19e
strict - clean ws/ and testing/
bartlomieju May 25, 2019
d40b031
strict - clean archive/
bartlomieju May 25, 2019
68452b1
strict - clean fs/
bartlomieju May 25, 2019
c4948a5
strict - clean http/
bartlomieju May 25, 2019
1c2c688
strict - clean log/, mime/, prettier/, textproto/
bartlomieju May 25, 2019
2b2ec3a
strict - clean ws/, io/, fs/
bartlomieju May 25, 2019
fa00df0
fix CSV
zekth May 25, 2019
589cfb4
fixing toml
zekth May 25, 2019
681a87c
Merge pull request #1 from zekth/fix_toml_strict
bartlomieju May 25, 2019
ce6b612
more strict fixes
bartlomieju May 26, 2019
c072d6f
rewrite flags module in strict mode
bartlomieju May 26, 2019
3284359
Merge branch 'chore-refactor_flags_strict_mode' into chore-strict_tsc…
bartlomieju May 26, 2019
a8c8aa8
fs module strict
zekth May 26, 2019
d294937
Merge pull request #2 from zekth/strict_contrib
bartlomieju May 26, 2019
6f733a1
strict fix
zekth May 26, 2019
295e6bd
Merge pull request #3 from zekth/strict_another
bartlomieju May 26, 2019
898718f
last part of cleanup
bartlomieju May 26, 2019
e9364c2
fmt
bartlomieju May 26, 2019
eb7a354
Merge branch 'master' into chore-strict_tsconfig
bartlomieju May 26, 2019
2644bf1
lint
bartlomieju May 26, 2019
0429cb1
more fixes for strict mode
bartlomieju May 26, 2019
79cd16a
fix testing/format.ts
bartlomieju May 26, 2019
eef15e6
fix textproto
bartlomieju May 26, 2019
158ae3b
rename deno.tsconfig.json to tsconfig.test.json
bartlomieju May 26, 2019
77a7a90
Merge branch 'master' into chore-strict_tsconfig
bartlomieju May 30, 2019
f8ebcd6
fmt
bartlomieju May 30, 2019
1e36fdb
strict fixes after master merge
bartlomieju May 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
fmt
  • Loading branch information
bartlomieju committed May 26, 2019
commit e9364c2e462f5ed79e014a638280cbc6f924c7e8
17 changes: 10 additions & 7 deletions encoding/csv_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,16 @@ for (const t of testCases) {
if (t.LazyQuotes) {
lazyquote = t.LazyQuotes;
}
const actual = await readAll(new BufReader(new StringReader(t.Input || "")), {
comma: comma,
comment: comment,
trimLeadingSpace: trim,
fieldsPerRecord: fieldsPerRec,
lazyQuotes: lazyquote
});
const actual = await readAll(
new BufReader(new StringReader(t.Input || "")),
{
comma: comma,
comment: comment,
trimLeadingSpace: trim,
fieldsPerRecord: fieldsPerRec,
lazyQuotes: lazyquote
}
);
if (t.Error) {
assert(!!actual[1]);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
21 changes: 18 additions & 3 deletions fs/globrex_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { GlobOptions } from "./glob.ts";
const isWin = Deno.build.os === "win";
const t = { equal: assertEquals, is: assertEquals };

function match(glob: string, strUnix: string, strWin?: string | object, opts = {}): boolean {
function match(
glob: string,
strUnix: string,
strWin?: string | object,
opts = {}
): boolean {
if (typeof strWin === "object") {
opts = strWin;
strWin = "";
Expand All @@ -19,14 +24,24 @@ function match(glob: string, strUnix: string, strWin?: string | object, opts = {
return res.regex.test(isWin && strWin ? strWin : strUnix);
}

function matchRegex(pattern: string, ifUnix: string, ifWin: string, opts: GlobOptions): GlobrexResult {
function matchRegex(
pattern: string,
ifUnix: string,
ifWin: string,
opts: GlobOptions
): GlobrexResult {
const res = globrex(pattern, opts);
const { regex } = opts.filepath ? res.path! : res;
t.is(regex.toString(), isWin ? ifWin : ifUnix, "~> regex matches expectant");
return res;
}

function matchSegments(pattern: string, ifUnix: RegExp[], ifWin: RegExp[], opts: GlobOptions): GlobrexResult {
function matchSegments(
pattern: string,
ifUnix: RegExp[],
ifWin: RegExp[],
opts: GlobOptions
): GlobrexResult {
const res = globrex(pattern, { filepath: true, ...opts });
const str = res.path!.segments.join(" ");
const exp = (isWin ? ifWin : ifUnix).join(" ");
Expand Down
2 changes: 1 addition & 1 deletion log/levels.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
export const LogLevel : Record<string, number> = {
export const LogLevel: Record<string, number> = {
NOTSET: 0,
DEBUG: 10,
INFO: 20,
Expand Down
2 changes: 1 addition & 1 deletion log/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TestHandler extends log.handlers.BaseHandler {

test(async function defaultHandlers(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const loggers: {[key: string]: (msg: string, ...args: any[]) => void} = {
const loggers: { [key: string]: (msg: string, ...args: any[]) => void } = {
DEBUG: log.debug,
INFO: log.info,
WARNING: log.warning,
Expand Down
2 changes: 1 addition & 1 deletion mime/multipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class PartReader implements Reader, Closer {
private getContentDispositionParams(): { [key: string]: string } {
if (this.contentDispositionParams) return this.contentDispositionParams;
const cd = this.headers.get("content-disposition");
const params: {[key: string]: string} = {};
const params: { [key: string]: string } = {};
const comps = cd!.split(";");
this.contentDisposition = comps[0];
comps
Expand Down
12 changes: 9 additions & 3 deletions ws/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,25 @@ export interface WebSocketCloseEvent {
reason?: string;
}

export function isWebSocketCloseEvent(a: WebSocketEvent): a is WebSocketCloseEvent {
export function isWebSocketCloseEvent(
a: WebSocketEvent
): a is WebSocketCloseEvent {
return typeof a === "object" && a.hasOwnProperty("code");
}

export type WebSocketPingEvent = ["ping", Uint8Array];

export function isWebSocketPingEvent(a: WebSocketEvent): a is WebSocketPingEvent {
export function isWebSocketPingEvent(
a: WebSocketEvent
): a is WebSocketPingEvent {
return Array.isArray(a) && a[0] === "ping" && a[1] instanceof Uint8Array;
}

export type WebSocketPongEvent = ["pong", Uint8Array];

export function isWebSocketPongEvent(a: WebSocketEvent): a is WebSocketPongEvent {
export function isWebSocketPongEvent(
a: WebSocketEvent
): a is WebSocketPongEvent {
return Array.isArray(a) && a[0] === "pong" && a[1] instanceof Uint8Array;
}

Expand Down
5 changes: 3 additions & 2 deletions ws/sha1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class Sha1 {

if (notString) {
for (i = start; index < length && i < 64; ++index) {
blocks[i >> 2] |= message[index] as number << SHIFT[i++ & 3];
blocks[i >> 2] |= (message[index] as number) << SHIFT[i++ & 3];
}
} else {
for (i = start; index < length && i < 64; ++index) {
Expand All @@ -94,7 +94,8 @@ export class Sha1 {
} else {
code =
0x10000 +
(((code & 0x3ff) << 10) | ((message as string).charCodeAt(++index) & 0x3ff));
(((code & 0x3ff) << 10) |
((message as string).charCodeAt(++index) & 0x3ff));
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
Expand Down