diff --git a/@commitlint/cli/src/cli.ts b/@commitlint/cli/src/cli.ts index 0820831a5e..432336086a 100644 --- a/@commitlint/cli/src/cli.ts +++ b/@commitlint/cli/src/cli.ts @@ -286,7 +286,7 @@ async function main(args: MainArgs): Promise { message: [ 'Please add rules to your `commitlint.config.js`', ' - Getting started guide: https://commitlint.js.org/#/?id=getting-started', - ' - Example config: https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-conventional/index.js', + ' - Example config: https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-conventional/src/index.ts', ].join('\n'), }, ], diff --git a/@commitlint/config-conventional/package.json b/@commitlint/config-conventional/package.json index 7db13d0932..6f0bf41570 100644 --- a/@commitlint/config-conventional/package.json +++ b/@commitlint/config-conventional/package.json @@ -2,8 +2,9 @@ "name": "@commitlint/config-conventional", "version": "18.6.0", "description": "Shareable commitlint config enforcing conventional commits", + "main": "lib/index.js", "files": [ - "index.js" + "lib/" ], "scripts": { "deps": "dep-check", @@ -37,6 +38,7 @@ "@commitlint/utils": "^18.4.4" }, "dependencies": { + "@commitlint/types": "^18.6.0", "conventional-changelog-conventionalcommits": "^7.0.2" }, "gitHead": "70f7f4688b51774e7ac5e40e896cdaa3f132b2bc" diff --git a/@commitlint/config-conventional/index.test.js b/@commitlint/config-conventional/src/index.test.ts similarity index 97% rename from @commitlint/config-conventional/index.test.js rename to @commitlint/config-conventional/src/index.test.ts index 2dad581937..144074eefb 100644 --- a/@commitlint/config-conventional/index.test.js +++ b/@commitlint/config-conventional/src/index.test.ts @@ -1,9 +1,9 @@ import lint from '@commitlint/lint'; -import {rules, parserPreset} from '.'; +import {config} from '.'; const commitLint = async (message) => { - const preset = await require(parserPreset)(); - return lint(message, rules, {...preset}); + const preset = await require(config.parserPreset)(); + return lint(message, config.rules, {...preset}); }; const messages = { diff --git a/@commitlint/config-conventional/index.js b/@commitlint/config-conventional/src/index.ts similarity index 74% rename from @commitlint/config-conventional/index.js rename to @commitlint/config-conventional/src/index.ts index 9a0a1d2507..d32da4aaf3 100644 --- a/@commitlint/config-conventional/index.js +++ b/@commitlint/config-conventional/src/index.ts @@ -1,23 +1,33 @@ -module.exports = { +import { + RuleConfigCondition, + RuleConfigSeverity, + TargetCaseType, +} from '@commitlint/types'; + +export const config = { parserPreset: 'conventional-changelog-conventionalcommits', rules: { - 'body-leading-blank': [1, 'always'], - 'body-max-line-length': [2, 'always', 100], - 'footer-leading-blank': [1, 'always'], - 'footer-max-line-length': [2, 'always', 100], - 'header-max-length': [2, 'always', 100], - 'header-trim': [2, 'always'], + 'body-leading-blank': [RuleConfigSeverity.Warning, 'always'] as const, + 'body-max-line-length': [RuleConfigSeverity.Error, 'always', 100] as const, + 'footer-leading-blank': [RuleConfigSeverity.Warning, 'always'] as const, + 'footer-max-line-length': [ + RuleConfigSeverity.Error, + 'always', + 100, + ] as const, + 'header-max-length': [RuleConfigSeverity.Error, 'always', 100] as const, + 'header-trim': [RuleConfigSeverity.Error, 'always'] as const, 'subject-case': [ - 2, + RuleConfigSeverity.Error, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case'], - ], - 'subject-empty': [2, 'never'], - 'subject-full-stop': [2, 'never', '.'], - 'type-case': [2, 'always', 'lower-case'], - 'type-empty': [2, 'never'], + ] as [RuleConfigSeverity, RuleConfigCondition, TargetCaseType[]], + 'subject-empty': [RuleConfigSeverity.Error, 'never'] as const, + 'subject-full-stop': [RuleConfigSeverity.Error, 'never', '.'] as const, + 'type-case': [RuleConfigSeverity.Error, 'always', 'lower-case'] as const, + 'type-empty': [RuleConfigSeverity.Error, 'never'] as const, 'type-enum': [ - 2, + RuleConfigSeverity.Error, 'always', [ 'build', @@ -32,7 +42,7 @@ module.exports = { 'style', 'test', ], - ], + ] as [RuleConfigSeverity, RuleConfigCondition, string[]], }, prompt: { questions: { diff --git a/@commitlint/config-conventional/tsconfig.json b/@commitlint/config-conventional/tsconfig.json index 2905f19318..49479bf34f 100644 --- a/@commitlint/config-conventional/tsconfig.json +++ b/@commitlint/config-conventional/tsconfig.json @@ -5,6 +5,6 @@ "rootDir": "./src", "outDir": "./lib" }, - "include": ["./**/*.ts"], - "exclude": ["./**/*.test.ts"] + "include": ["./src"], + "exclude": ["./src/**/*.test.ts", "./lib/**/*"] } diff --git a/README.md b/README.md index 916ec5d75e..1b3c8367cd 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ These can be modified by [your own configuration](#config). - `commitlint` field in `package.json` - Packages: [cli](./@commitlint/cli), [core](./@commitlint/core) - See [Rules](./docs/reference-rules.md) for a complete list of possible rules -- An example configuration can be found at [@commitlint/config-conventional](./@commitlint/config-conventional/index.js) +- An example configuration can be found at [@commitlint/config-conventional](./@commitlint/config-conventional/src/index.ts) ## Shared configuration diff --git a/tsconfig.json b/tsconfig.json index 0b126bbc7f..cf20a54fe6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,6 +23,7 @@ {"path": "@commitlint/cli"}, {"path": "@commitlint/travis-cli"}, {"path": "@commitlint/prompt"}, - {"path": "@commitlint/cz-commitlint"} + {"path": "@commitlint/cz-commitlint"}, + {"path": "@commitlint/config-conventional"} ] }