Skip to content

refactor: port message to typescript #765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 3 additions & 30 deletions @commitlint/message/package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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'
);
});
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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