Skip to content

Commit 8568005

Browse files
author
Mistructure
authored
Feature/restrict config (#1)
* [Chore] ignore dist folder * [Feat::config] add some rules & regex to restrict commit message
1 parent 4e44cba commit 8568005

File tree

20 files changed

+835
-55
lines changed

20 files changed

+835
-55
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# deps
22
node_modules
3-
packages/**/node_modules
3+
packages/**/node_modules
4+
5+
# dist
6+
dist

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
"commitlint-wizardoc-e2e-tests"
2525
],
2626
"dependencies": {}
27-
}
27+
}
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
import { LexicalElement } from "./typings";
2-
declare const config: {
3-
parserOpts: {
4-
headerPattern: RegExp;
5-
headerCorrespondence: LexicalElement[];
6-
};
7-
rules: {
8-
"body-leading-blank": (string | number)[];
9-
};
10-
};
1+
import { UserConfig } from "@commitlint/types";
2+
declare const config: UserConfig;
113
export = config;
Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
"use strict";
2-
const typings_1 = require("./typings");
2+
const constants_1 = require("./constants");
3+
const enum_1 = require("./utils/enum");
34
const config = {
4-
parserOpts: {
5-
headerPattern: /^\[(\w*)::(\w*)\]\s(.*)$/,
6-
headerCorrespondence: [
7-
typings_1.LexicalElement.TYPE,
8-
typings_1.LexicalElement.SCOPE,
9-
typings_1.LexicalElement.SUBJECT,
10-
],
5+
parserPreset: {
6+
name: "",
7+
path: "",
8+
parserOpts: {
9+
headerPattern: constants_1.CONVERSION_MATCH_REGEX,
10+
headerCorrespondence: [
11+
constants_1.LexicalElement.TYPE,
12+
constants_1.LexicalElement.SCOPE,
13+
constants_1.LexicalElement.SUBJECT,
14+
],
15+
},
1116
},
1217
rules: {
13-
"body-leading-blank": [1, "always"],
18+
// 'subject-exclamation-mark': [2, 'never'],
19+
"footer-leading-blank": [1, "always"],
20+
"header-max-length": [2, "always", 72],
21+
// 'scope-case': [2, 'always', 'lower-case'],
22+
"subject-case": [2, "never", ["upper-case"]],
23+
// 'subject-empty': [2, 'never'],
24+
"subject-full-stop": [2, "never", "."],
25+
"type-empty": [2, "never"],
26+
"scope-empty": [1, "never"],
27+
"type-enum": [2, "always", enum_1.enumerateValues(constants_1.CommitType)],
1428
},
1529
};
1630
module.exports = config;

packages/commitlint-config-wizardoc/dist/typings.d.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/commitlint-config-wizardoc/dist/typings.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/commitlint-config-wizardoc/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@
55
"license": "MIT",
66
"scripts": {
77
"compile": "tsc"
8-
}
8+
},
9+
"devDependencies": {
10+
"@commitlint/config-conventional": "^12.1.4",
11+
"@commitlint/parse": "^12.1.4",
12+
"@commitlint/types": "^12.1.4"
13+
},
14+
"dependencies": {}
915
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export enum LexicalElement {
2+
SUBJECT = "subject",
3+
TYPE = "type",
4+
SCOPE = "scope",
5+
TICKET = "ticket",
6+
}
7+
8+
export enum CommitType {
9+
FEAT = "Feat",
10+
INIT = "Init",
11+
REMOVE = "Remove",
12+
DELETE = "Delete",
13+
MOVE = "Move",
14+
NEW = "New",
15+
ADD = "Add",
16+
PATCH = "Patch",
17+
FIX = "Fix",
18+
TEST = "Test",
19+
STUB = "Stub",
20+
}
21+
22+
export const CONVERSION_MATCH_REGEX = /^\[(\w+?)(?:\:\:(\w*))?\]\s(.*)$/;

packages/commitlint-config-wizardoc/src/index.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
1-
import { LexicalElement } from "./typings";
1+
import {
2+
LexicalElement,
3+
CommitType,
4+
CONVERSION_MATCH_REGEX,
5+
} from "./constants";
6+
import { UserConfig } from "@commitlint/types";
7+
import { enumerateValues } from "./utils/enum";
28

3-
const config = {
4-
parserOpts: {
5-
headerPattern: /^\[(\w*)::(\w*)\]\s(.*)$/,
6-
headerCorrespondence: [
7-
LexicalElement.TYPE,
8-
LexicalElement.SCOPE,
9-
LexicalElement.SUBJECT,
10-
],
9+
const config: UserConfig = {
10+
parserPreset: {
11+
name: "",
12+
path: "",
13+
parserOpts: {
14+
headerPattern: CONVERSION_MATCH_REGEX,
15+
headerCorrespondence: [
16+
LexicalElement.TYPE,
17+
LexicalElement.SCOPE,
18+
LexicalElement.SUBJECT,
19+
],
20+
},
1121
},
1222
rules: {
13-
"body-leading-blank": [1, "always"],
23+
// 'subject-exclamation-mark': [2, 'never'],
24+
"footer-leading-blank": [1, "always"],
25+
"header-max-length": [2, "always", 72],
26+
// 'scope-case': [2, 'always', 'lower-case'],
27+
"subject-case": [2, "never", ["upper-case"] as any],
28+
// 'subject-empty': [2, 'never'],
29+
"subject-full-stop": [2, "never", "."],
30+
"type-empty": [2, "never"],
31+
"scope-empty": [1, "never"],
32+
"type-enum": [2, "always", enumerateValues(CommitType)],
1433
},
1534
};
1635

packages/commitlint-config-wizardoc/src/typings.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)