Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2e9d32f

Browse files
committedJul 27, 2019
refactor: port message to typescript
1 parent 6332d97 commit 2e9d32f

File tree

6 files changed

+34
-46
lines changed

6 files changed

+34
-46
lines changed
 

‎@commitlint/message/package.json

+3-30
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,13 @@
33
"version": "8.1.0",
44
"description": "Lint your commit messages",
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",
13-
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
14-
"test": "ava -c 4 --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"
3513
},
3614
"engines": {
3715
"node": ">=4"
@@ -58,11 +36,6 @@
5836
"devDependencies": {
5937
"@commitlint/test": "8.0.0",
6038
"@commitlint/utils": "^8.1.0",
61-
"ava": "0.22.0",
62-
"babel-cli": "6.26.0",
63-
"babel-preset-commitlint": "^8.0.0",
64-
"babel-register": "6.26.0",
65-
"concurrently": "3.6.1",
66-
"cross-env": "5.1.1"
39+
"typescript": "3.5.3"
6740
}
6841
}

‎@commitlint/message/src/index.test.js

-14
This file was deleted.

‎@commitlint/message/src/index.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import message from '.';
2+
3+
test('should return an empty string for empty input', () => {
4+
expect(message()).toBe('');
5+
});
6+
7+
test('should return an empty string for empty input array', () => {
8+
expect(message([])).toBe('');
9+
});
10+
11+
test('should filter falsy values', () => {
12+
expect(message([null, 'some', null, 'message', null])).toBe('some message');
13+
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default message;
22

3-
function message(input = []) {
3+
function message(input: any[] = []) {
44
return input.filter(Boolean).join(' ');
55
}

‎@commitlint/message/tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "../../tsconfig.shared.json",
3+
"compilerOptions": {
4+
"composite": true,
5+
"rootDir": "./src",
6+
"outDir": "./lib"
7+
},
8+
"include": [
9+
"./src"
10+
],
11+
"exclude": [
12+
"./src/**/*.test.ts",
13+
"./lib/**/*"
14+
]
15+
}

‎tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
{ "path": "@commitlint/execute-rule" },
88
{ "path": "@commitlint/format" },
99
{ "path": "@commitlint/is-ignored" },
10+
{ "path": "@commitlint/message" },
1011
{ "path": "@commitlint/resolve-extends" },
1112
{ "path": "@commitlint/to-lines" },
1213
{ "path": "@commitlint/top-level" },
1314
]
14-
}
15+
}

0 commit comments

Comments
 (0)
Please sign in to comment.