Skip to content

Commit 53f6ebd

Browse files
committed
docs: use
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent e90f28c commit 53f6ebd

13 files changed

+200
-23
lines changed

Diff for: .eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ yarn.lock
1919
!**/__fixtures__/**/node_modules/
2020
!**/typings/**/dist/
2121
!.codecov.yml
22-
!.commitlintrc.json
22+
!.commitlintrc.*
2323
!.cspell.json
2424
!.github/
2525
!.graphqlrc.yml

Diff for: .eslintrc.base.cjs

+51-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const config = {
5353
parser: '@typescript-eslint/parser',
5454
parserOptions: {
5555
extraFileExtensions: [],
56-
project: './tsconfig.json',
56+
project: ['./tsconfig.json', 'tsconfig.cjs.json'],
5757
sourceType: require('./package.json').type,
5858
tsconfigRootDir: process.cwd(),
5959
warnOnUnsupportedTypeScriptVersion: true
@@ -991,6 +991,56 @@ const config = {
991991
plugins: ['markdown', 'markdownlint'],
992992
processor: 'markdown/markdown'
993993
},
994+
{
995+
files: '**/*.md/*.+(cjs|cts|js|jsx|mjs|mts|ts|tsx)',
996+
parserOptions: { project: false },
997+
rules: {
998+
'@typescript-eslint/await-thenable': 0,
999+
'@typescript-eslint/consistent-type-exports': 0,
1000+
'@typescript-eslint/dot-notation': 0,
1001+
'@typescript-eslint/naming-convention': 0,
1002+
'@typescript-eslint/no-base-to-string': 0,
1003+
'@typescript-eslint/no-confusing-void-expression': 0,
1004+
'@typescript-eslint/no-floating-promises': 0,
1005+
'@typescript-eslint/no-for-in-array': 0,
1006+
'@typescript-eslint/no-implied-eval': 0,
1007+
'@typescript-eslint/no-meaningless-void-operator': 0,
1008+
'@typescript-eslint/no-misused-promises': 0,
1009+
'@typescript-eslint/no-mixed-enums': 0,
1010+
'@typescript-eslint/no-redundant-type-constituents': 0,
1011+
'@typescript-eslint/no-throw-literal': 0,
1012+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 0,
1013+
'@typescript-eslint/no-unnecessary-condition': 0,
1014+
'@typescript-eslint/no-unnecessary-qualifier': 0,
1015+
'@typescript-eslint/no-unnecessary-type-arguments': 0,
1016+
'@typescript-eslint/no-unnecessary-type-assertion': 0,
1017+
'@typescript-eslint/no-unsafe-argument': 0,
1018+
'@typescript-eslint/no-unsafe-assignment': 0,
1019+
'@typescript-eslint/no-unsafe-call': 0,
1020+
'@typescript-eslint/no-unsafe-member-access': 0,
1021+
'@typescript-eslint/no-unsafe-return': 0,
1022+
'@typescript-eslint/non-nullable-type-assertion-style': 0,
1023+
'@typescript-eslint/prefer-includes': 0,
1024+
'@typescript-eslint/prefer-nullish-coalescing': 0,
1025+
'@typescript-eslint/prefer-readonly': 0,
1026+
'@typescript-eslint/prefer-readonly-parameter-types': 0,
1027+
'@typescript-eslint/prefer-reduce-type-parameter': 0,
1028+
'@typescript-eslint/prefer-regexp-exec': 0,
1029+
'@typescript-eslint/prefer-return-this-type': 0,
1030+
'@typescript-eslint/prefer-string-starts-ends-with': 0,
1031+
'@typescript-eslint/promise-function-async': 0,
1032+
'@typescript-eslint/require-array-sort-compare': 0,
1033+
'@typescript-eslint/require-await': 0,
1034+
'@typescript-eslint/restrict-plus-operands': 0,
1035+
'@typescript-eslint/restrict-template-expressions': 0,
1036+
'@typescript-eslint/return-await': 0,
1037+
'@typescript-eslint/strict-boolean-expressions': 0,
1038+
'@typescript-eslint/switch-exhaustiveness-check': 0,
1039+
'@typescript-eslint/unbound-method': 0,
1040+
'jsdoc/require-file-overview': 0,
1041+
'unicorn/filename-case': 0
1042+
}
1043+
},
9941044
{
9951045
files: '**/*.yml',
9961046
parser: 'yaml-eslint-parser',

Diff for: .eslintrc.cjs

-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010
*/
1111
const config = {
1212
extends: ['./.eslintrc.base.cjs'],
13-
overrides: [
14-
...require('./.eslintrc.base.cjs').overrides,
15-
{
16-
files: ['src/toggle.ts'],
17-
rules: {
18-
'unicorn/prefer-json-parse-buffer': 0
19-
}
20-
}
21-
],
2213
root: true
2314
}
2415

Diff for: .github/workflows/ci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ jobs:
150150
with:
151151
key: ${{ runner.os }}-${{ github.run_id }}
152152
path: ${{ env.CACHE_PATH }}
153+
- id: build
154+
name: Build project
155+
run: yarn build
153156
- id: lint
154157
name: Check lint status
155158
run: yarn check:lint
@@ -208,6 +211,10 @@ jobs:
208211
with:
209212
key: ${{ runner.os }}-${{ github.run_id }}
210213
path: ${{ env.CACHE_PATH }}
214+
- id: build
215+
if: matrix.typescript-version == needs.metadata.outputs.version-typescript
216+
name: Build project
217+
run: yarn build
211218
- id: typescript
212219
name: Install typescript@${{ matrix.typescript-version }}
213220
run: yarn add -D typescript@${{ matrix.typescript-version }}

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ RELEASE_NOTES.md
7272

7373
# Misc
7474
# ------------------------------------------------------------------------------
75-
**/scratch.ts
75+
**/scratch.*

Diff for: README.md

+52-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Shareable [`commitlint`][1] config enforcing [conventional commits][2]
1717
- [When should I use this?](#when-should-i-use-this)
1818
- [Install](#install)
1919
- [Use](#use)
20+
- [Customizing scopes and types](#customizing-scopes-and-types)
2021
- [API](#api)
2122
- [Types](#types)
2223
- [Enums](#enums)
@@ -57,15 +58,59 @@ yarn add -D @flex-development/commitlint-config@flex-development/commitlint-conf
5758

5859
## Use
5960

60-
**TODO**: usage example.
61+
```sh
62+
echo '{\n "extends": "@flex-development"\n}' > .commitlintrc.json
63+
commitlint --from HEAD~1 --to HEAD --verbose
64+
```
65+
66+
### Customizing scopes and types
67+
68+
Due to [an unresolved `commitlint` issue][7], extended `commitlint` configurations do not concatenate [`scope-enum`][8],
69+
nor [`type-enum`][9]. Follow the example below to customize commit scopes and types losslessly.
70+
71+
```sh
72+
touch .commitlintrc.cts
73+
```
74+
75+
```ts
76+
/**
77+
* @file Configuration - commitlint
78+
* @module config/commitlint
79+
* @see https://commitlint.js.org
80+
*/
81+
82+
import {
83+
RuleConfigSeverity as Severity,
84+
type UserConfig
85+
} from '@commitlint/types'
86+
import { scopes } from '@flex-development/commitlint-config'
87+
88+
/**
89+
* `commitlint` configuration object.
90+
*
91+
* @const {UserConfig} config
92+
*/
93+
const config: UserConfig = {
94+
extends: ['@flex-development'],
95+
rules: {
96+
'scope-enum': [Severity.Error, 'always', scopes(['bundle', 'transpile'])]
97+
}
98+
}
99+
100+
export default config
101+
```
102+
103+
You may need to set [`TS_NODE_PROJECT`][10] if running `commitlint` from the command line.
104+
105+
See [`docs/examples/commitlint.config.cjs`](docs/examples/commitlint.config.cjs) for an example config written in pure CommonJS.
61106

62107
## API
63108

64109
**TODO**: api documentation.
65110

66111
## Types
67112

68-
This package is fully typed with [TypeScript][7].
113+
This package is fully typed with [TypeScript][11].
69114

70115
### Enums
71116

@@ -103,4 +148,8 @@ See [`CONTRIBUTING.md`](CONTRIBUTING.md).
103148
[4]: https://commitlint.js.org/#/guides-use-prompt
104149
[5]: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog
105150
[6]: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser
106-
[7]: https://www.typescriptlang.org
151+
[7]: https://github.com/conventional-changelog/commitlint/issues/528
152+
[8]: https://commitlint.js.org/#/reference-rules?id=scope-enum
153+
[9]: https://commitlint.js.org/#/reference-rules?id=type-enum
154+
[10]: https://typestrong.org/ts-node/docs/options#project
155+
[11]: https://www.typescriptlang.org

Diff for: __tests__/ts/v4/tsconfig.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
"#fixtures/*": ["__fixtures__/*"],
3333
"#src": ["src/index"],
3434
"#src/*": ["src/*"],
35-
"#tests/*": ["__tests__/*"],
36-
"@flex-development/commitlint-config": ["src/index"]
35+
"#tests/*": ["__tests__/*"]
3736
},
3837
"preserveConstEnums": true,
3938
"preserveSymlinks": false,
@@ -51,5 +50,5 @@
5150
"useUnknownInCatchVariables": true
5251
},
5352
"exclude": ["**/coverage", "**/dist", "**/node_modules"],
54-
"include": ["**/**.cjs", "**/**.mjs", "**/**.mts", "**/**.ts", "**/.*.cjs"]
53+
"include": ["**/**.mjs", "**/**.mts", "**/**.ts"]
5554
}

Diff for: __tests__/ts/v4/tsconfig.typecheck.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,13 @@
22
"compilerOptions": {
33
"target": "es2020"
44
},
5-
"extends": "./tsconfig.json"
5+
"extends": "./tsconfig.json",
6+
"include": [
7+
"**/**.cts",
8+
"**/**.mts",
9+
"**/**.ts",
10+
"**/.*.cts",
11+
"**/.*.mts",
12+
"**/.*.ts"
13+
]
614
}

Diff for: docs/examples/.commitlintrc.cts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @file Examples - .commitlintrc.cts
3+
* @module docs/examples/config/cts
4+
* @see https://commitlint.js.org
5+
*/
6+
7+
import {
8+
RuleConfigSeverity as Severity,
9+
type UserConfig
10+
} from '@commitlint/types'
11+
import { scopes } from '@flex-development/commitlint-config'
12+
13+
/**
14+
* `commitlint` configuration object.
15+
*
16+
* @const {UserConfig} config
17+
*/
18+
const config: UserConfig = {
19+
extends: ['@flex-development'],
20+
rules: {
21+
'scope-enum': [Severity.Error, 'always', scopes(['bundle', 'transpile'])]
22+
}
23+
}
24+
25+
export default config

Diff for: docs/examples/commitlint.config.cjs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @file Examples - commitlint.config.cjs
3+
* @module docs/examples/config/cjs
4+
* @see https://commitlint.js.org
5+
*/
6+
7+
const { RuleConfigSeverity: Severity } = require('@commitlint/types')
8+
const { scopes } = require('@flex-development/commitlint-config')
9+
10+
/**
11+
* `commitlint` configuration object.
12+
*
13+
* @type {import('@commitlint/types').UserConfig}
14+
* @const config
15+
*/
16+
const config = {
17+
extends: ['@flex-development'],
18+
rules: {
19+
'scope-enum': [Severity.Error, 'always', scopes(['bundle', 'transpile'])]
20+
}
21+
}
22+
23+
module.exports = config

Diff for: tsconfig.cjs.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"customConditions": ["require", "node"],
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
7+
"noEmit": false,
8+
"module": "commonjs",
9+
"moduleResolution": "nodenext",
10+
"outDir": ".",
11+
"verbatimModuleSyntax": false
12+
},
13+
"exclude": ["**/node_modules"],
14+
"extends": "./tsconfig.json",
15+
"include": ["**/**.cjs", "**/**.cts", "**/**.json", "**/.*.cjs", "**/.*.cts"]
16+
}

Diff for: tsconfig.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"alwaysStrict": false,
77
"baseUrl": ".",
88
"checkJs": false,
9+
"customConditions": ["import", "node"],
910
"declaration": false,
1011
"declarationMap": false,
1112
"emitDecoratorMetadata": false,
@@ -31,8 +32,7 @@
3132
"#fixtures/*": ["__fixtures__/*"],
3233
"#src": ["src/index"],
3334
"#src/*": ["src/*"],
34-
"#tests/*": ["__tests__/*"],
35-
"@flex-development/commitlint-config": ["src/index"]
35+
"#tests/*": ["__tests__/*"]
3636
},
3737
"preserveConstEnums": true,
3838
"preserveSymlinks": false,
@@ -53,5 +53,6 @@
5353
"verbatimModuleSyntax": true
5454
},
5555
"exclude": ["**/coverage", "**/dist", "**/node_modules"],
56-
"include": ["**/**.cjs", "**/**.mjs", "**/**.mts", "**/**.ts", "**/.*.cjs"]
56+
"include": ["**/**.mjs", "**/**.mts", "**/**.ts"],
57+
"references": [{ "path": "./tsconfig.cjs.json" }]
5758
}

Diff for: tsconfig.typecheck.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,13 @@
22
"compilerOptions": {
33
"target": "es2020"
44
},
5-
"extends": "./tsconfig.json"
5+
"extends": "./tsconfig.json",
6+
"include": [
7+
"**/**.cts",
8+
"**/**.mts",
9+
"**/**.ts",
10+
"**/.*.cts",
11+
"**/.*.mts",
12+
"**/.*.ts"
13+
]
614
}

0 commit comments

Comments
 (0)