Skip to content

Commit fba791c

Browse files
committed
chore: merge master
2 parents e58d5cb + 6ea5a9a commit fba791c

36 files changed

+1068
-633
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
rules: {
3+
'type-enum': [2, 'never', ['foo']]
4+
},
5+
helpUrl: 'https://www.example.com/foo'
6+
};

@commitlint/cli/package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,17 @@
3636
},
3737
"license": "MIT",
3838
"devDependencies": {
39-
"@babel/cli": "^7.11.6",
40-
"@babel/core": "^7.11.6",
4139
"@commitlint/test": "^11.0.0",
4240
"@commitlint/utils": "^11.0.0",
4341
"@types/yargs": "^15.0.5",
44-
"babel-preset-commitlint": "^11.0.0",
45-
"cross-env": "7.0.2",
46-
"execa": "^4.0.0",
42+
"execa": "^5.0.0",
4743
"fs-extra": "^9.0.0"
4844
},
4945
"dependencies": {
50-
"@babel/runtime": "^7.11.2",
5146
"@commitlint/format": "^11.0.0",
5247
"@commitlint/lint": "^11.0.0",
5348
"@commitlint/load": "^11.0.0",
5449
"@commitlint/read": "^11.0.0",
55-
"chalk": "4.1.0",
56-
"core-js": "^3.6.1",
5750
"get-stdin": "8.0.0",
5851
"lodash": "^4.17.19",
5952
"resolve-from": "5.0.0",

@commitlint/cli/src/cli.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ test('should fail for input from stdin with rule from js', async () => {
120120
expect(actual.exitCode).toBe(1);
121121
});
122122

123+
test('should output help URL defined in config file', async () => {
124+
const cwd = await gitBootstrap('fixtures/help-url');
125+
const actual = await cli([], {cwd})('foo: bar');
126+
expect(actual.stdout).toContain('Get help: https://www.example.com/foo');
127+
expect(actual.exitCode).toBe(1);
128+
});
129+
123130
test('should produce no error output with --quiet flag', async () => {
124131
const cwd = await gitBootstrap('fixtures/simple');
125132
const actual = await cli(['--quiet'], {cwd})('foo: bar');

@commitlint/cli/src/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ async function main(options: CliFlags) {
229229
}
230230
);
231231

232+
const helpUrl = flags['help-url']?.trim() || loaded.helpUrl;
233+
232234
const output = format(report, {
233235
color: flags.color,
234236
verbose: flags.verbose,
235-
helpUrl: flags['help-url']
236-
? flags['help-url'].trim()
237-
: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
237+
helpUrl,
238238
});
239239

240240
if (!flags.quiet && output !== '') {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"dependencies": {
3535
"import-from": "3.0.0",
3636
"resolve-pkg": "2.0.0",
37-
"semver": "7.3.2"
37+
"semver": "7.3.4"
3838
},
3939
"devDependencies": {
4040
"@commitlint/test": "^11.0.0",

@commitlint/is-ignored/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"dependencies": {
4343
"@commitlint/types": "^11.0.0",
44-
"semver": "7.3.2"
44+
"semver": "7.3.4"
4545
},
4646
"gitHead": "cb565dfcca3128380b9b3dc274aedbcae34ce5ca"
4747
}

@commitlint/is-ignored/src/defaults.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export const wildcards: Matcher[] = [
2121
test(/^(R|r)evert (.*)/),
2222
test(/^(fixup|squash)!/),
2323
isSemver,
24-
test(/^Merged (.*?)(in|into) (.*)/),
25-
test(/^Merge remote-tracking branch (.*)/),
24+
test(/^(Merged (.*?)(in|into) (.*)|Merged PR (.*): (.*))/),
25+
test(/^Merge remote-tracking branch(\s*)(.*)/),
2626
test(/^Automatic merge(.*)/),
2727
test(/^Auto-merged (.*?) into (.*)/),
2828
];

@commitlint/is-ignored/src/is-ignored.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ test('should return true for bitbucket merge commits', () => {
122122

123123
test('should return true for automatic merge commits', () => {
124124
expect(isIgnored('Auto-merged develop into master')).toBe(true);
125+
expect(isIgnored('Merge remote-tracking branch')).toBe(true);
126+
});
127+
128+
test('should return true for azure devops merge commits', () => {
129+
expect(isIgnored('Merged PR 123: Description here')).toBe(true);
125130
});
126131

127132
test('should return false for commits containing, but not starting, with merge branch', () => {

@commitlint/load/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"devDependencies": {
3737
"@commitlint/test": "^11.0.0",
3838
"@commitlint/utils": "^11.0.0",
39-
"@types/lodash": "4.14.161",
40-
"execa": "^4.0.0"
39+
"@types/lodash": "4.14.167",
40+
"execa": "^5.0.0"
4141
},
4242
"dependencies": {
4343
"@commitlint/execute-rule": "^11.0.0",

@commitlint/load/src/load.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ export default async function load(
112112
return registry;
113113
}, {});
114114

115+
const helpUrl =
116+
typeof config.helpUrl === 'string'
117+
? config.helpUrl
118+
: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint';
119+
115120
return {
116121
extends: preset.extends!,
117122
formatter: preset.formatter!,
@@ -120,5 +125,6 @@ export default async function load(
120125
defaultIgnores: preset.defaultIgnores!,
121126
plugins: preset.plugins!,
122127
rules: qualifiedRules,
128+
helpUrl,
123129
};
124130
}

@commitlint/load/src/utils/pick-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export const pickConfig = (input: unknown): UserConfig =>
1010
'parserPreset',
1111
'formatter',
1212
'ignores',
13-
'defaultIgnores'
13+
'defaultIgnores',
14+
'helpUrl'
1415
);

@commitlint/prompt-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"dependencies": {
3838
"@commitlint/prompt": "^11.0.0",
39-
"execa": "^4.0.0"
39+
"execa": "^5.0.0"
4040
},
4141
"gitHead": "cb565dfcca3128380b9b3dc274aedbcae34ce5ca"
4242
}

@commitlint/prompt/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"@babel/core": "^7.11.6",
5353
"@commitlint/utils": "^11.0.0",
5454
"babel-preset-commitlint": "^11.0.0",
55-
"commitizen": "4.2.1",
56-
"cross-env": "7.0.2"
55+
"commitizen": "4.2.2",
56+
"cross-env": "7.0.3"
5757
},
5858
"dependencies": {
5959
"@babel/runtime": "^7.11.2",

@commitlint/rules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@commitlint/parse": "^11.0.0",
3838
"@commitlint/test": "^11.0.0",
3939
"@commitlint/utils": "^11.0.0",
40-
"conventional-changelog-angular": "5.0.11",
40+
"conventional-changelog-angular": "5.0.12",
4141
"globby": "^11.0.0"
4242
},
4343
"dependencies": {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import parse from '@commitlint/parse';
2+
import {bodyFullStop} from './body-full-stop';
3+
4+
const messages = {
5+
empty: 'test:\n',
6+
with: `test: subject\n\nbody.`,
7+
without: `test: subject\n\nbody`,
8+
};
9+
10+
const parsed = {
11+
empty: parse(messages.empty),
12+
with: parse(messages.with),
13+
without: parse(messages.without),
14+
};
15+
16+
test('empty against "always" should succeed', async () => {
17+
const [actual] = bodyFullStop(await parsed.empty, 'always', '.');
18+
const expected = true;
19+
expect(actual).toEqual(expected);
20+
});
21+
22+
test('empty against "never ." should succeed', async () => {
23+
const [actual] = bodyFullStop(await parsed.empty, 'never', '.');
24+
const expected = true;
25+
expect(actual).toEqual(expected);
26+
});
27+
28+
test('with against "always ." should succeed', async () => {
29+
const [actual] = bodyFullStop(await parsed.with, 'always', '.');
30+
const expected = true;
31+
expect(actual).toEqual(expected);
32+
});
33+
34+
test('with against "never ." should fail', async () => {
35+
const [actual] = bodyFullStop(await parsed.with, 'never', '.');
36+
const expected = false;
37+
expect(actual).toEqual(expected);
38+
});
39+
40+
test('without against "always ." should fail', async () => {
41+
const [actual] = bodyFullStop(await parsed.without, 'always', '.');
42+
const expected = false;
43+
expect(actual).toEqual(expected);
44+
});
45+
46+
test('without against "never ." should succeed', async () => {
47+
const [actual] = bodyFullStop(await parsed.without, 'never', '.');
48+
const expected = true;
49+
expect(actual).toEqual(expected);
50+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import message from '@commitlint/message';
2+
import {SyncRule} from '@commitlint/types';
3+
4+
export const bodyFullStop: SyncRule<string> = (
5+
parsed,
6+
when = 'always',
7+
value = '.'
8+
) => {
9+
const input = parsed.body;
10+
11+
if (!input) {
12+
return [true];
13+
}
14+
15+
const negated = when === 'never';
16+
const hasStop = input[input.length - 1] === value;
17+
18+
return [
19+
negated ? !hasStop : hasStop,
20+
message(['body', negated ? 'may not' : 'must', 'end with full stop']),
21+
];
22+
};

@commitlint/rules/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {bodyCase} from './body-case';
22
import {bodyEmpty} from './body-empty';
3+
import {bodyFullStop} from './body-full-stop';
34
import {bodyLeadingBlank} from './body-leading-blank';
45
import {bodyMaxLength} from './body-max-length';
56
import {bodyMaxLineLength} from './body-max-line-length';
@@ -34,6 +35,7 @@ import {typeMinLength} from './type-min-length';
3435
export default {
3536
'body-case': bodyCase,
3637
'body-empty': bodyEmpty,
38+
'body-full-stop': bodyFullStop,
3739
'body-leading-blank': bodyLeadingBlank,
3840
'body-max-length': bodyMaxLength,
3941
'body-max-line-length': bodyMaxLineLength,

@commitlint/travis-cli/cli.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require('./lib/cli');

@commitlint/travis-cli/package.json

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,15 @@
33
"version": "11.0.0",
44
"description": "Lint all relevant commits for a change or PR on Travis CI",
55
"files": [
6-
"lib/"
6+
"lib/",
7+
"cli.js"
78
],
89
"bin": {
9-
"commitlint-travis": "./lib/cli.js"
10+
"commitlint-travis": "./cli.js"
1011
},
1112
"scripts": {
12-
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
1313
"deps": "dep-check",
14-
"pkg": "pkg-check --skip-main",
15-
"start": "yarn run watch",
16-
"watch": "babel src --out-dir lib --watch --source-maps"
17-
},
18-
"babel": {
19-
"presets": [
20-
"babel-preset-commitlint"
21-
],
22-
"ignore": [
23-
"**/*.test.js"
24-
]
14+
"pkg": "pkg-check --skip-main"
2515
},
2616
"engines": {
2717
"node": ">=v10.22.1"
@@ -45,17 +35,12 @@
4535
},
4636
"license": "MIT",
4737
"devDependencies": {
48-
"@babel/cli": "7.11.6",
49-
"@babel/core": "7.11.6",
5038
"@commitlint/test": "^11.0.0",
51-
"@commitlint/utils": "^11.0.0",
52-
"babel-preset-commitlint": "^11.0.0",
53-
"cross-env": "7.0.2"
39+
"@commitlint/utils": "^11.0.0"
5440
},
5541
"dependencies": {
56-
"@babel/runtime": "^7.11.2",
5742
"@commitlint/cli": "^11.0.0",
58-
"execa": "^4.0.0"
43+
"execa": "^5.0.0"
5944
},
6045
"gitHead": "cb565dfcca3128380b9b3dc274aedbcae34ce5ca"
6146
}

@commitlint/travis-cli/src/cli.test.js renamed to @commitlint/travis-cli/src/cli.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import execa from 'execa';
22
import {git} from '@commitlint/test';
33

4-
const bin = require.resolve('../lib/cli.js');
4+
const bin = require.resolve('../cli.js');
55

66
const TRAVIS_COMMITLINT_BIN = require.resolve('../fixtures/commitlint');
77
const TRAVIS_COMMITLINT_GIT_BIN = require.resolve('../fixtures/git');
88

99
const validBaseEnv = {
10-
TRAVIS: true,
11-
CI: true,
10+
TRAVIS: 'true',
11+
CI: 'true',
1212
TRAVIS_COMMIT: 'TRAVIS_COMMIT',
1313
TRAVIS_COMMITLINT_BIN: TRAVIS_COMMITLINT_BIN,
1414
TRAVIS_COMMITLINT_GIT_BIN: TRAVIS_COMMITLINT_GIT_BIN,
@@ -18,7 +18,7 @@ const validBaseEnv = {
1818
TRAVIS_PULL_REQUEST_SLUG: 'TRAVIS_PULL_REQUEST_SLUG',
1919
};
2020

21-
const cli = async (config = {}, args = []) => {
21+
const cli = async (config: execa.Options = {}, args: string[] = []) => {
2222
try {
2323
return await execa(bin, args, config);
2424
} catch (err) {
@@ -28,8 +28,8 @@ const cli = async (config = {}, args = []) => {
2828

2929
test('should throw when not on travis ci', async () => {
3030
const env = {
31-
CI: false,
32-
TRAVIS: false,
31+
CI: 'false',
32+
TRAVIS: 'false',
3333
};
3434

3535
await expect(cli({env})).rejects.toThrow(
@@ -39,8 +39,8 @@ test('should throw when not on travis ci', async () => {
3939

4040
test('should throw when on travis ci, but env vars are missing', async () => {
4141
const env = {
42-
TRAVIS: true,
43-
CI: true,
42+
TRAVIS: 'true',
43+
CI: 'true',
4444
};
4545

4646
await expect(cli({env})).rejects.toThrow(
@@ -131,7 +131,7 @@ test('should call git with extra expected args on pull_request', async () => {
131131
]);
132132
});
133133

134-
function getInvocations(stdout) {
134+
function getInvocations(stdout: string): string[][] {
135135
const matches = stdout.match(/[^[\]]+/g);
136136
const raw = Array.isArray(matches) ? matches : [];
137137

0 commit comments

Comments
 (0)