From 1ad3de191e7a11f3e0d02b58ec41e94c4acae5e3 Mon Sep 17 00:00:00 2001 From: escapedcat Date: Sun, 24 Jan 2021 15:36:57 +0800 Subject: [PATCH 1/2] docs: show config example in ts and js #2232 --- docs/reference-configuration.md | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/reference-configuration.md b/docs/reference-configuration.md index 2a1f7582fb..c5e2b9712c 100644 --- a/docs/reference-configuration.md +++ b/docs/reference-configuration.md @@ -8,6 +8,53 @@ The file is expected - export a configuration object - adhere to the schema outlined below +## Configuration object example + +### JavaScript + +```js +const Configuration = { + /* + * Resolve and load @commitlint/config-conventional from node_modules. + * Referenced packages must be installed + */ + extends: ['@commitlint/config-conventional'], + /* + * Resolve and load conventional-changelog-atom from node_modules. + * Referenced packages must be installed + */ + parserPreset: 'conventional-changelog-atom', + /* + * Resolve and load @commitlint/format from node_modules. + * Referenced package must be installed + */ + formatter: '@commitlint/format', + /* + * Any rules defined here will override rules from @commitlint/config-conventional + */ + rules: { + 'type-enum': [2, 'always', ['foo']], + }, + /* + * Functions that return true if commitlint should ignore the given message. + */ + ignores: [(commit) => commit === ''], + /* + * Whether commitlint uses the default ignore rules. + */ + defaultIgnores: true, + /* + * Custom URL to show upon failure + */ + helpUrl: + 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint', +}; + +module.exports = Configuration; +``` + +### TypeScript + ```ts type Config = { /* From 4b8c02f03a331cd202e4a40acc2221279c068d20 Mon Sep 17 00:00:00 2001 From: escapedcat Date: Thu, 28 Jan 2021 11:37:18 +0800 Subject: [PATCH 2/2] docs: import config type from types #2232 --- docs/reference-configuration.md | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/docs/reference-configuration.md b/docs/reference-configuration.md index c5e2b9712c..4d68aa98f5 100644 --- a/docs/reference-configuration.md +++ b/docs/reference-configuration.md @@ -56,38 +56,9 @@ module.exports = Configuration; ### TypeScript ```ts -type Config = { - /* - * Resolveable ids to commitlint configurations to extend - */ - extends?: string[]; - /* - * Resolveable id to conventional-changelog parser preset to import and use - */ - parserPreset?: string; - /* - * Resolveable id to package, from node_modules, which formats the output. - */ - formatter: string; - /* - * Rules to check against - */ - rules?: {[name: string]: Rule}; - /* - * Functions that return true if commitlint should ignore the given message. - */ - ignores?: ((message: string) => boolean)[]; - /* - * Whether commitlint uses the default ignore rules. - */ - defaultIgnores?: boolean; - /* - * Custom URL to show upon failure - */ - helpUrl?: string; -}; +import type {UserConfig} from '@commitlint/types'; -const Configuration: Config = { +const Configuration: UserConfig = { /* * Resolve and load @commitlint/config-conventional from node_modules. * Referenced packages must be installed