Skip to content

Commit 551e9a2

Browse files
Merge pull request #52 from conventional-changelog/master
[pull] master from conventional-changelog:master
2 parents 36e4415 + aa4df36 commit 551e9a2

File tree

7 files changed

+567
-506
lines changed

7 files changed

+567
-506
lines changed

@commitlint/config-angular/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test('a leading blank line after header', async () => {
6464
});
6565

6666
test('an invalid scope', async () => {
67-
const result = await lintMessage(`no: no is not not an invalid commit type`);
67+
const result = await lintMessage(`no: no is not an invalid commit type`);
6868

6969
expect(result.valid).toBe(false);
7070
expect(result.errors[0].message).toBe(

@commitlint/config-nx-scopes/readme.md

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,64 @@ As an example, the following code demonstrates how to select only applications t
2121
In your .commitlintrc.js file:
2222

2323
```javascript
24-
const {
25-
utils: {getProjects},
26-
} = require('@commitlint/config-nx-scopes');
27-
28-
module.exports = {
29-
rules: {
30-
'scope-enum': async (ctx) => [
31-
2,
32-
'always',
33-
[
34-
...(await getProjects(
35-
ctx,
36-
({name, projectType}) =>
37-
!name.includes('e2e') && projectType == 'application'
38-
)),
24+
async function getConfig() {
25+
const {
26+
default: {
27+
utils: {getProjects},
28+
},
29+
} = await import('@commitlint/config-nx-scopes');
30+
31+
return {
32+
rules: {
33+
'scope-enum': async (ctx) => [
34+
2,
35+
'always',
36+
[
37+
...(await getProjects(
38+
ctx,
39+
({name, projectType}) =>
40+
!name.includes('e2e') && projectType == 'application'
41+
)),
42+
],
3943
],
40-
],
41-
},
42-
// . . .
43-
};
44+
},
45+
// . . .
46+
};
47+
}
48+
49+
module.exports = getConfig();
4450
```
4551

4652
Here is another example where projects tagged with 'stage:end-of-life' are not allowed to be used as the scope for a commit.
4753

4854
In your .commitlintrc.js file:
4955

5056
```javascript
51-
const {
52-
utils: {getProjects},
53-
} = require('@commitlint/config-nx-scopes');
54-
55-
module.exports = {
56-
rules: {
57-
'scope-enum': async (ctx) => [
58-
2,
59-
'always',
60-
[
61-
...(await getProjects(
62-
ctx,
63-
({tags}) => !tags.includes('stage:end-of-life')
64-
)),
57+
async function getConfig() {
58+
const {
59+
default: {
60+
utils: {getProjects},
61+
},
62+
} = await import('@commitlint/config-nx-scopes');
63+
64+
return {
65+
rules: {
66+
'scope-enum': async (ctx) => [
67+
2,
68+
'always',
69+
[
70+
...(await getProjects(
71+
ctx,
72+
({tags}) => !tags.includes('stage:end-of-life')
73+
)),
74+
],
6575
],
66-
],
67-
},
68-
// . . .
69-
};
76+
},
77+
// . . .
78+
};
79+
}
80+
81+
module.exports = getConfig();
7082
```
7183

7284
## Examples

@commitlint/format/src/format.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,29 @@ test('returns empty summary if verbose', () => {
3535
expect(actual).toContain('0 problems, 0 warnings');
3636
});
3737

38+
test('returns empty summary with full commit message if verbose', () => {
39+
const actual = format(
40+
{
41+
results: [
42+
{
43+
errors: [],
44+
warnings: [],
45+
input:
46+
'feat(cli): this is a valid header\n\nThis is a valid body\n\nSigned-off-by: tester',
47+
},
48+
],
49+
},
50+
{
51+
verbose: true,
52+
color: false,
53+
}
54+
);
55+
56+
expect(actual).toStrictEqual(
57+
'⧗ input: feat(cli): this is a valid header\n\nThis is a valid body\n\nSigned-off-by: tester\n✔ found 0 problems, 0 warnings'
58+
);
59+
});
60+
3861
test('returns a correct summary of empty .errors and .warnings', () => {
3962
const actualError = format({
4063
results: [

@commitlint/format/src/format.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ function formatInput(
4242

4343
const sign = '⧗';
4444
const decoration = enabled ? chalk.gray(sign) : sign;
45-
const commitText = errors.length > 0 ? input : input.split('\n')[0];
4645

47-
const decoratedInput = enabled ? chalk.bold(commitText) : commitText;
46+
const decoratedInput = enabled ? chalk.bold(input) : input;
4847
const hasProblems = errors.length > 0 || warnings.length > 0;
4948

5049
return options.verbose || hasProblems

Dockerfile.ci

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN yarn install && \
66
# Commit lint CLI packages
77
npm pack @commitlint/cli && \
88
npm pack @commitlint/config-validator && \
9+
npm pack @commitlint/config-nx-scopes && \
910
npm pack @commitlint/ensure && \
1011
npm pack @commitlint/execute-rule && \
1112
npm pack @commitlint/format && \

docs/guides/ci-setup.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ lint:commit:
146146
entrypoint: ['']
147147
stage: lint
148148
script:
149+
# Uncomment the next line if you are extending the @commitlint/config-nx-scopes in your commitlint configuration
150+
#- npm i -g nx@$(node -pe "require('./package.json').devDependencies.nx")
149151
- echo "${CI_COMMIT_MESSAGE}" | commitlint
150152
```
151153

0 commit comments

Comments
 (0)