Skip to content

Commit 67f9f6b

Browse files
committed
Add CI tests for unused code
This commit tests in CI for unused functions and exports using ts-prune. There are two exported functions in ecmascript.ts that are only used by tests. Because our tests haven't been ported over to TS yet, that usage is invisible to ts-prune, so I marked both functions with a comment to disable ts-prune errors until we migrate the test code to TS and we can remove the `// ts-prune-ignore-next` comments
1 parent 047d413 commit 67f9f6b

File tree

6 files changed

+327
-10
lines changed

6 files changed

+327
-10
lines changed

.eslintrc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ rules:
3636
curly:
3737
- error
3838
- multi-line
39-
func-call-spacing: error
39+
func-call-spacing: off
40+
'@typescript-eslint/func-call-spacing': error
4041
function-call-argument-newline:
4142
- error
4243
- consistent

.github/workflows/lint.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ jobs:
1111
node-version: 15.x
1212
- run: npm ci --no-optional
1313
- run: npm run lint
14+
lint-unused-code: # look for unused functions and unused exports
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: use node.js v16.x
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: 16.x
22+
- run: npm ci --no-optional
23+
- run: npm run prune

.github/workflows/test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ jobs:
2828
test-test262:
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v2
32-
- name: use node.js v16.x
33-
uses: actions/setup-node@v1
34-
with:
35-
node-version: 16.x
36-
- run: npm ci
37-
- run: npm run test262
38-
env:
39-
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
31+
- uses: actions/checkout@v2
32+
- name: use node.js v16.x
33+
uses: actions/setup-node@v1
34+
with:
35+
node-version: 16.x
36+
- run: npm ci
37+
- run: npm run test262
38+
env:
39+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}

lib/ecmascript.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,7 @@ function GetISOPartsFromEpoch(epochNanoseconds) {
23222322
return { epochMilliseconds, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond };
23232323
}
23242324

2325+
// ts-prune-ignore-next TODO: remove this after tests are converted to TS
23252326
export function GetIANATimeZoneDateTimeParts(epochNanoseconds, id) {
23262327
const { epochMilliseconds, millisecond, microsecond, nanosecond } = GetISOPartsFromEpoch(epochNanoseconds);
23272328
const { year, month, day, hour, minute, second } = GetFormatterParts(id, epochMilliseconds);
@@ -2376,6 +2377,7 @@ export function GetIANATimeZonePreviousTransition(epochNanoseconds, id) {
23762377
return result;
23772378
}
23782379

2380+
// ts-prune-ignore-next TODO: remove this after tests are converted to TS
23792381
export function GetFormatterParts(timeZone, epochMilliseconds) {
23802382
const formatter = getIntlDateTimeFormatEnUsForTimeZone(timeZone);
23812383
// FIXME: can this use formatToParts instead?

0 commit comments

Comments
 (0)