Skip to content

Commit

Permalink
fix: disable some unwanted validations
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Jan 10, 2021
1 parent 6f00690 commit a7f92d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
12 changes: 5 additions & 7 deletions @commitlint/load/src/utils/load-parser-opts.ts
@@ -1,10 +1,5 @@
import {ParserPreset} from '@commitlint/types';
import {
isObjectLike,
isParserOptsFunction,
isPromiseLike,
validateParser,
} from './validators';
import {isObjectLike, isParserOptsFunction, isPromiseLike} from './validators';

export async function loadParser(
pendingParser: unknown
Expand All @@ -15,7 +10,9 @@ export async function loadParser(
// Await for the module, loaded with require
const parser = await pendingParser;

validateParser(parser);
if (!isObjectLike(parser)) {
throw new Error('Invalid configuration, `parserPreset` must be an object');
}

// Await parser opts if applicable
if (isPromiseLike(parser.parserOpts)) {
Expand All @@ -26,6 +23,7 @@ export async function loadParser(
// Create parser opts from factory
if (
isParserOptsFunction(parser) &&
typeof parser.name === 'string' &&
parser.name.startsWith('conventional-changelog-')
) {
return new Promise((resolve) => {
Expand Down
14 changes: 0 additions & 14 deletions @commitlint/load/src/utils/validators.ts
Expand Up @@ -56,17 +56,3 @@ export function validateConfig(
throw new Error('Invalid configuration, `helpUrl` must be a string');
}
}

export function validateParser(
parser: unknown
): asserts parser is {name: string; path: string; [key: string]: unknown} {
if (!isObjectLike(parser)) {
throw new Error('Invalid configuration, parserPreset must be an object');
}
if (typeof parser.name !== 'string') {
throw new Error('Invalid configuration, parserPreset must have a name');
}
if (typeof parser.path !== 'string') {
throw new Error('Invalid configuration, parserPreset must have a name');
}
}
4 changes: 2 additions & 2 deletions @commitlint/types/src/load.ts
Expand Up @@ -48,7 +48,7 @@ export interface QualifiedConfig {
}

export interface ParserPreset {
name: string;
path: string;
name?: string;
path?: string;
parserOpts?: unknown;
}

0 comments on commit a7f92d8

Please sign in to comment.