Skip to content

Commit

Permalink
refactor: port message to typescript (#765)
Browse files Browse the repository at this point in the history
* refactor: port message to typescript

* refactor(message): add strict input typing
  • Loading branch information
byCedric committed Sep 11, 2019
1 parent 756a333 commit a9f98e0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 45 deletions.
33 changes: 3 additions & 30 deletions @commitlint/message/package.json
Expand Up @@ -3,35 +3,13 @@
"version": "8.1.0",
"description": "Lint your commit messages",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib/"
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"deps": "dep-check",
"pkg": "pkg-check",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
"test": "ava -c 4 --verbose",
"watch": "babel src --out-dir lib --watch --source-maps"
},
"ava": {
"files": [
"src/**/*.test.js",
"!lib/**/*"
],
"source": [
"src/**/*.js",
"!lib/**/*"
],
"babel": "inherit",
"require": [
"babel-register"
]
},
"babel": {
"presets": [
"babel-preset-commitlint"
]
"pkg": "pkg-check"
},
"engines": {
"node": ">=4"
Expand All @@ -58,11 +36,6 @@
"devDependencies": {
"@commitlint/test": "8.0.0",
"@commitlint/utils": "^8.1.0",
"ava": "0.22.0",
"babel-cli": "6.26.0",
"babel-preset-commitlint": "^8.0.0",
"babel-register": "6.26.0",
"concurrently": "3.6.1",
"cross-env": "5.1.1"
"typescript": "3.5.3"
}
}
14 changes: 0 additions & 14 deletions @commitlint/message/src/index.test.js

This file was deleted.

15 changes: 15 additions & 0 deletions @commitlint/message/src/index.test.ts
@@ -0,0 +1,15 @@
import message from '.';

test('should return an empty string for empty input', () => {
expect(message()).toBe('');
});

test('should return an empty string for empty input array', () => {
expect(message([])).toBe('');
});

test('should filter falsy values', () => {
expect(message([null, 'some', undefined, 'message', null])).toBe(
'some message'
);
});
@@ -1,5 +1,5 @@
export default message;

function message(input = []) {
function message(input: (string | null | undefined)[] = []) {
return input.filter(Boolean).join(' ');
}
15 changes: 15 additions & 0 deletions @commitlint/message/tsconfig.json
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.shared.json",
"compilerOptions": {
"composite": true,
"rootDir": "./src",
"outDir": "./lib"
},
"include": [
"./src"
],
"exclude": [
"./src/**/*.test.ts",
"./lib/**/*"
]
}
1 change: 1 addition & 0 deletions tsconfig.json
Expand Up @@ -7,6 +7,7 @@
{ "path": "@commitlint/execute-rule" },
{ "path": "@commitlint/format" },
{ "path": "@commitlint/is-ignored" },
{ "path": "@commitlint/message" },
{ "path": "@commitlint/parse" },
{ "path": "@commitlint/resolve-extends" },
{ "path": "@commitlint/to-lines" },
Expand Down

0 comments on commit a9f98e0

Please sign in to comment.