Skip to content

Commit c98cd78

Browse files
committed
style: apply prettier style changes
1 parent a0d4d39 commit c98cd78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+532
-515
lines changed

@commitlint/cli/cli.js

+42-34
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const help = require('./help');
1515
* Behavioural rules
1616
*/
1717
const rules = {
18-
fromStdin: (input, flags) => input.length === 0 &&
18+
fromStdin: (input, flags) =>
19+
input.length === 0 &&
1920
typeof flags.from !== 'string' &&
2021
typeof flags.to !== 'string' &&
2122
!flags.edit
@@ -54,10 +55,15 @@ const configuration = {
5455
}
5556
};
5657

57-
const cli = meow({
58-
help: `[input] reads from stdin if --edit, --from and --to are omitted\n${help(configuration)}`,
59-
description: `${pkg.name}@${pkg.version} - ${pkg.description}`
60-
}, configuration);
58+
const cli = meow(
59+
{
60+
help: `[input] reads from stdin if --edit, --from and --to are omitted\n${help(
61+
configuration
62+
)}`,
63+
description: `${pkg.name}@${pkg.version} - ${pkg.description}`
64+
},
65+
configuration
66+
);
6167

6268
const load = seed => core.load(seed);
6369

@@ -70,28 +76,31 @@ function main(options) {
7076
const input = fromStdin ? stdin() : core.read(range);
7177
const fmt = new chalk.constructor({enabled: flags.color});
7278

73-
return input
74-
.then(raw => Array.isArray(raw) ? raw : [raw])
75-
.then(messages => Promise.all(messages.map(commit => {
76-
return load(getSeed(flags))
77-
.then(opts => core.lint(commit, opts.rules))
78-
.then(report => {
79-
const formatted = core.format(report, {color: flags.color});
79+
return input.then(raw => (Array.isArray(raw) ? raw : [raw])).then(messages =>
80+
Promise.all(
81+
messages.map(commit => {
82+
return load(getSeed(flags))
83+
.then(opts => core.lint(commit, opts.rules))
84+
.then(report => {
85+
const formatted = core.format(report, {color: flags.color});
8086

81-
if (!flags.quiet) {
82-
console.log(`${fmt.grey('⧗')} input: ${fmt.bold(commit.split('\n')[0])}`);
83-
console.log(formatted.join('\n'));
84-
}
87+
if (!flags.quiet) {
88+
console.log(
89+
`${fmt.grey('⧗')} input: ${fmt.bold(commit.split('\n')[0])}`
90+
);
91+
console.log(formatted.join('\n'));
92+
}
8593

86-
if (report.errors.length > 0) {
87-
const error = new Error(formatted[formatted.length - 1]);
88-
error.type = pkg.name;
89-
throw error;
90-
}
91-
return console.log('');
92-
});
93-
})
94-
));
94+
if (report.errors.length > 0) {
95+
const error = new Error(formatted[formatted.length - 1]);
96+
error.type = pkg.name;
97+
throw error;
98+
}
99+
return console.log('');
100+
});
101+
})
102+
)
103+
);
95104
}
96105

97106
function getSeed(seed) {
@@ -101,15 +110,14 @@ function getSeed(seed) {
101110
}
102111

103112
// Start the engine
104-
main(cli)
105-
.catch(err =>
106-
setTimeout(() => {
107-
if (err.type === pkg.name) {
108-
process.exit(1);
109-
}
110-
throw err;
111-
})
112-
);
113+
main(cli).catch(err =>
114+
setTimeout(() => {
115+
if (err.type === pkg.name) {
116+
process.exit(1);
117+
}
118+
throw err;
119+
})
120+
);
113121

114122
// Catch unhandled rejections globally
115123
process.on('unhandledRejection', (reason, promise) => {

@commitlint/cli/cli.test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ test('should fail for input from stdin with rule from rc', async t => {
5151
});
5252

5353
test('should fail for input from stdin with rule from js', async t => {
54-
const actual = await t.throws(cli('foo: bar', ['--extends', './extended'], {cwd: EXTENDS_ROOT}));
54+
const actual = await t.throws(
55+
cli('foo: bar', ['--extends', './extended'], {cwd: EXTENDS_ROOT})
56+
);
5557
t.true(actual.stdout.includes('scope must not be one of [foo]'));
5658
t.is(actual.code, 1);
5759
});

@commitlint/cli/help.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module.exports = configuration => {
2-
const lines = Object.entries(configuration.description)
3-
.map(entry => {
4-
const name = entry[0];
5-
const desc = entry[1];
6-
const alias = Object.entries(configuration.alias)
7-
.find(entry => entry[1] === name)
8-
.map(entry => entry[0])[0];
9-
const defaults = configuration.default[name];
10-
return [[name, alias].filter(Boolean), desc, defaults].filter(Boolean);
11-
});
2+
const lines = Object.entries(configuration.description).map(entry => {
3+
const name = entry[0];
4+
const desc = entry[1];
5+
const alias = Object.entries(configuration.alias)
6+
.find(entry => entry[1] === name)
7+
.map(entry => entry[0])[0];
8+
const defaults = configuration.default[name];
9+
return [[name, alias].filter(Boolean), desc, defaults].filter(Boolean);
10+
});
1211

1312
const longest = lines
1413
.map(line => {
@@ -22,7 +21,9 @@ module.exports = configuration => {
2221
const flags = line[0];
2322
const desc = line[1];
2423
const defaults = line[2];
25-
const fs = flags.map(flag => flag.length > 1 ? `--${flag}` : `-${flag}`);
24+
const fs = flags.map(
25+
flag => (flag.length > 1 ? `--${flag}` : `-${flag}`)
26+
);
2627
const ds = defaults ? `, defaults to: ${defaults}` : '';
2728
const length = flags.reduce((sum, flag) => sum + flag.length, 0);
2829
return `${fs.join(',')}${' '.repeat(4 + longest - length)}${desc}${ds}`;

@commitlint/config-angular/index.js

+14-45
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,19 @@
11
module.exports = {
22
rules: {
3-
'body-leading-blank': [1,
4-
'always'
5-
],
6-
'body-tense': [1,
7-
'always',
8-
['present-imperative']
9-
],
10-
'footer-leading-blank': [1,
11-
'always'
12-
],
13-
'footer-tense': [1,
14-
'always',
15-
['present-imperative']
16-
],
17-
'header-max-length': [2,
18-
'always',
19-
72
20-
],
21-
lang: [1,
22-
'always',
23-
'eng'
24-
],
25-
'scope-case': [2,
26-
'always',
27-
'lowerCase'
28-
],
29-
'subject-empty': [2,
30-
'never'
31-
],
32-
'subject-full-stop': [2,
33-
'never',
34-
'.'
35-
],
36-
'subject-tense': [1,
37-
'always',
38-
['present-imperative']
39-
],
40-
'type-case': [2,
41-
'always',
42-
'lowerCase'
43-
],
44-
'type-empty': [2,
45-
'never'
46-
],
47-
'type-enum': [2,
3+
'body-leading-blank': [1, 'always'],
4+
'body-tense': [1, 'always', ['present-imperative']],
5+
'footer-leading-blank': [1, 'always'],
6+
'footer-tense': [1, 'always', ['present-imperative']],
7+
'header-max-length': [2, 'always', 72],
8+
lang: [1, 'always', 'eng'],
9+
'scope-case': [2, 'always', 'lowerCase'],
10+
'subject-empty': [2, 'never'],
11+
'subject-full-stop': [2, 'never', '.'],
12+
'subject-tense': [1, 'always', ['present-imperative']],
13+
'type-case': [2, 'always', 'lowerCase'],
14+
'type-empty': [2, 'never'],
15+
'type-enum': [
16+
2,
4817
'always',
4918
[
5019
'build',

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ function getPackages() {
1111
const repo = new Repository(process.cwd());
1212
return repo.packages
1313
.map(pkg => pkg.name)
14-
.map(name => name.charAt(0) === '@' ? name.split('/')[1] : name);
14+
.map(name => (name.charAt(0) === '@' ? name.split('/')[1] : name));
1515
}

@commitlint/config-patternplate/index.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ function pathToId(root, filePath) {
1010
function getPatternIDs() {
1111
const root = path.resolve(process.cwd(), './patterns');
1212
const glob = path.resolve(root, '**/pattern.json');
13-
return globby(glob)
14-
.then(results => results.map(result => pathToId(root, result)));
13+
return globby(glob).then(results =>
14+
results.map(result => pathToId(root, result))
15+
);
1516
}
1617

17-
module.exports = merge(
18-
require('@commitlint/config-angular'),
19-
{
20-
rules: {
21-
'scope-enum': () => getPatternIDs()
22-
.then(ids => [2, 'always', ids.concat(['system'])])
23-
}
18+
module.exports = merge(require('@commitlint/config-angular'), {
19+
rules: {
20+
'scope-enum': () =>
21+
getPatternIDs().then(ids => [2, 'always', ids.concat(['system'])])
2422
}
25-
);
23+
});

@commitlint/core/fixtures/overridden-type-enums/extended.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
rules: {
3-
'type-enum': [2,
3+
'type-enum': [
4+
2,
45
'always',
56
[
67
'build',

@commitlint/core/src/format.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ const DEFAULT_SIGNS = [' ', '⚠', '✖'];
44
const DEFAULT_COLORS = ['white', 'yellow', 'red'];
55

66
export default function format(report = {}, options = {}) {
7-
const {signs = DEFAULT_SIGNS, colors = DEFAULT_COLORS, color: enabled = true} = options;
7+
const {
8+
signs = DEFAULT_SIGNS,
9+
colors = DEFAULT_COLORS,
10+
color: enabled = true
11+
} = options;
812
const {errors = [], warnings = []} = report;
913

10-
const problems = [...errors, ...warnings]
11-
.map(problem => {
12-
const sign = signs[problem.level] || '';
13-
const color = colors[problem.level] || 'white';
14-
const decoration = enabled ? chalk[color](sign) : sign;
15-
const name = enabled ? chalk.grey(`[${problem.name}]`) : `[${problem.name}]`;
16-
return `${decoration} ${problem.message} ${name}`;
17-
});
14+
const problems = [...errors, ...warnings].map(problem => {
15+
const sign = signs[problem.level] || '';
16+
const color = colors[problem.level] || 'white';
17+
const decoration = enabled ? chalk[color](sign) : sign;
18+
const name = enabled
19+
? chalk.grey(`[${problem.name}]`)
20+
: `[${problem.name}]`;
21+
return `${decoration} ${problem.message} ${name}`;
22+
});
1823

1924
const sign = selectSign({errors, warnings});
2025
const color = selectColor({errors, warnings});

@commitlint/core/src/format.test.js

+42-36
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,27 @@ test('uses appropriate signs by default', t => {
8484
});
8585

8686
test('uses signs as configured', t => {
87-
const [err, warn] = format({
88-
errors: [
89-
{
90-
level: 2,
91-
name: 'error-name',
92-
message: 'There was an error'
93-
}
94-
],
95-
warnings: [
96-
{
97-
level: 1,
98-
name: 'warning-name',
99-
message: 'There was a problem'
100-
}
101-
]
102-
}, {
103-
signs: ['HNT', 'WRN', 'ERR']
104-
});
87+
const [err, warn] = format(
88+
{
89+
errors: [
90+
{
91+
level: 2,
92+
name: 'error-name',
93+
message: 'There was an error'
94+
}
95+
],
96+
warnings: [
97+
{
98+
level: 1,
99+
name: 'warning-name',
100+
message: 'There was a problem'
101+
}
102+
]
103+
},
104+
{
105+
signs: ['HNT', 'WRN', 'ERR']
106+
}
107+
);
105108

106109
t.true(err.includes('ERR'));
107110
t.true(warn.includes('WRN'));
@@ -131,24 +134,27 @@ test('uses appropriate colors by default', t => {
131134

132135
if (process.platform !== 'win32') {
133136
test('uses colors as configured', t => {
134-
const [err, warn] = format({
135-
errors: [
136-
{
137-
level: 2,
138-
name: 'error-name',
139-
message: 'There was an error'
140-
}
141-
],
142-
warnings: [
143-
{
144-
level: 1,
145-
name: 'warning-name',
146-
message: 'There was a problem'
147-
}
148-
]
149-
}, {
150-
colors: ['white', 'magenta', 'blue']
151-
});
137+
const [err, warn] = format(
138+
{
139+
errors: [
140+
{
141+
level: 2,
142+
name: 'error-name',
143+
message: 'There was an error'
144+
}
145+
],
146+
warnings: [
147+
{
148+
level: 1,
149+
name: 'warning-name',
150+
message: 'There was a problem'
151+
}
152+
]
153+
},
154+
{
155+
colors: ['white', 'magenta', 'blue']
156+
}
157+
);
152158

153159
t.true(err.includes(blue.open));
154160
t.true(warn.includes(magenta.open));

0 commit comments

Comments
 (0)