Skip to content

docs: show config example in ts and js #2232 #2424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions docs/reference-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,57 @@ The file is expected
- export a configuration object
- adhere to the schema outlined below

```ts
type Config = {
## Configuration object example

### JavaScript

```js
const Configuration = {
/*
* Resolveable ids to commitlint configurations to extend
* Resolve and load @commitlint/config-conventional from node_modules.
* Referenced packages must be installed
*/
extends?: string[];
extends: ['@commitlint/config-conventional'],
/*
* Resolveable id to conventional-changelog parser preset to import and use
* Resolve and load conventional-changelog-atom from node_modules.
* Referenced packages must be installed
*/
parserPreset?: string;
parserPreset: 'conventional-changelog-atom',
/*
* Resolveable id to package, from node_modules, which formats the output.
* Resolve and load @commitlint/format from node_modules.
* Referenced package must be installed
*/
formatter: string;
formatter: '@commitlint/format',
/*
* Rules to check against
* Any rules defined here will override rules from @commitlint/config-conventional
*/
rules?: {[name: string]: Rule};
rules: {
'type-enum': [2, 'always', ['foo']],
},
/*
* Functions that return true if commitlint should ignore the given message.
*/
ignores?: ((message: string) => boolean)[];
ignores: [(commit) => commit === ''],
/*
* Whether commitlint uses the default ignore rules.
*/
defaultIgnores?: boolean;
defaultIgnores: true,
/*
* Custom URL to show upon failure
*/
helpUrl?: string;
helpUrl:
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
};

const Configuration: Config = {
module.exports = Configuration;
```

### TypeScript

```ts
import type {UserConfig} from '@commitlint/types';

const Configuration: UserConfig = {
/*
* Resolve and load @commitlint/config-conventional from node_modules.
* Referenced packages must be installed
Expand Down