Skip to content

Commit 2549f79

Browse files
armano2byCedric
authored andcommitted
refactor: upgrade babel from 6 to 7 (#886)
* feat: upgrade babel from 6 to 7 corejs@2 is deprecated * fix: add promise.finally * fix: rollback mistaken execa upgrade * chore: update rule names (import) * test: remove unnecessary arrow function * chore: remove unnecessary `/index` * chore: remove some leftovers from merge conflict * test: drop unnecessary notThrowsAsync * Revert "test: drop unnecessary notThrowsAsync" This reverts commit eba4002. * fix: drop some trash files after merge
1 parent b39e1ad commit 2549f79

File tree

28 files changed

+3442
-4615
lines changed

28 files changed

+3442
-4615
lines changed

@commitlint/cli/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@
5353
},
5454
"license": "MIT",
5555
"devDependencies": {
56+
"@babel/cli": "^7.7.7",
57+
"@babel/core": "^7.7.7",
58+
"@babel/register": "^7.7.7",
5659
"@commitlint/test": "8.2.0",
5760
"@commitlint/utils": "^8.3.4",
58-
"ava": "0.18.2",
59-
"babel-cli": "6.26.0",
61+
"ava": "2.4.0",
6062
"babel-preset-commitlint": "^8.2.0",
61-
"babel-register": "6.26.0",
6263
"concurrently": "3.6.1",
6364
"cross-env": "6.0.3",
6465
"execa": "0.11.0",
@@ -74,8 +75,8 @@
7475
"@commitlint/lint": "^8.3.5",
7576
"@commitlint/load": "^8.3.5",
7677
"@commitlint/read": "^8.3.4",
77-
"babel-polyfill": "6.26.0",
7878
"chalk": "2.4.2",
79+
"core-js": "^3.6.1",
7980
"get-stdin": "7.0.0",
8081
"lodash": "4.17.15",
8182
"meow": "5.0.0",

@commitlint/cli/src/cli.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#!/usr/bin/env node
2-
require('babel-polyfill'); // eslint-disable-line import/no-unassigned-import
3-
4-
const load = require('@commitlint/load');
5-
const lint = require('@commitlint/lint');
6-
const read = require('@commitlint/read');
7-
const meow = require('meow');
8-
const {merge, pick, isFunction} = require('lodash');
9-
const stdin = require('get-stdin');
10-
const resolveFrom = require('resolve-from');
11-
const resolveGlobal = require('resolve-global');
12-
2+
import 'core-js/stable'; // eslint-disable-line import/no-unassigned-import
3+
import 'regenerator-runtime/runtime'; // eslint-disable-line import/no-unassigned-import
4+
5+
import load from '@commitlint/load';
6+
import lint from '@commitlint/lint';
7+
import read from '@commitlint/read';
8+
import meow from 'meow';
9+
import {merge, pick, isFunction} from 'lodash';
10+
import stdin from 'get-stdin';
11+
import resolveFrom from 'resolve-from';
12+
import resolveGlobal from 'resolve-global';
13+
14+
import help from './help';
1315
const pkg = require('../package');
14-
const help = require('./help');
1516

1617
const flags = {
1718
color: {

@commitlint/cli/src/cli.test.js

+94-71
Original file line numberDiff line numberDiff line change
@@ -135,65 +135,86 @@ test('should produce no error output with -q flag', async t => {
135135
t.is(actual.code, 1);
136136
});
137137

138-
test('should work with husky commitmsg hook and git commit', async () => {
139-
const cwd = await git.bootstrap('fixtures/husky/integration');
140-
await writePkg({scripts: {commitmsg: `'${bin}' -e`}}, {cwd});
141-
142-
await execa('npm', ['install'], {cwd});
143-
await execa('git', ['add', 'package.json'], {cwd});
144-
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
145-
});
146-
147-
test('should work with husky commitmsg hook in sub packages', async () => {
148-
const upper = await git.bootstrap('fixtures/husky');
149-
const cwd = path.join(upper, 'integration');
150-
await writePkg({scripts: {commitmsg: `'${bin}' -e`}}, {cwd: upper});
151-
152-
await execa('npm', ['install'], {cwd});
153-
await execa('git', ['add', 'package.json'], {cwd});
154-
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
155-
});
156-
157-
test('should work with husky via commitlint -e $GIT_PARAMS', async () => {
158-
const cwd = await git.bootstrap('fixtures/husky/integration');
159-
await writePkg({scripts: {commitmsg: `'${bin}' -e $GIT_PARAMS`}}, {cwd});
160-
161-
await execa('npm', ['install'], {cwd});
162-
await execa('git', ['add', 'package.json'], {cwd});
163-
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
164-
});
165-
166-
test('should work with husky via commitlint -e %GIT_PARAMS%', async () => {
167-
const cwd = await git.bootstrap('fixtures/husky/integration');
168-
await writePkg({scripts: {commitmsg: `'${bin}' -e %GIT_PARAMS%`}}, {cwd});
169-
170-
await execa('npm', ['install'], {cwd});
171-
await execa('git', ['add', 'package.json'], {cwd});
172-
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
173-
});
174-
175-
test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async () => {
176-
const cwd = await git.bootstrap('fixtures/husky/integration');
177-
await writePkg(
178-
{scripts: {commitmsg: `'${bin}' -e $HUSKY_GIT_PARAMS`}},
179-
{cwd}
180-
);
181-
182-
await execa('npm', ['install'], {cwd});
183-
await execa('git', ['add', 'package.json'], {cwd});
184-
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
185-
});
186-
187-
test('should work with husky via commitlint -e %HUSKY_GIT_PARAMS%', async () => {
188-
const cwd = await git.bootstrap('fixtures/husky/integration');
189-
await writePkg(
190-
{scripts: {commitmsg: `'${bin}' -e %HUSKY_GIT_PARAMS%`}},
191-
{cwd}
192-
);
193-
194-
await execa('npm', ['install'], {cwd});
195-
await execa('git', ['add', 'package.json'], {cwd});
196-
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
138+
test('should work with husky commitmsg hook and git commit', async t => {
139+
await t.notThrowsAsync(async () => {
140+
const cwd = await git.bootstrap('fixtures/husky/integration');
141+
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd});
142+
143+
await execa('npm', ['install'], {cwd});
144+
await execa('git', ['add', 'package.json'], {cwd});
145+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
146+
});
147+
});
148+
149+
test('should work with husky commitmsg hook in sub packages', async t => {
150+
await t.notThrowsAsync(async () => {
151+
const upper = await git.bootstrap('fixtures/husky');
152+
const cwd = path.join(upper, 'integration');
153+
await writePkg(
154+
{husky: {hooks: {'commit-msg': `'${bin}' -e`}}},
155+
{cwd: upper}
156+
);
157+
158+
await execa('npm', ['install'], {cwd});
159+
await execa('git', ['add', 'package.json'], {cwd});
160+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
161+
});
162+
});
163+
164+
test('should work with husky via commitlint -e $GIT_PARAMS', async t => {
165+
await t.notThrowsAsync(async () => {
166+
const cwd = await git.bootstrap('fixtures/husky/integration');
167+
await writePkg(
168+
{husky: {hooks: {'commit-msg': `'${bin}' -e $GIT_PARAMS`}}},
169+
{cwd}
170+
);
171+
172+
await execa('npm', ['install'], {cwd});
173+
await execa('git', ['add', 'package.json'], {cwd});
174+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
175+
});
176+
});
177+
178+
test('should work with husky via commitlint -e %GIT_PARAMS%', async t => {
179+
await t.notThrowsAsync(async () => {
180+
const cwd = await git.bootstrap('fixtures/husky/integration');
181+
await writePkg(
182+
{husky: {hooks: {'commit-msg': `'${bin}' -e %GIT_PARAMS%`}}},
183+
{cwd}
184+
);
185+
186+
await execa('npm', ['install'], {cwd});
187+
await execa('git', ['add', 'package.json'], {cwd});
188+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
189+
});
190+
});
191+
192+
test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async t => {
193+
await t.notThrowsAsync(async () => {
194+
const cwd = await git.bootstrap('fixtures/husky/integration');
195+
await writePkg(
196+
{husky: {hooks: {'commit-msg': `'${bin}' -e $HUSKY_GIT_PARAMS`}}},
197+
{cwd}
198+
);
199+
200+
await execa('npm', ['install'], {cwd});
201+
await execa('git', ['add', 'package.json'], {cwd});
202+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
203+
});
204+
});
205+
206+
test('should work with husky via commitlint -e %HUSKY_GIT_PARAMS%', async t => {
207+
await t.notThrowsAsync(async () => {
208+
const cwd = await git.bootstrap('fixtures/husky/integration');
209+
await writePkg(
210+
{husky: {hooks: {'commit-msg': `'${bin}' -e %HUSKY_GIT_PARAMS%`}}},
211+
{cwd}
212+
);
213+
214+
await execa('npm', ['install'], {cwd});
215+
await execa('git', ['add', 'package.json'], {cwd});
216+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
217+
});
197218
});
198219

199220
test('should allow reading of environment variables for edit file, succeeding if valid', async t => {
@@ -269,18 +290,20 @@ test('should pick up config from inside git repo with precedence and fail accord
269290
t.is(actual.code, 1);
270291
});
271292

272-
test('should handle --amend with signoff', async () => {
273-
const cwd = await git.bootstrap('fixtures/signoff');
274-
await writePkg({scripts: {commitmsg: `'${bin}' -e`}}, {cwd});
275-
276-
await execa('npm', ['install'], {cwd});
277-
await execa('git', ['add', 'package.json'], {cwd});
278-
await execa(
279-
'git',
280-
['commit', '-m', '"test: this should work"', '--signoff'],
281-
{cwd}
282-
);
283-
await execa('git', ['commit', '--amend', '--no-edit'], {cwd});
293+
test('should handle --amend with signoff', async t => {
294+
await t.notThrowsAsync(async () => {
295+
const cwd = await git.bootstrap('fixtures/signoff');
296+
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd});
297+
298+
await execa('npm', ['install'], {cwd});
299+
await execa('git', ['add', 'package.json'], {cwd});
300+
await execa(
301+
'git',
302+
['commit', '-m', '"test: this should work"', '--signoff'],
303+
{cwd}
304+
);
305+
await execa('git', ['commit', '--amend', '--no-edit'], {cwd});
306+
});
284307
});
285308

286309
test('should handle linting with issue prefixes', async t => {

@commitlint/config-lerna-scopes/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@commitlint/test": "8.2.0",
5050
"@commitlint/utils": "^8.3.4",
5151
"@lerna/project": "3.18.0",
52-
"ava": "0.22.0",
52+
"ava": "2.4.0",
5353
"lerna": "3.18.3"
5454
}
5555
}

@commitlint/config-lerna-scopes/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ test('returns expected value for scoped lerna repository', async t => {
6565
test('works with lerna version < 3', async t => {
6666
const {'scope-enum': fn} = config.rules;
6767
const cwd = await npm.bootstrap('fixtures/lerna-two');
68-
await t.notThrows(async () => fn({cwd}));
68+
await t.notThrowsAsync(fn({cwd}));
6969
});

@commitlint/ensure/src/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test('rules export functions', () => {
1515
});
1616

1717
async function glob(pattern: string): Promise<string[]> {
18-
const files = await globby([path.join(__dirname, pattern)], {
18+
const files = await globby(pattern, {
1919
ignore: ['**/index.ts', '**/*.test.ts'],
2020
cwd: __dirname
2121
});

@commitlint/lint/package.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@
2323
"src/**/*.js",
2424
"!lib/**/*"
2525
],
26-
"babel": "inherit",
26+
"babel": {
27+
"testOptions": {
28+
"presets": [
29+
"babel-preset-commitlint"
30+
]
31+
}
32+
},
2733
"require": [
28-
"babel-register"
34+
"@babel/register"
2935
]
3036
},
3137
"babel": {
@@ -56,12 +62,13 @@
5662
},
5763
"license": "MIT",
5864
"devDependencies": {
65+
"@babel/cli": "^7.7.7",
66+
"@babel/core": "^7.7.7",
67+
"@babel/register": "^7.7.7",
5968
"@commitlint/test": "8.2.0",
6069
"@commitlint/utils": "^8.3.4",
61-
"ava": "0.22.0",
62-
"babel-cli": "6.26.0",
70+
"ava": "2.4.0",
6371
"babel-preset-commitlint": "^8.2.0",
64-
"babel-register": "6.26.0",
6572
"concurrently": "3.6.1",
6673
"cross-env": "6.0.3",
6774
"execa": "0.11.0",
@@ -72,7 +79,6 @@
7279
"@commitlint/is-ignored": "^8.3.5",
7380
"@commitlint/parse": "^8.3.4",
7481
"@commitlint/rules": "^8.3.4",
75-
"babel-runtime": "^6.23.0",
7682
"lodash": "4.17.15"
7783
}
7884
}

@commitlint/lint/src/index.test.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import test from 'ava';
22
import lint from '.';
33

44
test('throws without params', async t => {
5-
const error = await t.throws(lint());
5+
const error = await t.throwsAsync(lint());
66
t.is(error.message, 'Expected a raw commit');
77
});
88

99
test('throws with empty message', async t => {
10-
const error = await t.throws(lint(''));
10+
const error = await t.throwsAsync(lint(''));
1111
t.is(error.message, 'Expected a raw commit');
1212
});
1313

@@ -83,15 +83,15 @@ test('positive on stub message and opts', async t => {
8383
});
8484

8585
test('throws for invalid rule names', async t => {
86-
const error = await t.throws(
86+
const error = await t.throwsAsync(
8787
lint('foo', {foo: [2, 'always'], bar: [1, 'never']})
8888
);
8989

9090
t.is(error.message.indexOf('Found invalid rule names: foo, bar'), 0);
9191
});
9292

9393
test('throws for invalid rule config', async t => {
94-
const error = await t.throws(
94+
const error = await t.throwsAsync(
9595
lint('type(scope): foo', {
9696
'type-enum': 1,
9797
'scope-enum': {0: 2, 1: 'never', 2: ['foo'], length: 3}
@@ -103,19 +103,19 @@ test('throws for invalid rule config', async t => {
103103
});
104104

105105
test('allows disable shorthand', async t => {
106-
await t.notThrows(lint('foo', {'type-enum': [0], 'scope-enum': [0]}));
106+
await t.notThrowsAsync(lint('foo', {'type-enum': [0], 'scope-enum': [0]}));
107107
});
108108

109109
test('throws for rule with invalid length', async t => {
110-
const error = await t.throws(
110+
const error = await t.throwsAsync(
111111
lint('type(scope): foo', {'scope-enum': [1, 2, 3, 4]})
112112
);
113113

114114
t.true(error.message.indexOf('scope-enum must be 2 or 3 items long') > -1);
115115
});
116116

117117
test('throws for rule with invalid level', async t => {
118-
const error = await t.throws(
118+
const error = await t.throwsAsync(
119119
lint('type(scope): foo', {
120120
'type-enum': ['2', 'always'],
121121
'header-max-length': [{}, 'always']
@@ -127,7 +127,7 @@ test('throws for rule with invalid level', async t => {
127127
});
128128

129129
test('throws for rule with out of range level', async t => {
130-
const error = await t.throws(
130+
const error = await t.throwsAsync(
131131
lint('type(scope): foo', {
132132
'type-enum': [-1, 'always'],
133133
'header-max-length': [3, 'always']
@@ -139,7 +139,7 @@ test('throws for rule with out of range level', async t => {
139139
});
140140

141141
test('throws for rule with invalid condition', async t => {
142-
const error = await t.throws(
142+
const error = await t.throwsAsync(
143143
lint('type(scope): foo', {
144144
'type-enum': [1, 2],
145145
'header-max-length': [1, {}]
@@ -151,7 +151,7 @@ test('throws for rule with invalid condition', async t => {
151151
});
152152

153153
test('throws for rule with out of range condition', async t => {
154-
const error = await t.throws(
154+
const error = await t.throwsAsync(
155155
lint('type(scope): foo', {
156156
'type-enum': [1, 'foo'],
157157
'header-max-length': [1, 'bar']

0 commit comments

Comments
 (0)