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 is-ignored ts #675

Merged
merged 6 commits into from Jun 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions @commitlint/is-ignored/index.d.ts
@@ -0,0 +1 @@
export * from "./lib";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's better, double or single quotes? In other files I see that you are using single, I prefer them too but open for double. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i vote single :P

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';