Skip to content

Commit bc18bdf

Browse files
authored
fix(dependencies): Upgrading packages to latest
Needed to bump to `jest@24` which used `@babel/core` (instead of `babel-core`). Before I was able to use Yarn resolutions to map `babel-core` to `@babel/core`, but an app using `@benmvp/cli` would have to do the same thing, which is less than ideal. This was found while trying to update [`url-lib`](https://github.com/benmvp/url-lib) to use `@benmvp/cli`. Also needed to bump to latest of `@typescript-eslint/*` so that it will work w/ the latest version of `typescript` we're using and stop giving the warning in `typescript-estree`. However, bumping some packages, meant bumping others, so in the end, I just updated everything I could to the latest. The biggest update was switching from `eslint-pluging-typescript` (abandoned) to `@typescript-eslint/eslint-plugin`. This came w/ a set of recommended rules as well. BREAKING CHANGE: Typescript eslint rules have been updated to catch more issues. Most new lint rules are fixable, but likely there will be code that was "fine" before that will need to be manually fixed.
1 parent c7ae24c commit bc18bdf

File tree

14 files changed

+1487
-1720
lines changed

14 files changed

+1487
-1720
lines changed

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,32 @@
3232
"engines": {
3333
"node": ">= 8"
3434
},
35-
"resolutions": {
36-
"babel-core": "^7.0.0-bridge.0"
37-
},
3835
"dependencies": {
3936
"@babel/cli": "^7.2.0",
4037
"@babel/core": "^7.2.0",
41-
"@types/jest": "^24.0.11",
4238
"@babel/plugin-external-helpers": "^7.2.0",
4339
"@babel/plugin-proposal-class-properties": "^7.2.0",
4440
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
4541
"@babel/preset-env": "^7.2.0",
4642
"@babel/preset-typescript": "^7.1.0",
43+
"@types/jest": "^24.0.11",
44+
"@typescript-eslint/eslint-plugin": "^1.8.0",
45+
"@typescript-eslint/parser": "^1.7.0",
4746
"babel-eslint": "^8.2.3",
48-
"babel-jest": "^23.6.0",
47+
"babel-jest": "^24.8.0",
48+
"core-js": "^3.0.1",
4949
"eslint": "^5.14.0",
5050
"eslint-config-eventbrite": "^5.0.0",
5151
"eslint-plugin-babel": "^5.1.0",
5252
"eslint-plugin-import": "^2.17.2",
5353
"eslint-plugin-jest": "^22.4.1",
54-
"eslint-plugin-typescript": "^0.14.0",
55-
"jest": "^23.6.0",
56-
"jest-runner-eslint": "^0.7.1",
54+
"jest": "^24.8.0",
55+
"jest-runner-eslint": "^0.7.3",
5756
"jest-runner-tsc": "^1.3.2",
5857
"jest-watch-typeahead": "^0.3.0",
5958
"lodash": "^4.17.11",
59+
"regenerator-runtime": "^0.13.2",
6060
"typescript": "^3.2.1",
61-
"typescript-eslint-parser": "^21.0.2",
6261
"yargs": "^13.1.0"
6362
},
6463
"devDependencies": {

src/cli/args.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,30 @@ import {resolve} from 'path'
22
import yargs from 'yargs'
33
import {ModuleFormat, TestMode, Command} from '../commands/types'
44

5+
interface CommandOptions {
6+
[key: string]: yargs.Options;
7+
}
8+
9+
interface YargsArgv {
10+
[x: string]: unknown;
11+
_: string[];
12+
$0: string;
13+
}
14+
515
const TEST_MODES = {
616
modes: {
717
describe: 'The types/modes of tests to run',
818
alias: 'm',
919
array: true,
10-
default: ['lint', 'type', 'unit'] as Array<TestMode>,
20+
default: ['lint', 'type', 'unit'] as TestMode[],
1121
},
1222
}
1323
const BUILD_FORMATS = {
1424
formats: {
1525
describe: 'The module formats to build',
1626
alias: 'f',
1727
array: true,
18-
default: ['type', 'esm', 'cjs'] as Array<ModuleFormat>,
28+
default: ['type', 'esm', 'cjs'] as ModuleFormat[],
1929
},
2030
}
2131
const OUTPUT_PATH = {
@@ -35,19 +45,19 @@ export const CREATE_POS_ARGS = {
3545
string: true,
3646
},
3747
}
38-
export const TEST_ARGS = {
48+
export const TEST_ARGS: CommandOptions = {
3949
...TEST_MODES,
4050
watch: {
4151
describe: 'Re-run tests when source files change',
4252
alias: 'w',
4353
type: 'boolean',
4454
default: false,
4555
},
46-
} as {[key: string]: yargs.Options}
47-
export const START_ARGS = {
56+
}
57+
export const START_ARGS: CommandOptions = {
4858
...TEST_MODES,
49-
} as {[key: string]: yargs.Options}
50-
export const BUILD_ARGS = {
59+
}
60+
export const BUILD_ARGS: CommandOptions = {
5161
...BUILD_FORMATS,
5262
...OUTPUT_PATH,
5363
watch: {
@@ -56,7 +66,7 @@ export const BUILD_ARGS = {
5666
type: 'boolean',
5767
default: false,
5868
},
59-
} as {[key: string]: yargs.Options}
69+
}
6070

6171
export const CREATE_COMMAND = 'create' as Command
6272
export const TEST_COMMAND = 'test' as Command
@@ -65,20 +75,20 @@ export const BUILD_COMMAND = 'build' as Command
6575

6676
export const DEFAULT_COMMAND = CREATE_COMMAND
6777

68-
export const parseArgs = (args: Array<string>) =>
78+
export const parseArgs = (args: string[]): YargsArgv =>
6979
yargs(args)
7080
.version()
71-
.command<{[key: string]: yargs.Options}>(
81+
.command<CommandOptions>(
7282
TEST_COMMAND,
7383
'Runs linting, typing & unit tests for the library',
7484
TEST_ARGS,
7585
)
76-
.command<{[key: string]: yargs.Options}>(
86+
.command<CommandOptions>(
7787
START_COMMAND,
7888
'Runs the lib\'s tests in watch mode',
7989
START_ARGS,
8090
)
81-
.command<{[key: string]: yargs.Options}>(
91+
.command<CommandOptions>(
8292
BUILD_COMMAND,
8393
'Builds the library into desired module formats',
8494
BUILD_ARGS,

src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {Command, Result} from '../commands/types'
1616
* @param {Array<string>} [args] An array of CLI arguments similar to the arguments received by `process.argv` (after the first two elements)
1717
* @returns Promise<Result> The result of the executing the command
1818
*/
19-
export const run = (args: Array<string> = []): Promise<Result> => {
19+
export const run = (args: string[] = []): Promise<Result> => {
2020
const parsedArgs = parseArgs(args)
2121
const [firstCommand = DEFAULT_COMMAND] = parsedArgs._
2222
const command = firstCommand as Command

src/commands/build/__tests__/utils.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('getBabelArgs', () => {
2020

2121
it('generates CJS + ESM w/ default output directory', () => {
2222
const [cjsArgs, esmArgs] = getBabelArgs({
23-
formats: new Set(['cjs', 'esm'] as Array<ModuleFormat>),
23+
formats: new Set(['cjs', 'esm'] as ModuleFormat[]),
2424
out: BUILD_ARGS.out.default,
2525
watch: BUILD_ARGS.watch.default,
2626
})
@@ -34,7 +34,7 @@ describe('getBabelArgs', () => {
3434

3535
it('still only generates CJS + ESM when more formats are specified', () => {
3636
const [cjsArgs, esmArgs, ...otherArgs] = getBabelArgs({
37-
formats: new Set(['cjs', 'esm', 'type'] as Array<ModuleFormat>),
37+
formats: new Set(['cjs', 'esm', 'type'] as ModuleFormat[]),
3838
out: BUILD_ARGS.out.default,
3939
watch: BUILD_ARGS.watch.default,
4040
})
@@ -51,7 +51,7 @@ describe('getBabelArgs', () => {
5151
it('sets correct outDir when `out` is relative', () => {
5252
const out = './built'
5353
const [esmArgs] = getBabelArgs({
54-
formats: new Set(['esm'] as Array<ModuleFormat>),
54+
formats: new Set(['esm'] as ModuleFormat[]),
5555
out,
5656
watch: BUILD_ARGS.watch.default,
5757
})
@@ -62,7 +62,7 @@ describe('getBabelArgs', () => {
6262
it('sets correct outDir when `out` is absolute', () => {
6363
const out = '/path/to/built'
6464
const [cjsArgs] = getBabelArgs({
65-
formats: new Set(['cjs'] as Array<ModuleFormat>),
65+
formats: new Set(['cjs'] as ModuleFormat[]),
6666
out,
6767
watch: BUILD_ARGS.watch.default,
6868
})
@@ -112,7 +112,7 @@ describe('getTypescriptArgs', () => {
112112

113113
it('returns null if `formats` does not contain "type"', () => {
114114
const typescriptArgs = getTypescriptArgs({
115-
formats: new Set(['esm'] as Array<ModuleFormat>),
115+
formats: new Set(['esm'] as ModuleFormat[]),
116116
out: BUILD_ARGS.out.default,
117117
watch: BUILD_ARGS.watch.default,
118118
})
@@ -124,7 +124,7 @@ describe('getTypescriptArgs', () => {
124124
describe('type format requested', () => {
125125
it('includes all of the args from base config', () => {
126126
const typescriptArgs = getTypescriptArgs({
127-
formats: new Set(['esm', 'type'] as Array<ModuleFormat>),
127+
formats: new Set(['esm', 'type'] as ModuleFormat[]),
128128
out: BUILD_ARGS.out.default,
129129
watch: BUILD_ARGS.watch.default,
130130
})
@@ -136,7 +136,7 @@ describe('getTypescriptArgs', () => {
136136

137137
it('specifies generic declaration information', () => {
138138
const typescriptArgs = getTypescriptArgs({
139-
formats: new Set(['esm', 'type'] as Array<ModuleFormat>),
139+
formats: new Set(['esm', 'type'] as ModuleFormat[]),
140140
out: BUILD_ARGS.out.default,
141141
watch: BUILD_ARGS.watch.default,
142142
})
@@ -149,7 +149,7 @@ describe('getTypescriptArgs', () => {
149149
it('specifies the declaration destination when `out` is relative', () => {
150150
const out = './built'
151151
const typescriptArgs = getTypescriptArgs({
152-
formats: new Set(['type'] as Array<ModuleFormat>),
152+
formats: new Set(['type'] as ModuleFormat[]),
153153
out,
154154
watch: BUILD_ARGS.watch.default,
155155
})
@@ -162,7 +162,7 @@ describe('getTypescriptArgs', () => {
162162

163163
it('specifies the declaration destination when `out` is absolute', () => {
164164
const typescriptArgs = getTypescriptArgs({
165-
formats: new Set(['type'] as Array<ModuleFormat>),
165+
formats: new Set(['type'] as ModuleFormat[]),
166166
out: '/out/dir',
167167
watch: BUILD_ARGS.watch.default,
168168
})
@@ -176,7 +176,7 @@ describe('getTypescriptArgs', () => {
176176
describe('watch option', () => {
177177
it('includes --watch when `watch` is true', () => {
178178
const typescriptArgs = getTypescriptArgs({
179-
formats: new Set(['type'] as Array<ModuleFormat>),
179+
formats: new Set(['type'] as ModuleFormat[]),
180180
out: BUILD_ARGS.out.default,
181181
watch: true,
182182
})
@@ -186,7 +186,7 @@ describe('getTypescriptArgs', () => {
186186

187187
it('does not include --watch when `watch` is false', () => {
188188
const typescriptArgs = getTypescriptArgs({
189-
formats: new Set(['type'] as Array<ModuleFormat>),
189+
formats: new Set(['type'] as ModuleFormat[]),
190190
out: BUILD_ARGS.out.default,
191191
watch: false,
192192
})
@@ -197,7 +197,7 @@ describe('getTypescriptArgs', () => {
197197

198198
it('uses current working director for source files location', () => {
199199
const typescriptArgs = getTypescriptArgs({
200-
formats: new Set(['type'] as Array<ModuleFormat>),
200+
formats: new Set(['type'] as ModuleFormat[]),
201201
out: BUILD_ARGS.out.default,
202202
watch: BUILD_ARGS.watch.default,
203203
})

src/commands/build/babel-config-utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const getBabelConfig = (moduleType) => ({
1010
targets: 'last 2 versions',
1111
modules: moduleType === 'esm' ? false : moduleType,
1212
useBuiltIns: 'usage',
13+
corejs: {
14+
version: 3,
15+
}
1316
},
1417
],
1518
'@babel/preset-typescript',

0 commit comments

Comments
 (0)