Skip to content

Commit 066cc44

Browse files
author
Mistructure
authored
Feature/restrict config (#3)
* [Feat::deps] link wizardoc to config package * [Test::config] add test case for config generator
1 parent 8568005 commit 066cc44

File tree

11 files changed

+106
-73
lines changed

11 files changed

+106
-73
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ node_modules
33
packages/**/node_modules
44

55
# dist
6-
dist
6+
dist
7+
packages/**/dist

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"devDependencies": {
1313
"@commitlint/cli": "^12.1.4",
1414
"@commitlint/config-conventional": "^12.1.4",
15+
"@types/jest": "^26.0.23",
1516
"jest": "^27.0.1",
1617
"jest-config": "^27.0.1",
1718
"lerna": "^4.0.0",

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

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

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

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

packages/commitlint-config-wizardoc/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"compile": "tsc"
88
},
99
"devDependencies": {
10-
"@commitlint/config-conventional": "^12.1.4",
11-
"@commitlint/parse": "^12.1.4",
1210
"@commitlint/types": "^12.1.4"
1311
},
1412
"dependencies": {}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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";
8+
9+
export 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+
},
21+
},
22+
rules: {
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)],
33+
},
34+
};
Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
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";
8-
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-
},
21-
},
22-
rules: {
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)],
33-
},
34-
};
1+
import { config } from "./config";
352

363
export = config;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { config } from "../config";
2+
3+
describe("validate config structure", () => {
4+
it("should return a correct config", () => {
5+
expect(config).toHaveProperty("rules");
6+
expect(config).toHaveProperty("parserPreset");
7+
});
8+
});
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const config = require('../commitlint-config-wizardoc/dist/index')
2-
31
module.exports = {
4-
extends: ["./../commitlint-config-wizardoc/dist/index"]
2+
extends: ["wizardoc"]
53
}

packages/commitlint-wizardoc-e2e-tests/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
"license": "MIT",
66
"devDependencies": {
77
"zx": "^1.12.0"
8+
},
9+
"dependencies": {
10+
"commitlint-config-wizardoc": "^1.0.0"
811
}
912
}

0 commit comments

Comments
 (0)