Skip to content

Commit

Permalink
refactor: port is-ignored ts (#675)
Browse files Browse the repository at this point in the history
* chore: add ts and jest config

* chore: add ts related deps

* refactor: port is-ignored to ts

* style: apply prettier rules
  • Loading branch information
marionebl committed Jun 11, 2019
1 parent 2bde134 commit 71928ae
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 233 deletions.
1 change: 1 addition & 0 deletions @commitlint/is-ignored/index.d.ts
@@ -0,0 +1 @@
export * from "./lib";
2 changes: 2 additions & 0 deletions @commitlint/is-ignored/index.js
@@ -0,0 +1,2 @@
module.exports = require('./lib').default;
module.exports.default = module.exports;
4 changes: 4 additions & 0 deletions @commitlint/is-ignored/jest.config.js
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
};
42 changes: 11 additions & 31 deletions @commitlint/is-ignored/package.json
Expand Up @@ -2,36 +2,16 @@
"name": "@commitlint/is-ignored",
"version": "8.0.0",
"description": "Lint your commit messages",
"main": "lib/index.js",
"files": [
"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 \"jest --watchAll\" \"tsc -w\"",
"test": "jest",
"watch": "tsc -w"
},
"engines": {
"node": ">=4"
Expand All @@ -56,17 +36,17 @@
},
"license": "MIT",
"devDependencies": {
"@commitlint/parse": "^8.0.0",
"@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",
"@commitlint/utils": "8.0.0",
"@types/jest": "^24.0.13",
"concurrently": "3.5.1",
"cross-env": "5.1.1"
"jest": "^24.8.0",
"ts-jest": "^24.0.2",
"typescript": "^3.5.1"
},
"dependencies": {
"@types/semver": "^6.0.0",
"semver": "6.1.1"
}
}
29 changes: 29 additions & 0 deletions @commitlint/is-ignored/src/defaults.ts
@@ -0,0 +1,29 @@
import semver from 'semver';

export type Matcher = (commit: string) => boolean;

const isSemver = (c: string): boolean => {
const firstLine = c.split('\n').shift();

if (typeof firstLine !== 'string') {
return false;
}

const stripped = firstLine.replace(/^chore(\([^)]+\))?:/, '').trim();
return semver.valid(stripped) !== null;
};

const test = (r: RegExp): ((c: string) => boolean) => r.test.bind(r);

export const wildcards: Matcher[] = [
test(
/^((Merge pull request)|(Merge (.*?) into (.*?)|(Merge branch (.*?)))(?:\r?\n)*$)/m
),
test(/^(R|r)evert (.*)/),
test(/^(fixup|squash)!/),
isSemver,
test(/^Merged (.*?)(in|into) (.*)/),
test(/^Merge remote-tracking branch (.*)/),
test(/^Automatic merge(.*)/),
test(/^Auto-merged (.*?) into (.*)/)
];
45 changes: 0 additions & 45 deletions @commitlint/is-ignored/src/index.js

This file was deleted.

153 changes: 0 additions & 153 deletions @commitlint/is-ignored/src/index.test.js

This file was deleted.

2 changes: 2 additions & 0 deletions @commitlint/is-ignored/src/index.ts
@@ -0,0 +1,2 @@
export * from './is-ignored';
export {Matcher} from './defaults';

0 comments on commit 71928ae

Please sign in to comment.