Skip to content

fix: upgrade babel from 6 to 7 #886

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

Merged
merged 12 commits into from
Jan 26, 2020
9 changes: 5 additions & 4 deletions @commitlint/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
},
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.7",
"@babel/core": "^7.7.7",
"@babel/register": "^7.7.7",
"@commitlint/test": "8.2.0",
"@commitlint/utils": "^8.3.4",
"ava": "0.18.2",
"babel-cli": "6.26.0",
"ava": "2.4.0",
"babel-preset-commitlint": "^8.2.0",
"babel-register": "6.26.0",
"concurrently": "3.6.1",
"cross-env": "6.0.3",
"execa": "0.11.0",
Expand All @@ -74,8 +75,8 @@
"@commitlint/lint": "^8.3.4",
"@commitlint/load": "^8.3.4",
"@commitlint/read": "^8.3.4",
"babel-polyfill": "6.26.0",
"chalk": "2.4.2",
"core-js": "^3.6.1",
"get-stdin": "7.0.0",
"lodash": "4.17.15",
"meow": "5.0.0",
Expand Down
25 changes: 13 additions & 12 deletions @commitlint/cli/src/cli.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env node
require('babel-polyfill'); // eslint-disable-line import/no-unassigned-import

const load = require('@commitlint/load');
const lint = require('@commitlint/lint');
const read = require('@commitlint/read');
const meow = require('meow');
const {merge, pick, isFunction} = require('lodash');
const stdin = require('get-stdin');
const resolveFrom = require('resolve-from');
const resolveGlobal = require('resolve-global');

import 'core-js/stable'; // eslint-disable-line import/no-unassigned-import
import 'regenerator-runtime/runtime'; // eslint-disable-line import/no-unassigned-import

import load from '@commitlint/load';
import lint from '@commitlint/lint';
import read from '@commitlint/read';
import meow from 'meow';
import {merge, pick, isFunction} from 'lodash';
import stdin from 'get-stdin';
import resolveFrom from 'resolve-from';
import resolveGlobal from 'resolve-global';

import help from './help';
const pkg = require('../package');
const help = require('./help');

const flags = {
color: {
Expand Down
165 changes: 94 additions & 71 deletions @commitlint/cli/src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,65 +135,86 @@ test('should produce no error output with -q flag', async t => {
t.is(actual.code, 1);
});

test('should work with husky commitmsg hook and git commit', async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg({scripts: {commitmsg: `'${bin}' -e`}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});

test('should work with husky commitmsg hook in sub packages', async () => {
const upper = await git.bootstrap('fixtures/husky');
const cwd = path.join(upper, 'integration');
await writePkg({scripts: {commitmsg: `'${bin}' -e`}}, {cwd: upper});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});

test('should work with husky via commitlint -e $GIT_PARAMS', async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg({scripts: {commitmsg: `'${bin}' -e $GIT_PARAMS`}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});

test('should work with husky via commitlint -e %GIT_PARAMS%', async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg({scripts: {commitmsg: `'${bin}' -e %GIT_PARAMS%`}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});

test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{scripts: {commitmsg: `'${bin}' -e $HUSKY_GIT_PARAMS`}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});

test('should work with husky via commitlint -e %HUSKY_GIT_PARAMS%', async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{scripts: {commitmsg: `'${bin}' -e %HUSKY_GIT_PARAMS%`}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
test('should work with husky commitmsg hook and git commit', async t => {
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky commitmsg hook in sub packages', async t => {
await t.notThrowsAsync(async () => {
const upper = await git.bootstrap('fixtures/husky');
const cwd = path.join(upper, 'integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e`}}},
{cwd: upper}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky via commitlint -e $GIT_PARAMS', async t => {
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e $GIT_PARAMS`}}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky via commitlint -e %GIT_PARAMS%', async t => {
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e %GIT_PARAMS%`}}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async t => {
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e $HUSKY_GIT_PARAMS`}}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

test('should work with husky via commitlint -e %HUSKY_GIT_PARAMS%', async t => {
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e %HUSKY_GIT_PARAMS%`}}},
{cwd}
);

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
});
});

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

test('should handle --amend with signoff', async () => {
const cwd = await git.bootstrap('fixtures/signoff');
await writePkg({scripts: {commitmsg: `'${bin}' -e`}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa(
'git',
['commit', '-m', '"test: this should work"', '--signoff'],
{cwd}
);
await execa('git', ['commit', '--amend', '--no-edit'], {cwd});
test('should handle --amend with signoff', async t => {
await t.notThrowsAsync(async () => {
const cwd = await git.bootstrap('fixtures/signoff');
await writePkg({husky: {hooks: {'commit-msg': `'${bin}' -e`}}}, {cwd});

await execa('npm', ['install'], {cwd});
await execa('git', ['add', 'package.json'], {cwd});
await execa(
'git',
['commit', '-m', '"test: this should work"', '--signoff'],
{cwd}
);
await execa('git', ['commit', '--amend', '--no-edit'], {cwd});
});
});

test('should handle linting with issue prefixes', async t => {
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/config-lerna-scopes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@commitlint/test": "8.2.0",
"@commitlint/utils": "^8.3.4",
"@lerna/project": "3.18.0",
"ava": "0.22.0",
"ava": "2.4.0",
"lerna": "3.18.3"
}
}
2 changes: 1 addition & 1 deletion @commitlint/config-lerna-scopes/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ test('returns expected value for scoped lerna repository', async t => {
test('works with lerna version < 3', async t => {
const {'scope-enum': fn} = config.rules;
const cwd = await npm.bootstrap('fixtures/lerna-two');
await t.notThrows(async () => fn({cwd}));
await t.notThrowsAsync(fn({cwd}));
});
2 changes: 1 addition & 1 deletion @commitlint/ensure/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('rules export functions', () => {
});

async function glob(pattern: string): Promise<string[]> {
const files = await globby([path.join(__dirname, pattern)], {
const files = await globby(pattern, {
ignore: ['**/index.ts', '**/*.test.ts'],
cwd: __dirname
});
Expand Down
18 changes: 12 additions & 6 deletions @commitlint/lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
"src/**/*.js",
"!lib/**/*"
],
"babel": "inherit",
"babel": {
"testOptions": {
"presets": [
"babel-preset-commitlint"
]
}
},
"require": [
"babel-register"
"@babel/register"
]
},
"babel": {
Expand Down Expand Up @@ -56,12 +62,13 @@
},
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.7",
"@babel/core": "^7.7.7",
"@babel/register": "^7.7.7",
"@commitlint/test": "8.2.0",
"@commitlint/utils": "^8.3.4",
"ava": "0.22.0",
"babel-cli": "6.26.0",
"ava": "2.4.0",
"babel-preset-commitlint": "^8.2.0",
"babel-register": "6.26.0",
"concurrently": "3.6.1",
"cross-env": "6.0.3",
"execa": "0.11.0",
Expand All @@ -72,7 +79,6 @@
"@commitlint/is-ignored": "^8.3.4",
"@commitlint/parse": "^8.3.4",
"@commitlint/rules": "^8.3.4",
"babel-runtime": "^6.23.0",
"lodash": "4.17.15"
}
}
20 changes: 10 additions & 10 deletions @commitlint/lint/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import test from 'ava';
import lint from '.';

test('throws without params', async t => {
const error = await t.throws(lint());
const error = await t.throwsAsync(lint());
t.is(error.message, 'Expected a raw commit');
});

test('throws with empty message', async t => {
const error = await t.throws(lint(''));
const error = await t.throwsAsync(lint(''));
t.is(error.message, 'Expected a raw commit');
});

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

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

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

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

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

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

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

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

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

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

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