Skip to content
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

refactor: port to-lines to ts #677

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions @commitlint/to-lines/jest.config.js
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
};
39 changes: 9 additions & 30 deletions @commitlint/to-lines/package.json
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
@@ -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']);
});
@@ -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
@@ -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"
]
}