Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions @commitlint/ensure/src/case.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
import * as _ from 'lodash';
import _ from 'lodash';
import {TargetCaseType} from '.';

export default ensureCase;

export type TargetCaseType =
| 'camel-case'
| 'kebab-case'
| 'snake-case'
| 'pascal-case'
| 'start-case'
| 'upper-case'
| 'uppercase'
| 'sentence-case'
| 'sentencecase'
| 'lower-case'
| 'lowercase'
| 'lowerCase';

function ensureCase(
raw: string = '',
target: TargetCaseType = 'lowercase'
Expand Down
6 changes: 5 additions & 1 deletion @commitlint/ensure/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {camelCase, values} from 'lodash';
import * as ensure from '.';

test('exports all checkers', async () => {
const expected = (await glob('*.ts')).map(f => camelCase(f)).sort();
const ignore = ['types'];
const expected = (await glob('*.ts'))
.map(f => camelCase(f))
.sort()
.filter(item => !ignore.includes(item));
const actual = Object.keys(ensure).sort();
expect(actual).toEqual(expected);
Copy link
Contributor

@armano2 armano2 Feb 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(actual).toEqual(expected);
expect(actual).toMatchObject(expected);

and you should be able to remove sorting

test('exports all checkers', async () => { const ignore = ['types']; const expected = (await glob('*.ts')) .map(f => camelCase(f)) .filter(item => !ignore.includes(item)); const actual = Object.keys(ensure); expect(actual).toMatchObject(expected); });

toMatchObject works on arrays

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know! I go with the current approach as this is supposed to test if we forgot to reexport any checker from the directory. So failing for a new file that is not exported from index.js is the expected behavior

});
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/ensure/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import ensureCase, {TargetCaseType} from './case';
import ensureCase from './case';
import ensureEnum from './enum';
import maxLength from './max-length';
import maxLineLength from './max-line-length';
import minLength from './min-length';
import notEmpty from './not-empty';

export * from './types';
export {ensureCase as case};
export {ensureEnum as enum};
export {TargetCaseType};
export {maxLength, maxLineLength, minLength, notEmpty};
13 changes: 13 additions & 0 deletions @commitlint/ensure/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type TargetCaseType =
| 'camel-case'
| 'kebab-case'
| 'snake-case'
| 'pascal-case'
| 'start-case'
| 'upper-case'
| 'uppercase'
| 'sentence-case'
| 'sentencecase'
| 'lower-case'
| 'lowercase'
| 'lowerCase';
9 changes: 2 additions & 7 deletions @commitlint/ensure/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"rootDir": "./src",
"outDir": "./lib"
},
"include": [
"./src"
],
"exclude": [
"./src/**/*.test.ts",
"./lib/**/*"
]
"include": ["./src/**/*.ts"],
"exclude": ["./src/**/*.test.ts", "./lib/**/*"]
}
3 changes: 1 addition & 2 deletions @commitlint/is-ignored/src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as semver from 'semver';

export type Matcher = (commit: string) => boolean;
import {Matcher} from './types';

const isSemver = (c: string): boolean => {
const firstLine = c.split('\n').shift();
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/is-ignored/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './is-ignored';
export {Matcher} from './defaults';
export * from './types';
7 changes: 4 additions & 3 deletions @commitlint/is-ignored/src/is-ignored.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as Defaults from './defaults';
import {wildcards} from './defaults';
import {Matcher} from './types';

export interface IsIgnoredOptions {
ignores?: Defaults.Matcher[];
ignores?: Matcher[];
defaults?: boolean;
}

Expand All @@ -27,6 +28,6 @@ export default function isIgnored(
);
}

const base = opts.defaults === false ? [] : Defaults.wildcards;
const base = opts.defaults === false ? [] : wildcards;
return [...base, ...ignores].some(w => w(commit));
}
1 change: 1 addition & 0 deletions @commitlint/is-ignored/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Matcher = (commit: string) => boolean;
2 changes: 1 addition & 1 deletion @commitlint/is-ignored/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outDir": "./lib"
},
"include": [
"./src"
"./src/**/*.ts"
],
"exclude": [
"./src/**/*.test.ts",
Expand Down
1 change: 0 additions & 1 deletion @commitlint/load/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"dependencies": {
"@commitlint/execute-rule": "^8.3.4",
"@commitlint/resolve-extends": "^8.3.5",
"@commitlint/rules": "^8.3.4",
"chalk": "3.0.0",
"cosmiconfig": "^6.0.0",
"lodash": "^4.17.15",
Expand Down
3 changes: 1 addition & 2 deletions @commitlint/load/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {TargetCaseType} from '@commitlint/ensure';
import {RuleCondition} from '@commitlint/rules';

export {RuleCondition} from '@commitlint/rules';
export type RuleCondition = 'always' | 'never';

export type PluginRecords = Record<string, unknown>;

Expand Down
3 changes: 1 addition & 2 deletions @commitlint/load/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
],
"references": [
{ "path": "../execute-rule" },
{ "path": "../resolve-extends" },
{ "path": "../rules" }
{ "path": "../resolve-extends" }
]
}
4 changes: 3 additions & 1 deletion tsconfig.shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"noUnusedParameters": true,
"forceConsistentCasingInFileNames": true,
"keyofStringsOnly": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"isolatedModules": true,
"skipLibCheck": true
}
}