Skip to content
2 changes: 1 addition & 1 deletion packages/commitlint-config-wizardoc/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const config: UserConfig = {
},
...plugins,
rules: {
"break-change-prefix": [2, "always"],
"break-change-prefix": [2, "always", "#"],
"footer-leading-blank": [1, "always"],
"header-max-length": [2, "always", 72],
"subject-full-stop": [2, "never", "."],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { BREAK_CHANGE_SYMBOL } from "./constants";
import { Commit, Rule, RuleOutcome } from "@commitlint/types";
import { Commit, RuleOutcome, RuleConfigCondition } from "@commitlint/types";

export type WithSymbol<T> = T & {
symbol: string;
};

export type CommitWithSymbol = WithSymbol<Commit>;

export const breakChangeSymbolRule = (walkData: Commit): RuleOutcome => {
export const breakChangeSymbolRule = (
walkData: Commit,
_when?: RuleConfigCondition,
value: string = BREAK_CHANGE_SYMBOL
): RuleOutcome => {
const { symbol } = walkData as CommitWithSymbol;
const isRuleValid = !symbol || symbol === BREAK_CHANGE_SYMBOL;
const isRuleValid = !symbol || symbol === value;

return [
isRuleValid,
`break change must be symbol with "${BREAK_CHANGE_SYMBOL}" e.g: ${BREAK_CHANGE_SYMBOL}[Type::scope] subject`,
`break change must be symbol with "${value}" e.g: ${value}[Type::scope] subject`,
];
};
5 changes: 3 additions & 2 deletions packages/commitlint-wizardoc-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"main": "index.js",
"license": "MIT",
"devDependencies": {
"zx": "^1.12.0"
"@types/shelljs": "^0.8.8"
},
"dependencies": {
"commitlint-config-wizardoc": "^1.0.0"
"commitlint-config-wizardoc": "^1.0.0",
"shelljs": "^0.8.4"
}
}
50 changes: 50 additions & 0 deletions packages/commitlint-wizardoc-e2e-tests/src/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* eslint-disable import/no-extraneous-dependencies */
import { $ } from "../utils/shell";

const SUCCESS_SIGNAL = 0;

describe("commitlintPluginRuleTests", () => {
const successfulCase = "![Add::scope] subject";

it("success provided commitlint config", () => {
const res = $`echo "${successfulCase}" | npx commitlint`;

expect(res.code).toEqual(SUCCESS_SIGNAL);
});

it("success provided commitlint config", () => {
const res = $`echo "${successfulCase}" | npx commitlint`;

expect(res.code).toEqual(SUCCESS_SIGNAL);
});

it("type fail provided commitlint config", () => {
const res = $`echo ![add::scope] subject | npx commitlint`;

expect(res.code).not.toEqual(SUCCESS_SIGNAL);
});

it("scope fail provided commitlint config", () => {
const res = $`echo @[add@scope] subjectFail | npx commitlint`;

expect(res.code).not.toEqual(SUCCESS_SIGNAL);
});

it("symbol fail provided commitlint config", () => {
const res = $`echo @[add::scope] subject | npx commitlint`;

expect(res.code).not.toEqual(SUCCESS_SIGNAL);
});

it("subject fail provided commitlint config", () => {
const res = $`echo @[add::scope] subject_fail | npx commitlint`;

expect(res.code).not.toEqual(SUCCESS_SIGNAL);
});

it("subject fail provided commitlint config", () => {
const res = $`echo @[add::scope] subjectFail | npx commitlint`;

expect(res.code).not.toEqual(SUCCESS_SIGNAL);
});
});
4 changes: 4 additions & 0 deletions packages/commitlint-wizardoc-e2e-tests/src/utils/shell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { exec } from "shelljs";

export const $ = (pieces: TemplateStringsArray, ...args: unknown[]) =>
exec(pieces.reduce((pre, cur, i) => pre + cur + ((args ?? [])[i] ?? ""), ""));
218 changes: 152 additions & 66 deletions packages/commitlint-wizardoc-e2e-tests/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,165 @@
# yarn lockfile v1


"@types/node@^15.3":
"integrity" "sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA=="
"resolved" "https://registry.npmjs.org/@types/node/-/node-15.6.1.tgz"
"version" "15.6.1"

"ansi-styles@^4.1.0":
"integrity" "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="
"resolved" "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz"
"version" "4.3.0"
"@types/glob@*":
version "7.1.3"
resolved "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183"
integrity sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w==
dependencies:
"color-convert" "^2.0.1"
"@types/minimatch" "*"
"@types/node" "*"

"chalk@^4.1.1":
"integrity" "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg=="
"resolved" "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz"
"version" "4.1.1"
"@types/minimatch@*":
version "3.0.4"
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21"
integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA==

"@types/node@*":
version "15.6.1"
resolved "https://registry.npmjs.org/@types/node/-/node-15.6.1.tgz#32d43390d5c62c5b6ec486a9bc9c59544de39a08"
integrity sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA==

"@types/shelljs@^0.8.8":
version "0.8.8"
resolved "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.8.tgz#e439c69929b88a2c8123c1a55e09eb708315addf"
integrity sha512-lD3LWdg6j8r0VRBFahJVaxoW0SIcswxKaFUrmKl33RJVeeoNYQAz4uqCJ5Z6v4oIBOsC5GozX+I5SorIKiTcQA==
dependencies:
"@types/glob" "*"
"@types/node" "*"

balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"

commitlint-config-wizardoc@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/commitlint-config-wizardoc/-/commitlint-config-wizardoc-1.0.0.tgz#d8f4372b75667ee8b553f1b6fa6eed9553e42a93"
integrity sha512-ecOER5XBrTZVVIzRyXfGQMoe8C4OQevP4lYFK/HwB5jhFgCAX1TXiASYQLwgq4iU1hQcHMBc2inHVitVqRadHA==
dependencies:
"ansi-styles" "^4.1.0"
"supports-color" "^7.1.0"
commitlint-plugin-wizardoc-rules "^1.0.0"

"color-convert@^2.0.1":
"integrity" "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="
"resolved" "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz"
"version" "2.0.1"
commitlint-plugin-wizardoc-rules@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/commitlint-plugin-wizardoc-rules/-/commitlint-plugin-wizardoc-rules-1.0.0.tgz#3f6e8a42d42b31c7897a91bc224b85132768324b"
integrity sha512-V7NT3egc4LXBYeNtKnYYFtCAb8/3vlea9xNlky4r41HUHC9mx5w6mnKe7NQAucllkLGyYDL/FRt51UiyujrYPg==

concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=

function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==

glob@^7.0.0:
version "7.1.7"
resolved "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90"
integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==
dependencies:
"color-name" "~1.1.4"

"color-name@~1.1.4":
"integrity" "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
"resolved" "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz"
"version" "1.1.4"

"has-flag@^4.0.0":
"integrity" "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
"resolved" "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz"
"version" "4.0.0"

"isexe@^2.0.0":
"integrity" "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
"resolved" "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
"version" "2.0.0"

"node-fetch@^2.6.1":
"integrity" "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
"resolved" "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz"
"version" "2.6.1"

"shq@^1.0.2":
"integrity" "sha512-8AvNyHL75DHlkbLmzF7nzTzT2F0qEfSewwxHjH79Ww8S+hGpIZVlf8b0TcdOwv4HqIkOVBInu9n+wqhUSl9Wag=="
"resolved" "https://registry.npmjs.org/shq/-/shq-1.0.2.tgz"
"version" "1.0.2"

"supports-color@^7.1.0":
"integrity" "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="
"resolved" "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz"
"version" "7.2.0"
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"

has@^1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==
dependencies:
"has-flag" "^4.0.0"
function-bind "^1.1.1"

"which@^2.0.2":
"integrity" "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="
"resolved" "https://registry.npmjs.org/which/-/which-2.0.2.tgz"
"version" "2.0.2"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
"isexe" "^2.0.0"
once "^1.3.0"
wrappy "1"

inherits@2:
version "2.0.4"
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==

interpret@^1.0.0:
version "1.4.0"
resolved "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e"
integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==

"zx@^1.12.0":
"integrity" "sha512-JvZxN3QTnZIUF5p9YVpqc/wm6Ghc5yVQd/p53KC0nnSK3RUfeuGMRrOnxJ5c4R4iYwY5F65i4e3BU59JD6svBw=="
"resolved" "https://registry.npmjs.org/zx/-/zx-1.12.0.tgz"
"version" "1.12.0"
is-core-module@^2.2.0:
version "2.4.0"
resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1"
integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==
dependencies:
"@types/node" "^15.3"
"chalk" "^4.1.1"
"node-fetch" "^2.6.1"
"shq" "^1.0.2"
"which" "^2.0.2"
has "^1.0.3"

minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"

once@^1.3.0:
version "1.4.0"
resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=

path-parse@^1.0.6:
version "1.0.7"
resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==

rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=
dependencies:
resolve "^1.1.6"

resolve@^1.1.6:
version "1.20.0"
resolved "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
dependencies:
is-core-module "^2.2.0"
path-parse "^1.0.6"

shelljs@^0.8.4:
version "0.8.4"
resolved "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"

wrappy@1:
version "1.0.2"
resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"declaration": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
}
}