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
strict - clean fs/
  • Loading branch information
bartlomieju committed May 25, 2019
commit 68452b1ac4437764017c859150367d4a0d293da4
2 changes: 1 addition & 1 deletion encoding/csv_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ for (const t of testCases) {
if (t.LazyQuotes) {
lazyquote = t.LazyQuotes;
}
const actual = await readAll(new BufReader(new StringReader(t.Input)), {
const actual = await readAll(new BufReader(new StringReader(t.Input || "")), {
comma: comma,
comment: comment,
trimLeadingSpace: trim,
Expand Down
20 changes: 10 additions & 10 deletions flags/unknown_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";

test(function booleanAndAliasIsNotUnknown(): void {
const unknown = [];
function unknownFn(arg): boolean {
const unknown: string[] = [];
function unknownFn(arg: string): boolean {
unknown.push(arg);
return false;
}
Expand All @@ -23,8 +23,8 @@ test(function booleanAndAliasIsNotUnknown(): void {
});

test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown(): void {
const unknown = [];
function unknownFn(arg): boolean {
const unknown: string[] = [];
function unknownFn(arg: string): boolean {
unknown.push(arg);
return false;
}
Expand All @@ -40,8 +40,8 @@ test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown(): void {
});

test(function stringAndAliasIsNotUnkown(): void {
const unknown = [];
function unknownFn(arg): boolean {
const unknown: string[] = [];
function unknownFn(arg: string): boolean {
unknown.push(arg);
return false;
}
Expand All @@ -59,8 +59,8 @@ test(function stringAndAliasIsNotUnkown(): void {
});

test(function defaultAndAliasIsNotUnknown(): void {
const unknown = [];
function unknownFn(arg): boolean {
const unknown: string[] = [];
function unknownFn(arg: string): boolean {
unknown.push(arg);
return false;
}
Expand All @@ -78,8 +78,8 @@ test(function defaultAndAliasIsNotUnknown(): void {
});

test(function valueFollowingDoubleHyphenIsNotUnknown(): void {
const unknown = [];
function unknownFn(arg): boolean {
const unknown: string[] = [];
function unknownFn(arg: string): boolean {
unknown.push(arg);
return false;
}
Expand Down
61 changes: 29 additions & 32 deletions fs/globrex_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@
import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";
import { globrex, GlobrexResult } from "./globrex.ts";
import { GlobOptions } from "./glob.ts";

const isWin = Deno.build.os === "win";
const t = { equal: assertEquals, is: assertEquals };

function match(glob, strUnix, strWin?, opts = {}): boolean {
function match(glob: string, strUnix: string, strWin?: string | object, opts = {}): boolean {
if (typeof strWin === "object") {
opts = strWin;
strWin = false;
strWin = "";
}
let res = globrex(glob, opts);
return res.regex.test(isWin && strWin ? strWin : strUnix);
}

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

function matchSegments(t, pattern, ifUnix, ifWin, opts): 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 str = res.path!.segments.join(" ");
const exp = (isWin ? ifWin : ifUnix).join(" ");
t.is(str, exp);
return res;
Expand Down Expand Up @@ -191,7 +192,7 @@ test({
t.equal(match("f?o", "fooo", { extended: true }), false);
t.equal(match("f?oo", "foo", { extended: true }), false);

const tester = (globstar): void => {
const tester = (globstar: boolean): void => {
t.equal(
match("f?o", "foo", { extended: true, globstar, flags: "g" }),
true
Expand Down Expand Up @@ -235,7 +236,7 @@ test({
t.equal(match("fo[!tz]", "fot", { extended: true }), false);
t.equal(match("fo[!tz]", "fob", { extended: true }), true);

const tester = (globstar): void => {
const tester = (globstar: boolean): void => {
t.equal(
match("fo[oz]", "foo", { extended: true, globstar, flags: "g" }),
true
Expand Down Expand Up @@ -321,7 +322,7 @@ test({
t.equal(match("foo{bar,baaz}", "foobuzz", { extended: true }), false);
t.equal(match("foo{bar,b*z}", "foobuzz", { extended: true }), true);

const tester = (globstar): void => {
const tester = (globstar: boolean): void => {
t.equal(
match("foo{bar,baaz}", "foobaaz", {
extended: true,
Expand Down Expand Up @@ -405,7 +406,7 @@ test({
false
);

const tester = (globstar): void => {
const tester = (globstar: boolean): void => {
t.equal(
match(
"http:https://?o[oz].b*z.com/{*.js,*.html}",
Expand Down Expand Up @@ -456,7 +457,7 @@ test({
test({
name: "globrex: standard globstar",
fn(): void {
const tester = (globstar): void => {
const tester = (globstar: boolean): void => {
t.equal(
match(
"http:https://foo.com/**/{*.js,*.html}",
Expand Down Expand Up @@ -491,7 +492,7 @@ test({
test({
name: "globrex: remaining chars should match themself",
fn(): void {
const tester = (globstar): void => {
const tester = (globstar: boolean): void => {
const testExtStr = "\\/$^+.()=!|,.*";
t.equal(match(testExtStr, testExtStr, { extended: true }), true);
t.equal(
Expand Down Expand Up @@ -801,47 +802,43 @@ test({

res = globrex("", opts);
t.is(res.hasOwnProperty("path"), true);
t.is(res.path.hasOwnProperty("regex"), true);
t.is(res.path.hasOwnProperty("segments"), true);
t.is(Array.isArray(res.path.segments), true);
t.is(res.path!.hasOwnProperty("regex"), true);
t.is(res.path!.hasOwnProperty("segments"), true);
t.is(Array.isArray(res.path!.segments), true);

pattern = "foo/bar/baz.js";
res = matchRegex(
t,
pattern,
"/^foo\\/bar\\/baz\\.js$/",
"/^foo\\\\+bar\\\\+baz\\.js$/",
opts
);
t.is(res.path.segments.length, 3);
t.is(res.path!.segments.length, 3);

res = matchRegex(
t,
"../foo/bar.js",
"/^\\.\\.\\/foo\\/bar\\.js$/",
"/^\\.\\.\\\\+foo\\\\+bar\\.js$/",
opts
);
t.is(res.path.segments.length, 3);
t.is(res.path!.segments.length, 3);

res = matchRegex(
t,
"*/bar.js",
"/^.*\\/bar\\.js$/",
"/^.*\\\\+bar\\.js$/",
opts
);
t.is(res.path.segments.length, 2);
t.is(res.path!.segments.length, 2);

opts.globstar = true;
res = matchRegex(
t,
"**/bar.js",
"/^((?:[^\\/]*(?:\\/|$))*)bar\\.js$/",
"/^((?:[^\\\\]*(?:\\\\|$))*)bar\\.js$/",
opts
);
t.is(res.path.segments.length, 2);
t.is(res.path!.segments.length, 2);
}
});

Expand All @@ -854,42 +851,42 @@ test({

unix = [/^foo$/, /^bar$/, /^([^\/]*)$/, /^baz\.(md|js|txt)$/];
win = [/^foo$/, /^bar$/, /^([^\\]*)$/, /^baz\.(md|js|txt)$/];
matchSegments(t, "foo/bar/*/baz.{md,js,txt}", unix, win, {
matchSegments("foo/bar/*/baz.{md,js,txt}", unix, win, {
...opts,
globstar: true
});

unix = [/^foo$/, /^.*$/, /^baz\.md$/];
win = [/^foo$/, /^.*$/, /^baz\.md$/];
matchSegments(t, "foo/*/baz.md", unix, win, opts);
matchSegments("foo/*/baz.md", unix, win, opts);

unix = [/^foo$/, /^.*$/, /^baz\.md$/];
win = [/^foo$/, /^.*$/, /^baz\.md$/];
matchSegments(t, "foo/**/baz.md", unix, win, opts);
matchSegments("foo/**/baz.md", unix, win, opts);

unix = [/^foo$/, /^((?:[^\/]*(?:\/|$))*)$/, /^baz\.md$/];
win = [/^foo$/, /^((?:[^\\]*(?:\\|$))*)$/, /^baz\.md$/];
matchSegments(t, "foo/**/baz.md", unix, win, { ...opts, globstar: true });
matchSegments("foo/**/baz.md", unix, win, { ...opts, globstar: true });

unix = [/^foo$/, /^.*$/, /^.*\.md$/];
win = [/^foo$/, /^.*$/, /^.*\.md$/];
matchSegments(t, "foo/**/*.md", unix, win, opts);
matchSegments("foo/**/*.md", unix, win, opts);

unix = [/^foo$/, /^((?:[^\/]*(?:\/|$))*)$/, /^([^\/]*)\.md$/];
win = [/^foo$/, /^((?:[^\\]*(?:\\|$))*)$/, /^([^\\]*)\.md$/];
matchSegments(t, "foo/**/*.md", unix, win, { ...opts, globstar: true });
matchSegments("foo/**/*.md", unix, win, { ...opts, globstar: true });

unix = [/^foo$/, /^:$/, /^b:az$/];
win = [/^foo$/, /^:$/, /^b:az$/];
matchSegments(t, "foo/:/b:az", unix, win, opts);
matchSegments("foo/:/b:az", unix, win, opts);

unix = [/^foo$/, /^baz\.md$/];
win = [/^foo$/, /^baz\.md$/];
matchSegments(t, "foo///baz.md", unix, win, { ...opts, strict: true });
matchSegments("foo///baz.md", unix, win, { ...opts, strict: true });

unix = [/^foo$/, /^baz\.md$/];
win = [/^foo$/, /^baz\.md$/];
matchSegments(t, "foo///baz.md", unix, win, { ...opts, strict: false });
matchSegments("foo///baz.md", unix, win, { ...opts, strict: false });
}
});

Expand Down
2 changes: 1 addition & 1 deletion fs/walk_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { test, TestFunction, runIfMain } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";

export async function testWalk(
setup: (string) => void | Promise<void>,
setup: (arg0: string) => void | Promise<void>,
t: TestFunction
): Promise<void> {
const name = t.name;
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 : {[key: string]: number } = {
export const LogLevel : Record<string, number> = {
NOTSET: 0,
DEBUG: 10,
INFO: 20,
Expand Down