Skip to content

Commit

Permalink
test(load): recursive extends with ts file
Browse files Browse the repository at this point in the history
  • Loading branch information
songhn233 authored and AdeAttwood committed Aug 12, 2021
1 parent 08f64f9 commit 885bd8a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type {UserConfig} from './types';

const Configuration: UserConfig = {
extends: ['./first-extended'],
rules: {
zero: [0, 'never', 'zero']
}
};
module.exports = Configuration;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type {UserConfig} from '../types';
module.exports = {
extends: ['./second-extended'],
rules: {
one: [1, 'never', 'one']
}
} as UserConfig;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type {UserConfig} from '../../types';
module.exports = {
rules: {
two: [2, 'never', 'two']
}
} as UserConfig;
11 changes: 11 additions & 0 deletions @commitlint/load/fixtures/recursive-extends-ts/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface UserConfig {
extends?: string[];
formatter?: string;
rules?: any;
parserPreset?: any;
ignores?: ((commit: string) => boolean)[];
defaultIgnores?: boolean;
plugins?: (string | Plugin)[];
helpUrl?: string;
prompt?: any;
}
16 changes: 16 additions & 0 deletions @commitlint/load/src/load.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,22 @@ test('recursive extends with package.json file', async () => {
});
});

test('recursive extends with ts file', async () => {
const cwd = await gitBootstrap('fixtures/recursive-extends-ts');
const actual = await load({}, {cwd});

expect(actual).toMatchObject({
formatter: '@commitlint/format',
extends: ['./first-extended'],
plugins: {},
rules: {
zero: [0, 'never', 'zero'],
one: [1, 'never', 'one'],
two: [2, 'never', 'two'],
},
});
});

test('parser preset overwrites completely instead of merging', async () => {
const cwd = await gitBootstrap('fixtures/parser-preset-override');
const actual = await load({}, {cwd});
Expand Down

0 comments on commit 885bd8a

Please sign in to comment.