Skip to content

Commit 0806545

Browse files
committed
style: run prettier v3
1 parent dffa5ee commit 0806545

File tree

104 files changed

+413
-412
lines changed

Some content is hidden

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

104 files changed

+413
-412
lines changed

@commitlint/cli/src/cli-error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class CliError extends Error {
1515
constructor(
1616
message: string,
1717
type: string,
18-
error_code = ExitCode.CommitlintErrorDefault
18+
error_code = ExitCode.CommitlintErrorDefault,
1919
) {
2020
super(message);
2121

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ test('should produce help for problems', async () => {
115115
const result = cli([], {cwd})('foo: bar');
116116
const output = await result;
117117
expect(output.stdout.trim()).toContain(
118-
'Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
118+
'Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
119119
);
120120
expect(result.exitCode).toBe(ExitCode.CommitlintErrorDefault);
121121
});
@@ -124,11 +124,11 @@ test('should produce help for problems with correct helpurl', async () => {
124124
const cwd = await gitBootstrap('fixtures/default');
125125
const result = cli(
126126
['-H https://github.com/conventional-changelog/commitlint/#testhelpurl'],
127-
{cwd}
127+
{cwd},
128128
)('foo: bar');
129129
const output = await result;
130130
expect(output.stdout.trim()).toContain(
131-
'Get help: https://github.com/conventional-changelog/commitlint/#testhelpurl'
131+
'Get help: https://github.com/conventional-changelog/commitlint/#testhelpurl',
132132
);
133133
expect(result.exitCode).toBe(ExitCode.CommitlintErrorDefault);
134134
});
@@ -177,7 +177,7 @@ test('should output help URL defined in config file', async () => {
177177
const result = cli([], {cwd})('foo: bar');
178178
const output = await result;
179179
expect(output.stdout.trim()).toContain(
180-
'Get help: https://www.example.com/foo'
180+
'Get help: https://www.example.com/foo',
181181
);
182182
expect(result.exitCode).toBe(ExitCode.CommitlintErrorDefault);
183183
});
@@ -230,7 +230,7 @@ test('should work with husky via commitlint -e $GIT_PARAMS', async () => {
230230
const cwd = await gitBootstrap('fixtures/husky/integration');
231231
await writePkg(
232232
{husky: {hooks: {'commit-msg': `'${bin}' -e $GIT_PARAMS`}}},
233-
{cwd}
233+
{cwd},
234234
);
235235

236236
// await x('npm', ['install'], { nodeOptions: {cwd}}); // npm install is failing on windows machines
@@ -245,7 +245,7 @@ test('should work with husky via commitlint -e %GIT_PARAMS%', async () => {
245245
const cwd = await gitBootstrap('fixtures/husky/integration');
246246
await writePkg(
247247
{husky: {hooks: {'commit-msg': `'${bin}' -e %GIT_PARAMS%`}}},
248-
{cwd}
248+
{cwd},
249249
);
250250

251251
// await x('npm', ['install'], { nodeOptions: {cwd}}); // npm install is failing on windows machines
@@ -260,7 +260,7 @@ test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async () => {
260260
const cwd = await gitBootstrap('fixtures/husky/integration');
261261
await writePkg(
262262
{husky: {hooks: {'commit-msg': `'${bin}' -e $HUSKY_GIT_PARAMS`}}},
263-
{cwd}
263+
{cwd},
264264
);
265265

266266
// await x('npm', ['install'], { nodeOptions: {cwd}}); // npm install is failing on windows machines
@@ -275,7 +275,7 @@ test('should work with husky via commitlint -e %HUSKY_GIT_PARAMS%', async () =>
275275
const cwd = await gitBootstrap('fixtures/husky/integration');
276276
await writePkg(
277277
{husky: {hooks: {'commit-msg': `'${bin}' -e %HUSKY_GIT_PARAMS%`}}},
278-
{cwd}
278+
{cwd},
279279
);
280280

281281
// await x('npm', ['install'], { nodeOptions: {cwd}}); // npm install is failing on windows machines
@@ -301,7 +301,7 @@ test('should allow reading of environment variables for edit file, failing if in
301301
const cwd = await gitBootstrap('fixtures/simple');
302302
await fs.writeFile(
303303
path.join(cwd, 'commit-msg-file'),
304-
'foo: bar\n\nFoo bar bizz buzz.\n\nCloses #123.'
304+
'foo: bar\n\nFoo bar bizz buzz.\n\nCloses #123.',
305305
);
306306
const result = cli(['--env', 'variable'], {
307307
cwd,
@@ -314,7 +314,7 @@ test('should allow reading of environment variables for edit file, failing if in
314314
test('should pick up parser preset and fail accordingly', async () => {
315315
const cwd = await gitBootstrap('fixtures/parser-preset');
316316
const result = cli(['--parser-preset', './parser-preset'], {cwd})(
317-
'type(scope): subject'
317+
'type(scope): subject',
318318
);
319319
const output = await result;
320320
expect(output.stdout.trim()).toContain('may not be empty');
@@ -324,7 +324,7 @@ test('should pick up parser preset and fail accordingly', async () => {
324324
test('should pick up parser preset and succeed accordingly', async () => {
325325
const cwd = await gitBootstrap('fixtures/parser-preset');
326326
const result = cli(['--parser-preset', './parser-preset'], {cwd})(
327-
'----type(scope): subject'
327+
'----type(scope): subject',
328328
);
329329
await result;
330330
expect(result.exitCode).toBe(ExitCode.CommitlintDefault);
@@ -396,7 +396,7 @@ test("it doesn't use parserOpts.commentChar when using edit mode", async () => {
396396
const cwd = await gitBootstrap('fixtures/comment-char');
397397
await fs.writeFile(
398398
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
399-
'header: foo\n\n$body\n'
399+
'header: foo\n\n$body\n',
400400
);
401401

402402
const result = cli(['--edit', '.git/COMMIT_EDITMSG'], {cwd})();
@@ -412,7 +412,7 @@ test('it uses core.commentChar git config when using edit mode', async () => {
412412
});
413413
await fs.writeFile(
414414
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
415-
'header: foo\n\n$body\n'
415+
'header: foo\n\n$body\n',
416416
);
417417

418418
const result = cli(['--edit', '.git/COMMIT_EDITMSG'], {cwd})();
@@ -425,7 +425,7 @@ test('it falls back to # for core.commentChar when using edit mode', async () =>
425425
const cwd = await gitBootstrap('fixtures/comment-char');
426426
await fs.writeFile(
427427
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
428-
'header: foo\n\n#body\n'
428+
'header: foo\n\n#body\n',
429429
);
430430

431431
const result = cli(['--edit', '.git/COMMIT_EDITMSG'], {cwd})();
@@ -468,7 +468,7 @@ test('should fail for invalid formatters from configuration', async () => {
468468
const result = cli([], {cwd})('foo: bar');
469469
const output = await result;
470470
expect(output.stderr).toContain(
471-
'Using format custom-formatter, but cannot find the module'
471+
'Using format custom-formatter, but cannot find the module',
472472
);
473473
expect(output.stdout.trim()).toEqual('');
474474
expect(result.exitCode).toBe(ExitCode.CommitlintErrorDefault);
@@ -514,7 +514,7 @@ test('should fail for invalid formatters from flags', async () => {
514514
const result = cli(['--format', 'through-flag'], {cwd})('foo: bar');
515515
const output = await result;
516516
expect(output.stderr).toContain(
517-
'Using format through-flag, but cannot find the module'
517+
'Using format through-flag, but cannot find the module',
518518
);
519519
expect(output.stdout.trim()).toEqual('');
520520
expect(result.exitCode).toBe(ExitCode.CommitlintErrorDefault);
@@ -523,11 +523,11 @@ test('should fail for invalid formatters from flags', async () => {
523523
test('should work with absolute formatter path', async () => {
524524
const formatterPath = path.resolve(
525525
__dirname,
526-
'../fixtures/custom-formatter/formatters/custom.js'
526+
'../fixtures/custom-formatter/formatters/custom.js',
527527
);
528528
const cwd = await gitBootstrap('fixtures/custom-formatter');
529529
const result = cli(['--format', formatterPath], {cwd})(
530-
'test: this should work'
530+
'test: this should work',
531531
);
532532
const output = await result;
533533
expect(output.stdout.trim()).toContain('custom-formatter-ok');
@@ -537,10 +537,10 @@ test('should work with absolute formatter path', async () => {
537537
test('should work with relative formatter path', async () => {
538538
const cwd = path.resolve(
539539
await gitBootstrap('fixtures/custom-formatter'),
540-
'./formatters'
540+
'./formatters',
541541
);
542542
const result = cli(['--format', './custom.js'], {cwd})(
543-
'test: this should work'
543+
'test: this should work',
544544
);
545545
const output = await result;
546546
expect(output.stdout.trim()).toContain('custom-formatter-ok');
@@ -665,7 +665,7 @@ describe('should print config', () => {
665665
const result = cli(['--print-config=json', '--no-color'], {cwd})();
666666
const output = await result;
667667
expect(output.stdout.trim()).toMatchInlineSnapshot(
668-
`"{"extends":[],"formatter":"@commitlint/format","plugins":{},"rules":{"type-enum":[2,"never",["foo"]]},"helpUrl":"https://github.com/conventional-changelog/commitlint/#what-is-commitlint","prompt":{}}"`
668+
`"{"extends":[],"formatter":"@commitlint/format","plugins":{},"rules":{"type-enum":[2,"never",["foo"]]},"helpUrl":"https://github.com/conventional-changelog/commitlint/#what-is-commitlint","prompt":{}}"`,
669669
);
670670
});
671671
});

@commitlint/cli/src/cli.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ const cli = yargs(process.argv.slice(2))
144144
.version(
145145
'version',
146146
'display version information',
147-
`${pkg.name}@${pkg.version}`
147+
`${pkg.name}@${pkg.version}`,
148148
)
149149
.alias('v', 'version')
150150
.help('help')
151151
.alias('h', 'help')
152152
.config(
153153
'options',
154154
'path to a JSON file or Common.js module containing CLI options',
155-
require
155+
require,
156156
)
157157
.usage(`${pkg.name}@${pkg.version} - ${pkg.description}\n`)
158158
.usage(
159-
`[input] reads from stdin if --edit, --env, --from and --to are omitted`
159+
`[input] reads from stdin if --edit, --env, --from and --to are omitted`,
160160
)
161161
.strict();
162162

@@ -236,7 +236,7 @@ async function main(args: MainArgs): Promise<void> {
236236
) {
237237
const err = new CliError(
238238
'Please use the --last flag alone. The --last flag should not be used with --to or --from or --edit.',
239-
pkg.name
239+
pkg.name,
240240
);
241241
cli.showHelp('log');
242242
console.log(err.message);
@@ -253,7 +253,7 @@ async function main(args: MainArgs): Promise<void> {
253253
edit: flags.edit,
254254
cwd: flags.cwd,
255255
gitLogArgs: flags['git-log-args'],
256-
}));
256+
}));
257257

258258
const messages = (Array.isArray(input) ? input : [input])
259259
.filter((message) => typeof message === 'string')
@@ -263,7 +263,7 @@ async function main(args: MainArgs): Promise<void> {
263263
if (messages.length === 0 && !checkFromRepository(flags)) {
264264
const err = new CliError(
265265
'[input] is required: supply via stdin, or --env or --edit or --last or --from and --to',
266-
pkg.name
266+
pkg.name,
267267
);
268268
cli.showHelp('log');
269269
console.log(err.message);
@@ -304,7 +304,7 @@ async function main(args: MainArgs): Promise<void> {
304304
if (result.exitCode && result.exitCode > 1) {
305305
console.warn(
306306
'Could not determine core.commentChar git configuration',
307-
output.stderr
307+
output.stderr,
308308
);
309309
opts.parserOpts.commentChar = gitDefaultCommentChar;
310310
} else {
@@ -314,7 +314,7 @@ async function main(args: MainArgs): Promise<void> {
314314
}
315315

316316
const results = await Promise.all(
317-
messages.map((message) => lint(message, loaded.rules, opts))
317+
messages.map((message) => lint(message, loaded.rules, opts)),
318318
);
319319

320320
let isRulesEmpty = false;
@@ -365,7 +365,7 @@ async function main(args: MainArgs): Promise<void> {
365365
errorCount: 0,
366366
warningCount: 0,
367367
results: [],
368-
}
368+
},
369369
);
370370

371371
const helpUrl = flags['help-url']?.trim() || loaded.helpUrl;
@@ -429,7 +429,7 @@ function getEditValue(flags: CliFlags) {
429429
if (flags.env) {
430430
if (!(flags.env in process.env)) {
431431
throw new Error(
432-
`Received '${flags.env}' as value for -E | --env, but environment variable '${flags.env}' is not available globally`
432+
`Received '${flags.env}' as value for -E | --env, but environment variable '${flags.env}' is not available globally`,
433433
);
434434
}
435435
return process.env[flags.env];
@@ -463,15 +463,15 @@ function getEditValue(flags: CliFlags) {
463463
return process.env.HUSKY_GIT_PARAMS;
464464
}
465465
throw new Error(
466-
`Received ${edit} as value for -e | --edit, but GIT_PARAMS or HUSKY_GIT_PARAMS are not available globally.`
466+
`Received ${edit} as value for -e | --edit, but GIT_PARAMS or HUSKY_GIT_PARAMS are not available globally.`,
467467
);
468468
}
469469
return edit;
470470
}
471471

472472
function getSeed(flags: CliFlags): UserConfig {
473473
const n = (flags.extends || []).filter(
474-
(i): i is string => typeof i === 'string'
474+
(i): i is string => typeof i === 'string',
475475
);
476476
return n.length > 0
477477
? {extends: n, parserPreset: flags['parser-preset']}
@@ -492,7 +492,7 @@ function selectParserOpts(parserPreset: ParserPreset | undefined) {
492492

493493
function loadFormatter(
494494
config: QualifiedConfig,
495-
flags: CliFlags
495+
flags: CliFlags,
496496
): Promise<Formatter> {
497497
const moduleName = flags.format || config.formatter || '@commitlint/format';
498498
const modulePath =

@commitlint/config-conventional/src/index.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ test('type-empty', async () => {
149149

150150
test('subject-case', async () => {
151151
const invalidInputs = await Promise.all(
152-
messages.invalidSubjectCases.map((invalidInput) => commitLint(invalidInput))
152+
messages.invalidSubjectCases.map((invalidInput) =>
153+
commitLint(invalidInput),
154+
),
153155
);
154156

155157
invalidInputs.forEach((result) => {
@@ -209,7 +211,7 @@ test('body-max-line-length', async () => {
209211

210212
test('valid messages', async () => {
211213
const validInputs = await Promise.all(
212-
messages.validMessages.map((input) => commitLint(input))
214+
messages.validMessages.map((input) => commitLint(input)),
213215
);
214216

215217
validInputs.forEach((result) => {

@commitlint/config-validator/src/formatErrors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ export function formatErrors(errors: ErrorObject[]): string {
3232
: error.instancePath) || 'Config';
3333
if (error.keyword === 'typeof') {
3434
return `"${field}" should be a ${error.schema}. Value: ${JSON.stringify(
35-
error.data
35+
error.data,
3636
)}`;
3737
}
3838

3939
return `"${field}" ${error.message}. Value: ${JSON.stringify(
40-
error.data
40+
error.data,
4141
)}`;
4242
})
4343
.map((message) => `\t- ${message}.\n`)

@commitlint/config-validator/src/validate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('validation should pass for', () => {
6969
describe('validation should fail for', () => {
7070
test.each(Object.entries(invalidSchemas))('%s', (file, config) => {
7171
expect(() =>
72-
validateConfig(`${file}.js`, config)
72+
validateConfig(`${file}.js`, config),
7373
).toThrowErrorMatchingSnapshot();
7474
});
7575
});

@commitlint/config-validator/src/validate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const Ajv = _Ajv as unknown as typeof _Ajv.default;
2424

2525
export function validateConfig(
2626
source: string,
27-
config: unknown
27+
config: unknown,
2828
): asserts config is UserConfig {
2929
const ajv = new Ajv({
3030
meta: false,
@@ -49,8 +49,8 @@ export function validateConfig(
4949
if (!isValid && validate.errors && validate.errors.length) {
5050
throw new Error(
5151
`Commitlint configuration in ${source} is invalid:\n${formatErrors(
52-
validate.errors
53-
)}`
52+
validate.errors,
53+
)}`,
5454
);
5555
}
5656
}

0 commit comments

Comments
 (0)