Skip to content

Commit 05bc959

Browse files
committed
chore: various internal updates
1 parent 2134cfa commit 05bc959

File tree

9 files changed

+62
-54
lines changed

9 files changed

+62
-54
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: CI
22
on: push
33
jobs:
44
test-library:
5-
name: Deno test
6-
runs-on: ubuntu-latest
5+
name: Deno test
6+
runs-on: ubuntu-latest
77

8-
steps:
9-
- uses: actions/checkout@v2
10-
- uses: denolib/setup-deno@v2
11-
with:
12-
deno-version: v1.7
13-
- name: Run tests
14-
run: deno test
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: denoland/setup-deno@v1
11+
with:
12+
deno-version: v1.x
13+
- name: Run tests
14+
run: deno test

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"deno.enable": true
2+
"deno.enable": true,
3+
"deno.lint": true
34
}

build_npm.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deno run -A --unstable scripts/build_npm.ts
1+
deno run --allow-read=./ --allow-write=./npm --unstable scripts/build_npm.ts

comment_char.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @internal */
22
export enum CommentChar {
3-
Line,
4-
Star,
3+
Line,
4+
Star,
55
}

mod.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function runTestsForNewLineChar(opts: { newLine: "\r\n" | "\n" }) {
6060
const expected = "";
6161

6262
doTest(expected, writer => {
63-
writer.write(null as any as string);
63+
writer.write(null as unknown as string);
6464
});
6565
});
6666

@@ -736,6 +736,7 @@ test`;
736736
});
737737

738738
it("should not evaluate the given function when the condition is false", () => {
739+
// deno-lint-ignore no-explicit-any
739740
const test: any = null;
740741
doTest("", writer => {
741742
writer.conditionalWrite(false, () => test.test);
@@ -775,6 +776,7 @@ test`;
775776
});
776777

777778
it("should not evaluate the given function when the condition is false", () => {
779+
// deno-lint-ignore no-explicit-any
778780
const test: any = null;
779781
doTest("", writer => {
780782
writer.conditionalWriteLine(false, () => test.test);
@@ -899,6 +901,7 @@ describe("#setIndentationLevel", () => {
899901

900902
it("should throw when not providing a number or string", () => {
901903
const writer = new CodeBlockWriter();
904+
// deno-lint-ignore no-explicit-any
902905
expect(() => writer.setIndentationLevel({} as any)).to.throw();
903906
});
904907

@@ -1047,6 +1050,7 @@ describe("#queueIndentationLevel", () => {
10471050

10481051
it("should throw when not providing a number or string", () => {
10491052
const writer = new CodeBlockWriter();
1053+
// deno-lint-ignore no-explicit-any
10501054
expect(() => writer.queueIndentationLevel({} as any)).to.throw();
10511055
});
10521056

mod.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,10 @@ export default class CodeBlockWriter {
475475
}
476476
this.write("*/");
477477
break;
478-
default:
478+
default: {
479479
const _assertUndefined: undefined = commentChar;
480480
break;
481+
}
481482
}
482483

483484
return this;

readme.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,24 @@
77

88
Code writer that assists with formatting and visualizing blocks of JavaScript or TypeScript code.
99

10-
```
11-
npm install --save code-block-writer
10+
With Deno/Browser:
11+
12+
```ts
13+
import CodeBlockWriter from "https://deno.land/x/code_block_writer/mod.ts";
1214
```
1315

14-
Or with Deno:
16+
Or with Node:
1517

16-
```ts
17-
import CodeBlockWriter from "https://deno.land/x/[email protected]/mod.ts";
18+
```
19+
npm install --save code-block-writer
1820
```
1921

2022
## Example
2123

2224
<!-- dprint-ignore -->
2325

2426
```typescript
25-
import CodeBlockWriter from "https://deno.land/x/code_block_writer@x.x.x/mod.ts";
27+
import CodeBlockWriter from "https://deno.land/x/code_block_writer/mod.ts";
2628

2729
const writer = new CodeBlockWriter({
2830
// optional options

test_helpers/mocha.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function it(desc: string, action: () => void) {
1717
}
1818

1919
function logDesc(desc: string) {
20-
console.log(desc.split("\n").map(l => " ".repeat(indent) + desc).join("\n"));
20+
console.log(desc.split("\n").map(l => " ".repeat(indent) + l).join("\n"));
2121
}
2222

2323
export function expect<T>(value: T) {
@@ -33,9 +33,9 @@ export function expect<T>(value: T) {
3333
throw new Error(`FAIL. ${JSON.stringify(value)} did not equal ${JSON.stringify(otherValue)}`);
3434
}
3535
},
36-
throw(message?: string) {
37-
const func = value as any as () => void;
38-
let caughtErr: any;
36+
throw(_message?: string) {
37+
const func = value as unknown as () => void;
38+
let caughtErr: unknown;
3939
try {
4040
func();
4141
} catch (err) {
@@ -46,8 +46,8 @@ export function expect<T>(value: T) {
4646
}
4747
},
4848
notThrow() {
49-
const func = value as any as () => void;
50-
let caughtErr: any;
49+
const func = value as unknown as () => void;
50+
let caughtErr: unknown;
5151
try {
5252
func();
5353
} catch (err) {

utils/string_utils.test.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@ import { describe, expect, it } from "../test_helpers/mocha.ts";
22
import { escapeChar, escapeForWithinString, getStringFromStrOrFunc } from "./string_utils.ts";
33

44
describe("escapeForWithinString", () => {
5-
function doTest(input: string, expected: string) {
6-
expect(escapeForWithinString(input, "\"")).to.equal(expected);
7-
}
5+
function doTest(input: string, expected: string) {
6+
expect(escapeForWithinString(input, "\"")).to.equal(expected);
7+
}
88

9-
it("should escape the quotes and newline", () => {
10-
doTest(`"testing\n this out"`, `\\"testing\\\n this out\\"`);
11-
});
9+
it("should escape the quotes and newline", () => {
10+
doTest(`"testing\n this out"`, `\\"testing\\\n this out\\"`);
11+
});
1212
});
1313

1414
describe("escapeChar", () => {
15-
function doTest(input: string, char: string, expected: string) {
16-
expect(escapeChar(input, char)).to.equal(expected);
17-
}
15+
function doTest(input: string, char: string, expected: string) {
16+
expect(escapeChar(input, char)).to.equal(expected);
17+
}
1818

19-
it("should throw when specifying a char length > 1", () => {
20-
expect(() => escapeChar("", "ab")).to.throw();
21-
});
19+
it("should throw when specifying a char length > 1", () => {
20+
expect(() => escapeChar("", "ab")).to.throw();
21+
});
2222

23-
it("should throw when specifying a char length < 1", () => {
24-
expect(() => escapeChar("", "")).to.throw();
25-
});
23+
it("should throw when specifying a char length < 1", () => {
24+
expect(() => escapeChar("", "")).to.throw();
25+
});
2626

27-
it("should escape the single quotes when specified", () => {
28-
doTest(`'testing "this" out'`, `'`, `\\'testing "this" out\\'`);
29-
});
27+
it("should escape the single quotes when specified", () => {
28+
doTest(`'testing "this" out'`, `'`, `\\'testing "this" out\\'`);
29+
});
3030

31-
it("should escape regardless of if the character is already escaped", () => {
32-
doTest(`"testing \\"this\\" out"`, `"`, `\\"testing \\\\"this\\\\" out\\"`);
33-
});
31+
it("should escape regardless of if the character is already escaped", () => {
32+
doTest(`"testing \\"this\\" out"`, `"`, `\\"testing \\\\"this\\\\" out\\"`);
33+
});
3434
});
3535

3636
describe("getStringFromStrOrFunc", () => {
37-
it("should return a string when given a string", () => {
38-
expect(getStringFromStrOrFunc("test")).to.equal("test");
39-
});
37+
it("should return a string when given a string", () => {
38+
expect(getStringFromStrOrFunc("test")).to.equal("test");
39+
});
4040

41-
it("should return a string when given a function", () => {
42-
expect(getStringFromStrOrFunc(() => "test")).to.equal("test");
43-
});
41+
it("should return a string when given a function", () => {
42+
expect(getStringFromStrOrFunc(() => "test")).to.equal("test");
43+
});
4444
});

0 commit comments

Comments
 (0)