Skip to content

Commit

Permalink
chore: prettier v2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Aug 9, 2023
1 parent ae55dd9 commit 173d416
Show file tree
Hide file tree
Showing 99 changed files with 357 additions and 357 deletions.
52 changes: 26 additions & 26 deletions @commitlint/cli/src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test('should produce help for problems', async () => {
const cwd = await gitBootstrap('fixtures/default');
const actual = await cli([], {cwd})('foo: bar');
expect(actual.stdout).toContain(
'Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
'Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
);
expect(actual.exitCode).toBe(1);
});
Expand All @@ -78,10 +78,10 @@ test('should produce help for problems with correct helpurl', async () => {
const cwd = await gitBootstrap('fixtures/default');
const actual = await cli(
['-H https://github.com/conventional-changelog/commitlint/#testhelpurl'],
{cwd},
{cwd}
)('foo: bar');
expect(actual.stdout).toContain(
'Get help: https://github.com/conventional-changelog/commitlint/#testhelpurl',
'Get help: https://github.com/conventional-changelog/commitlint/#testhelpurl'
);
expect(actual.exitCode).toBe(1);
});
Expand Down Expand Up @@ -152,7 +152,7 @@ test('should work with husky commitmsg hook and git commit', async () => {
const commit = await execa(
'git',
['commit', '-m', '"test: this should work"'],
{cwd},
{cwd}
);

expect(commit).toBeTruthy();
Expand All @@ -168,7 +168,7 @@ test('should work with husky commitmsg hook in sub packages', async () => {
const commit = await execa(
'git',
['commit', '-m', '"test: this should work"'],
{cwd},
{cwd}
);
expect(commit).toBeTruthy();
});
Expand All @@ -177,15 +177,15 @@ test('should work with husky via commitlint -e $GIT_PARAMS', async () => {
const cwd = await gitBootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e $GIT_PARAMS`}}},
{cwd},
{cwd}
);

// await execa('npm', ['install'], {cwd}); // npm install is failing on windows machines
await execa('git', ['add', 'package.json'], {cwd});
const commit = await execa(
'git',
['commit', '-m', '"test: this should work"'],
{cwd},
{cwd}
);
expect(commit).toBeTruthy();
});
Expand All @@ -194,15 +194,15 @@ test('should work with husky via commitlint -e %GIT_PARAMS%', async () => {
const cwd = await gitBootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e %GIT_PARAMS%`}}},
{cwd},
{cwd}
);

// await execa('npm', ['install'], {cwd}); // npm install is failing on windows machines
await execa('git', ['add', 'package.json'], {cwd});
const commit = await execa(
'git',
['commit', '-m', '"test: this should work"'],
{cwd},
{cwd}
);
expect(commit).toBeTruthy();
});
Expand All @@ -211,15 +211,15 @@ test('should work with husky via commitlint -e $HUSKY_GIT_PARAMS', async () => {
const cwd = await gitBootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e $HUSKY_GIT_PARAMS`}}},
{cwd},
{cwd}
);

// await execa('npm', ['install'], {cwd}); // npm install is failing on windows machines
await execa('git', ['add', 'package.json'], {cwd});
const commit = await execa(
'git',
['commit', '-m', '"test: this should work"'],
{cwd},
{cwd}
);
expect(commit).toBeTruthy();
});
Expand All @@ -228,15 +228,15 @@ test('should work with husky via commitlint -e %HUSKY_GIT_PARAMS%', async () =>
const cwd = await gitBootstrap('fixtures/husky/integration');
await writePkg(
{husky: {hooks: {'commit-msg': `'${bin}' -e %HUSKY_GIT_PARAMS%`}}},
{cwd},
{cwd}
);

// await execa('npm', ['install'], {cwd}); // npm install is failing on windows machines
await execa('git', ['add', 'package.json'], {cwd});
const commit = await execa(
'git',
['commit', '-m', '"test: this should work"'],
{cwd},
{cwd}
);
expect(commit).toBeTruthy();
});
Expand All @@ -255,7 +255,7 @@ test('should allow reading of environment variables for edit file, failing if in
const cwd = await gitBootstrap('fixtures/simple');
await fs.writeFile(
path.join(cwd, 'commit-msg-file'),
'foo: bar\n\nFoo bar bizz buzz.\n\nCloses #123.',
'foo: bar\n\nFoo bar bizz buzz.\n\nCloses #123.'
);
const actual = await cli(['--env', 'variable'], {
cwd,
Expand All @@ -267,7 +267,7 @@ test('should allow reading of environment variables for edit file, failing if in
test('should pick up parser preset and fail accordingly', async () => {
const cwd = await gitBootstrap('fixtures/parser-preset');
const actual = await cli(['--parser-preset', './parser-preset'], {cwd})(
'type(scope): subject',
'type(scope): subject'
);
expect(actual.exitCode).toBe(1);
expect(actual.stdout).toContain('may not be empty');
Expand All @@ -276,7 +276,7 @@ test('should pick up parser preset and fail accordingly', async () => {
test('should pick up parser preset and succeed accordingly', async () => {
const cwd = await gitBootstrap('fixtures/parser-preset');
const actual = await cli(['--parser-preset', './parser-preset'], {cwd})(
'----type(scope): subject',
'----type(scope): subject'
);
expect(actual.exitCode).toBe(0);
});
Expand Down Expand Up @@ -322,7 +322,7 @@ test('should handle --amend with signoff', async () => {
await execa(
'git',
['commit', '-m', '"test: this should work"', '--signoff'],
{cwd},
{cwd}
);
const commit = await execa('git', ['commit', '--amend', '--no-edit'], {cwd});

Expand All @@ -342,7 +342,7 @@ test("it doesn't use parserOpts.commentChar when using edit mode", async () => {
const cwd = await gitBootstrap('fixtures/comment-char');
await fs.writeFile(
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
'header: foo\n\n$body\n',
'header: foo\n\n$body\n'
);

const actual = await cli(['--edit', '.git/COMMIT_EDITMSG'], {cwd})();
Expand All @@ -355,7 +355,7 @@ test('it uses core.commentChar git config when using edit mode', async () => {
await execa('git', ['config', '--local', 'core.commentChar', '$'], {cwd});
await fs.writeFile(
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
'header: foo\n\n$body\n',
'header: foo\n\n$body\n'
);

const actual = await cli(['--edit', '.git/COMMIT_EDITMSG'], {cwd})();
Expand All @@ -367,7 +367,7 @@ test('it falls back to # for core.commentChar when using edit mode', async () =>
const cwd = await gitBootstrap('fixtures/comment-char');
await fs.writeFile(
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
'header: foo\n\n#body\n',
'header: foo\n\n#body\n'
);

const actual = await cli(['--edit', '.git/COMMIT_EDITMSG'], {cwd})();
Expand Down Expand Up @@ -408,7 +408,7 @@ test('should fail for invalid formatters from configuration', async () => {
const actual = await cli([], {cwd})('foo: bar');

expect(actual.stderr).toContain(
'Using format custom-formatter, but cannot find the module',
'Using format custom-formatter, but cannot find the module'
);
expect(actual.stdout).toEqual('');
expect(actual.exitCode).toBe(1);
Expand Down Expand Up @@ -449,7 +449,7 @@ test('should fail for invalid formatters from flags', async () => {
const actual = await cli(['--format', 'through-flag'], {cwd})('foo: bar');

expect(actual.stderr).toContain(
'Using format through-flag, but cannot find the module',
'Using format through-flag, but cannot find the module'
);
expect(actual.stdout).toEqual('');
expect(actual.exitCode).toBe(1);
Expand All @@ -458,11 +458,11 @@ test('should fail for invalid formatters from flags', async () => {
test('should work with absolute formatter path', async () => {
const formatterPath = path.resolve(
__dirname,
'../fixtures/custom-formatter/formatters/custom.js',
'../fixtures/custom-formatter/formatters/custom.js'
);
const cwd = await gitBootstrap('fixtures/custom-formatter');
const actual = await cli(['--format', formatterPath], {cwd})(
'test: this should work',
'test: this should work'
);

expect(actual.stdout).toContain('custom-formatter-ok');
Expand All @@ -472,10 +472,10 @@ test('should work with absolute formatter path', async () => {
test('should work with relative formatter path', async () => {
const cwd = path.resolve(
await gitBootstrap('fixtures/custom-formatter'),
'./formatters',
'./formatters'
);
const actual = await cli(['--format', './custom.js'], {cwd})(
'test: this should work',
'test: this should work'
);

expect(actual.stdout).toContain('custom-formatter-ok');
Expand Down
18 changes: 9 additions & 9 deletions @commitlint/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ const cli = yargs
.version(
'version',
'display version information',
`${pkg.name}@${pkg.version}`,
`${pkg.name}@${pkg.version}`
)
.alias('v', 'version')
.help('help')
.alias('h', 'help')
.usage(`${pkg.name}@${pkg.version} - ${pkg.description}\n`)
.usage(
`[input] reads from stdin if --edit, --env, --from and --to are omitted`,
`[input] reads from stdin if --edit, --env, --from and --to are omitted`
)
.strict();

Expand Down Expand Up @@ -204,7 +204,7 @@ async function main(args: MainArgs): Promise<void> {
if (messages.length === 0 && !checkFromRepository(flags)) {
const err = new CliError(
'[input] is required: supply via stdin, or --env or --edit or --from and --to',
pkg.name,
pkg.name
);
yargs.showHelp('log');
console.log(err.message);
Expand Down Expand Up @@ -249,15 +249,15 @@ async function main(args: MainArgs): Promise<void> {
if (!execaError.failed || execaError.exitCode !== 1) {
console.warn(
'Could not determine core.commentChar git configuration',
e,
e
);
}
opts.parserOpts.commentChar = gitDefaultCommentChar;
}
}

const results = await Promise.all(
messages.map((message) => lint(message, loaded.rules, opts)),
messages.map((message) => lint(message, loaded.rules, opts))
);

if (Object.keys(loaded.rules).length === 0) {
Expand Down Expand Up @@ -305,7 +305,7 @@ async function main(args: MainArgs): Promise<void> {
errorCount: 0,
warningCount: 0,
results: [],
},
}
);

const helpUrl = flags['help-url']?.trim() || loaded.helpUrl;
Expand Down Expand Up @@ -361,7 +361,7 @@ function getEditValue(flags: CliFlags) {
if (flags.env) {
if (!(flags.env in process.env)) {
throw new Error(
`Received '${flags.env}' as value for -E | --env, but environment variable '${flags.env}' is not available globally`,
`Received '${flags.env}' as value for -E | --env, but environment variable '${flags.env}' is not available globally`
);
}
return process.env[flags.env];
Expand Down Expand Up @@ -395,15 +395,15 @@ function getEditValue(flags: CliFlags) {
return process.env.HUSKY_GIT_PARAMS;
}
throw new Error(
`Received ${edit} as value for -e | --edit, but GIT_PARAMS or HUSKY_GIT_PARAMS are not available globally.`,
`Received ${edit} as value for -e | --edit, but GIT_PARAMS or HUSKY_GIT_PARAMS are not available globally.`
);
}
return edit;
}

function getSeed(flags: CliFlags): UserConfig {
const n = (flags.extends || []).filter(
(i): i is string => typeof i === 'string',
(i): i is string => typeof i === 'string'
);
return n.length > 0
? {extends: n, parserPreset: flags['parser-preset']}
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-validator/src/formatErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export function formatErrors(errors: ErrorObject[]): string {
: error.instancePath) || 'Config';
if (error.keyword === 'typeof') {
return `"${field}" should be a ${error.schema}. Value: ${JSON.stringify(
error.data,
error.data
)}`;
}

return `"${field}" ${error.message}. Value: ${JSON.stringify(
error.data,
error.data
)}`;
})
.map((message) => `\t- ${message}.\n`)
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/config-validator/src/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('validation should pass for', () => {
describe('validation should fail for', () => {
test.each(Object.entries(invalidSchemas))('%s', (file, config) => {
expect(() =>
validateConfig(`${file}.js`, config),
validateConfig(`${file}.js`, config)
).toThrowErrorMatchingSnapshot();
});
});
6 changes: 3 additions & 3 deletions @commitlint/config-validator/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TYPE_OF = [

export function validateConfig(
source: string,
config: unknown,
config: unknown
): asserts config is UserConfig {
const ajv = new Ajv({
meta: false,
Expand All @@ -40,8 +40,8 @@ export function validateConfig(
if (!isValid && validate.errors && validate.errors.length) {
throw new Error(
`Commitlint configuration in ${source} is invalid:\n${formatErrors(
validate.errors,
)}`,
validate.errors
)}`
);
}
}
8 changes: 4 additions & 4 deletions @commitlint/cz-commitlint/src/Process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ describe('conventional-changlog', () => {
return process(rules as any, prompts, InquirerFactory(answers) as any).then(
(commitMessage) => {
expect(commitMessage).toBe(
'refactor(prompt): refactor prompt based on inquirer\n\ninspired by commitizen/cz-conventional-changelog\n\nBREAKING CHANGE: refactor types\nhttps://github.com/conventional-changelog/commitlint/issues/94',
'refactor(prompt): refactor prompt based on inquirer\n\ninspired by commitizen/cz-conventional-changelog\n\nBREAKING CHANGE: refactor types\nhttps://github.com/conventional-changelog/commitlint/issues/94'
);
},
}
);
});

Expand All @@ -234,10 +234,10 @@ describe('conventional-changlog', () => {
return process(rules as any, prompts, InquirerFactory(answers) as any).then(
() => {
expect(mockShowValidation).toHaveBeenCalledWith(
'subject can not be empty',
'subject can not be empty'
);
expect(mockShowTitle).toHaveBeenCalledTimes(3);
},
}
);
});
});
2 changes: 1 addition & 1 deletion @commitlint/cz-commitlint/src/Process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {setRules} from './store/rules';
export default async function (
rules: QualifiedRules,
prompts: UserPromptConfig,
inquirer: Inquirer,
inquirer: Inquirer
): Promise<string> {
setRules(rules);
setPromptConfig(prompts);
Expand Down
Loading

0 comments on commit 173d416

Please sign in to comment.