Skip to content

Commit

Permalink
refactor: port to-lines to ts (#677)
Browse files Browse the repository at this point in the history
* refactor(to-lines): port to-lines src and tests to ts

* build(to-lines): add ts dependencies and remove ava, babel config, dep

* chore(to-lines): update yarn lock due to @commitlint/to-lines dep change
  • Loading branch information
bendtherules authored and marionebl committed Jun 3, 2019
1 parent 4360d56 commit c102d2f
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 67 deletions.
4 changes: 4 additions & 0 deletions @commitlint/to-lines/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
};
39 changes: 9 additions & 30 deletions @commitlint/to-lines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,12 @@
"lib/"
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"build": "tsc",
"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"
]
"start": "concurrently \"yarn test --watchAll\" \"yarn run watch\"",
"test": "jest",
"watch": "tsc -w"
},
"engines": {
"node": ">=4"
Expand All @@ -57,13 +38,11 @@
"license": "MIT",
"devDependencies": {
"@commitlint/parse": "^8.0.0",
"@commitlint/test": "8.0.0",
"@commitlint/utils": "^8.0.0",
"ava": "0.22.0",
"babel-cli": "6.26.0",
"babel-preset-commitlint": "^8.0.0",
"babel-register": "6.26.0",
"concurrently": "3.5.1",
"cross-env": "5.1.1"
"@types/jest": "^24.0.13",
"jest": "^24.8.0",
"ts-jest": "^24.0.2",
"typescript": "^3.4.5"
}
}
}
22 changes: 0 additions & 22 deletions @commitlint/to-lines/src/index.test.js

This file was deleted.

21 changes: 21 additions & 0 deletions @commitlint/to-lines/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import toLines from '.';

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

test('should return an array for null input', () => {
expect((toLines as (input: any) => string[])(null)).toStrictEqual([]);
});

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

test('should split LF newlines', () => {
expect(toLines('some\nweird\ntext')).toStrictEqual(['some', 'weird', 'text']);
});

test('should split CR+LF newlines', () => {
expect(toLines('some\r\nweird\r\ntext')).toStrictEqual(['some', 'weird', 'text']);
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function toLines(input) {
export default function toLines(input: string): string[] {
if (typeof input !== 'string') {
return [];
}
Expand Down
22 changes: 22 additions & 0 deletions @commitlint/to-lines/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"lib": [
"dom",
"es2015"
],
"rootDir": "src",
"outDir": "lib",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": [
"./src"
],
"exclude": [
"./src/**/*.test.ts"
]
}
18 changes: 4 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@
version "20.0.1"
resolved "https://registry.npmjs.org/@types/jest-diff/-/jest-diff-20.0.1.tgz#35cc15b9c4f30a18ef21852e255fdb02f6d59b89"

"@types/[email protected]":
"@types/[email protected]", "@types/jest@^24.0.13":
version "24.0.13"
resolved "https://registry.npmjs.org/@types/jest/-/jest-24.0.13.tgz#10f50b64cb05fb02411fbba49e9042a3a11da3f9"
dependencies:
Expand All @@ -1079,7 +1079,6 @@
"@types/[email protected]":
version "4.14.133"
resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.133.tgz#430721c96da22dd1694443e68e6cec7ba1c1003d"
integrity sha512-/3JqnvPnY58GLzG3Y7fpphOhATV1DDZ/Ak3DQufjlRK5E4u+s0CfClfNFtAGBabw+jDGtRFbOZe+Z02ZMWCBNQ==

"@types/minimatch@*":
version "3.0.3"
Expand All @@ -1088,7 +1087,6 @@
"@types/node@*", "@types/node@^12.0.2":
version "12.0.2"
resolved "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz#3452a24edf9fea138b48fad4a0a028a683da1e40"
integrity sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand All @@ -1097,7 +1095,6 @@
"@types/[email protected]":
version "5.0.1"
resolved "https://registry.npmjs.org/@types/resolve-from/-/resolve-from-5.0.1.tgz#2714eaa840c0472dcfa96ec3fb9d170dbf0b677d"
integrity sha512-1G7n5Jtr5inoS1Ez2Y9Efedk9/wH6uGQslbfhGTOw9J42PCAwuyaDgQHW7fIq02+shwB02kM/w31W8gMxI8ORg==
dependencies:
resolve-from "*"

Expand Down Expand Up @@ -5429,7 +5426,6 @@ istanbul-lib-source-maps@^3.0.1:
istanbul-reports@^2.1.1:
version "2.2.6"
resolved "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.6.tgz#7b4f2660d82b29303a8fe6091f8ca4bf058da1af"
integrity sha512-SKi4rnMyLBKe0Jy2uUdx28h8oG7ph2PPuQPvIAh31d+Ci+lSiEu4C+h3oBPuJ9+mPKhOyW0M8gY4U5NM1WLeXA==
dependencies:
handlebars "^4.1.2"

Expand Down Expand Up @@ -5796,7 +5792,7 @@ jest-worker@^24.6.0:
merge-stream "^1.0.1"
supports-color "^6.1.0"

[email protected]:
[email protected], jest@^24.8.0:
version "24.8.0"
resolved "https://registry.npmjs.org/jest/-/jest-24.8.0.tgz#d5dff1984d0d1002196e9b7f12f75af1b2809081"
dependencies:
Expand Down Expand Up @@ -8449,7 +8445,6 @@ semver-diff@^2.0.0:
[email protected]:
version "6.1.1"
resolved "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz#53f53da9b30b2103cd4f15eab3a18ecbcb210c9b"
integrity sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==

semver@^5.5:
version "5.7.0"
Expand All @@ -8466,7 +8461,6 @@ semver@^5.5.1, semver@^5.6.0:
semver@^6.0.0:
version "6.0.0"
resolved "https://registry.npmjs.org/semver/-/semver-6.0.0.tgz#05e359ee571e5ad7ed641a6eec1e547ba52dea65"
integrity sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==

semver@~5.3.0:
version "5.3.0"
Expand Down Expand Up @@ -8582,7 +8576,6 @@ slash@^1.0.0:
slash@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==

slash@^3.0.0:
version "3.0.0"
Expand Down Expand Up @@ -8780,7 +8773,6 @@ [email protected]:
sshpk@^1.7.0:
version "1.16.1"
resolved "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877"
integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==
dependencies:
asn1 "~0.2.3"
assert-plus "^1.0.0"
Expand Down Expand Up @@ -9155,7 +9147,6 @@ throat@^4.0.0:
throat@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b"
integrity sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==

through2@^2.0.0, through2@^2.0.2:
version "2.0.3"
Expand Down Expand Up @@ -9301,7 +9292,7 @@ trim-right@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"

[email protected]:
[email protected], ts-jest@^24.0.2:
version "24.0.2"
resolved "https://registry.npmjs.org/ts-jest/-/ts-jest-24.0.2.tgz#8dde6cece97c31c03e80e474c749753ffd27194d"
dependencies:
Expand Down Expand Up @@ -9351,10 +9342,9 @@ [email protected]:
version "3.4.5"
resolved "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99"

[email protected]:
[email protected], typescript@^3.4.5:
version "3.5.1"
resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz#ba72a6a600b2158139c5dd8850f700e231464202"
integrity sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==

uglify-js@^3.1.4:
version "3.4.9"
Expand Down

0 comments on commit c102d2f

Please sign in to comment.