Skip to content

Commit c102d2f

Browse files
bendtherulesmarionebl
authored andcommitted
refactor: port to-lines to ts (#677)
* 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
1 parent 4360d56 commit c102d2f

File tree

7 files changed

+61
-67
lines changed

7 files changed

+61
-67
lines changed

@commitlint/to-lines/jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node'
4+
};

@commitlint/to-lines/package.json

+9-30
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,12 @@
77
"lib/"
88
],
99
"scripts": {
10-
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
10+
"build": "tsc",
1111
"deps": "dep-check",
1212
"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-
]
13+
"start": "concurrently \"yarn test --watchAll\" \"yarn run watch\"",
14+
"test": "jest",
15+
"watch": "tsc -w"
3516
},
3617
"engines": {
3718
"node": ">=4"
@@ -57,13 +38,11 @@
5738
"license": "MIT",
5839
"devDependencies": {
5940
"@commitlint/parse": "^8.0.0",
60-
"@commitlint/test": "8.0.0",
6141
"@commitlint/utils": "^8.0.0",
62-
"ava": "0.22.0",
63-
"babel-cli": "6.26.0",
64-
"babel-preset-commitlint": "^8.0.0",
65-
"babel-register": "6.26.0",
6642
"concurrently": "3.5.1",
67-
"cross-env": "5.1.1"
43+
"@types/jest": "^24.0.13",
44+
"jest": "^24.8.0",
45+
"ts-jest": "^24.0.2",
46+
"typescript": "^3.4.5"
6847
}
69-
}
48+
}

@commitlint/to-lines/src/index.test.js

-22
This file was deleted.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import toLines from '.';
2+
3+
test('should return an array for empty input', () => {
4+
expect((toLines as () => string[])()).toStrictEqual([]);
5+
});
6+
7+
test('should return an array for null input', () => {
8+
expect((toLines as (input: any) => string[])(null)).toStrictEqual([]);
9+
});
10+
11+
test('should return an array for empty string input', () => {
12+
expect(toLines('')).toStrictEqual(['']);
13+
});
14+
15+
test('should split LF newlines', () => {
16+
expect(toLines('some\nweird\ntext')).toStrictEqual(['some', 'weird', 'text']);
17+
});
18+
19+
test('should split CR+LF newlines', () => {
20+
expect(toLines('some\r\nweird\r\ntext')).toStrictEqual(['some', 'weird', 'text']);
21+
});

@commitlint/to-lines/src/index.js renamed to @commitlint/to-lines/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function toLines(input) {
1+
export default function toLines(input: string): string[] {
22
if (typeof input !== 'string') {
33
return [];
44
}

@commitlint/to-lines/tsconfig.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"lib": [
4+
"dom",
5+
"es2015"
6+
],
7+
"rootDir": "src",
8+
"outDir": "lib",
9+
"declaration": true,
10+
"declarationMap": true,
11+
"sourceMap": true,
12+
"esModuleInterop": true,
13+
"allowSyntheticDefaultImports": true,
14+
"strict": true
15+
},
16+
"include": [
17+
"./src"
18+
],
19+
"exclude": [
20+
"./src/**/*.test.ts"
21+
]
22+
}

yarn.lock

+4-14
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@
10661066
version "20.0.1"
10671067
resolved "https://registry.npmjs.org/@types/jest-diff/-/jest-diff-20.0.1.tgz#35cc15b9c4f30a18ef21852e255fdb02f6d59b89"
10681068

1069-
1069+
"@types/[email protected]", "@types/jest@^24.0.13":
10701070
version "24.0.13"
10711071
resolved "https://registry.npmjs.org/@types/jest/-/jest-24.0.13.tgz#10f50b64cb05fb02411fbba49e9042a3a11da3f9"
10721072
dependencies:
@@ -1079,7 +1079,6 @@
10791079
10801080
version "4.14.133"
10811081
resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.133.tgz#430721c96da22dd1694443e68e6cec7ba1c1003d"
1082-
integrity sha512-/3JqnvPnY58GLzG3Y7fpphOhATV1DDZ/Ak3DQufjlRK5E4u+s0CfClfNFtAGBabw+jDGtRFbOZe+Z02ZMWCBNQ==
10831082

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

10931091
"@types/normalize-package-data@^2.4.0":
10941092
version "2.4.0"
@@ -1097,7 +1095,6 @@
10971095
10981096
version "5.0.1"
10991097
resolved "https://registry.npmjs.org/@types/resolve-from/-/resolve-from-5.0.1.tgz#2714eaa840c0472dcfa96ec3fb9d170dbf0b677d"
1100-
integrity sha512-1G7n5Jtr5inoS1Ez2Y9Efedk9/wH6uGQslbfhGTOw9J42PCAwuyaDgQHW7fIq02+shwB02kM/w31W8gMxI8ORg==
11011098
dependencies:
11021099
resolve-from "*"
11031100

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

@@ -5796,7 +5792,7 @@ jest-worker@^24.6.0:
57965792
merge-stream "^1.0.1"
57975793
supports-color "^6.1.0"
57985794

5799-
5795+
[email protected], jest@^24.8.0:
58005796
version "24.8.0"
58015797
resolved "https://registry.npmjs.org/jest/-/jest-24.8.0.tgz#d5dff1984d0d1002196e9b7f12f75af1b2809081"
58025798
dependencies:
@@ -8449,7 +8445,6 @@ semver-diff@^2.0.0:
84498445
84508446
version "6.1.1"
84518447
resolved "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz#53f53da9b30b2103cd4f15eab3a18ecbcb210c9b"
8452-
integrity sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==
84538448

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

84718465
semver@~5.3.0:
84728466
version "5.3.0"
@@ -8582,7 +8576,6 @@ slash@^1.0.0:
85828576
slash@^2.0.0:
85838577
version "2.0.0"
85848578
resolved "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
8585-
integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==
85868579

85878580
slash@^3.0.0:
85888581
version "3.0.0"
@@ -8780,7 +8773,6 @@ [email protected]:
87808773
sshpk@^1.7.0:
87818774
version "1.16.1"
87828775
resolved "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877"
8783-
integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==
87848776
dependencies:
87858777
asn1 "~0.2.3"
87868778
assert-plus "^1.0.0"
@@ -9155,7 +9147,6 @@ throat@^4.0.0:
91559147
throat@^5.0.0:
91569148
version "5.0.0"
91579149
resolved "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b"
9158-
integrity sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==
91599150

91609151
through2@^2.0.0, through2@^2.0.2:
91619152
version "2.0.3"
@@ -9301,7 +9292,7 @@ trim-right@^1.0.1:
93019292
version "1.0.1"
93029293
resolved "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
93039294

9304-
9295+
[email protected], ts-jest@^24.0.2:
93059296
version "24.0.2"
93069297
resolved "https://registry.npmjs.org/ts-jest/-/ts-jest-24.0.2.tgz#8dde6cece97c31c03e80e474c749753ffd27194d"
93079298
dependencies:
@@ -9351,10 +9342,9 @@ [email protected]:
93519342
version "3.4.5"
93529343
resolved "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99"
93539344

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

93599349
uglify-js@^3.1.4:
93609350
version "3.4.9"

0 commit comments

Comments
 (0)