Skip to content

Commit d32a641

Browse files
committed
wip: combine ts port and opts factory fix
2 parents c705cd4 + 0f8a4db commit d32a641

21 files changed

+921
-655
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ insert_final_newline = true
44
trim_trailing_whitespace = true
55
indent_style = tab
66

7-
[{.*rc,*.yml,*.md,package.json,lerna.json,*.svg}]
7+
[{.*rc,*.yml,*.md,package.json,lerna.json,tsconfig.json,tsconfig.*.json,*.svg}]
88
indent_style = space
99

1010
[*.md]

@commitlint/cli/src/cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
require('babel-polyfill'); // eslint-disable-line import/no-unassigned-import
33

4-
const load = require('@commitlint/load');
4+
import load from '@commitlint/load';
55
const lint = require('@commitlint/lint');
66
const read = require('@commitlint/read');
77
const meow = require('meow');

@commitlint/ensure/src/case.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
22

33
export default ensureCase;
44

5-
type TargetCaseType =
5+
export type TargetCaseType =
66
| 'camel-case'
77
| 'kebab-case'
88
| 'snake-case'

@commitlint/ensure/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import ensureCase from './case';
1+
import ensureCase, {TargetCaseType} from './case';
22
import ensureEnum from './enum';
33
import maxLength from './max-length';
44
import maxLineLength from './max-line-length';
55
import minLength from './min-length';
66
import notEmpty from './not-empty';
77

88
export {ensureCase as case};
9+
export {TargetCaseType};
910
export {ensureEnum as enum};
1011
export {maxLength, maxLineLength, minLength, notEmpty};

@commitlint/execute-rule/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type ExecutedRule<T> = readonly [string, T];
77
export default execute;
88

99
export async function execute<T = unknown>(
10-
rule: Rule<T>
10+
rule?: Rule<T>
1111
): Promise<ExecutedRule<T> | null> {
1212
if (!Array.isArray(rule)) {
1313
return null;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
rules: {
3-
basic: true
3+
'body-case': [1, 'never', 'camel-case']
44
}
55
};

@commitlint/load/package.json

+9-33
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,13 @@
33
"version": "8.3.1",
44
"description": "Load shared commitlint configuration",
55
"main": "lib/index.js",
6+
"types": "lib/index.d.ts",
67
"files": [
78
"lib/"
89
],
910
"scripts": {
10-
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
1111
"deps": "dep-check",
12-
"pkg": "pkg-check --skip-import",
13-
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
14-
"test": "ava -c 4 --verbose && ava \"src/*.serial-test.js\" --verbose",
15-
"watch": "babel src --out-dir lib --watch --source-maps"
16-
},
17-
"ava": {
18-
"files": [
19-
"src/**/*.test.js",
20-
"!lib/**/*"
21-
],
22-
"source": [
23-
"src/**/*.js",
24-
"!lib/**/*"
25-
],
26-
"babel": "inherit",
27-
"require": [
28-
"babel-register"
29-
]
30-
},
31-
"babel": {
32-
"presets": [
33-
"babel-preset-commitlint"
34-
]
12+
"pkg": "pkg-check --skip-import"
3513
},
3614
"engines": {
3715
"node": ">=4"
@@ -58,21 +36,19 @@
5836
"devDependencies": {
5937
"@commitlint/test": "8.2.0",
6038
"@commitlint/utils": "^8.3.0",
61-
"ava": "0.22.0",
62-
"babel-cli": "6.26.0",
63-
"babel-preset-commitlint": "^8.2.0",
64-
"babel-register": "6.26.0",
65-
"concurrently": "3.6.1",
66-
"cross-env": "6.0.0",
67-
"execa": "0.11.0",
68-
"globby": "10.0.1"
39+
"@types/cosmiconfig": "5.0.3",
40+
"@types/lodash": "4.14.136",
41+
"@types/resolve-from": "^5.0.1",
42+
"typescript": "3.5.3"
6943
},
7044
"dependencies": {
45+
"@commitlint/ensure": "^8.3.0",
7146
"@commitlint/execute-rule": "^8.3.0",
7247
"@commitlint/resolve-extends": "^8.3.0",
73-
"babel-runtime": "^6.23.0",
48+
"@types/execa": "^2.0.0",
7449
"chalk": "2.4.2",
7550
"cosmiconfig": "^5.2.0",
51+
"execa": "^3.2.0",
7652
"lodash": "4.17.15",
7753
"resolve-from": "^5.0.0"
7854
}

@commitlint/load/src/index.js

-156
This file was deleted.

@commitlint/load/src/index.serial-test.js

-19
This file was deleted.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as path from 'path';
2+
import load from '.';
3+
4+
const {fix} = require('@commitlint/test');
5+
6+
const fixture = (name: string) => path.resolve(__dirname, '../fixtures', name);
7+
8+
test('default cwd option to process.cwd()', async () => {
9+
const cwd = await fix.bootstrap(fixture('basic'));
10+
const before = process.cwd();
11+
process.chdir(cwd);
12+
13+
try {
14+
const actual = await load();
15+
expect(actual.rules['body-case']).toBeTruthy();
16+
} catch (err) {
17+
throw err;
18+
} finally {
19+
process.chdir(before);
20+
}
21+
});

0 commit comments

Comments
 (0)