-
Notifications
You must be signed in to change notification settings - Fork 965
fix(types): incorrect types for rule options #4633
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
+63
−7
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a3ca58e
test(types): add type-check regression tests for "as const" compatibi…
Zamiell fdcf183
fix(types): use readonly arrays for "as const" compatibility
Zamiell 38d91ac
Revert "fix(types): use readonly arrays for "as const" compatibility"
Zamiell 97677fd
Reapply "fix(types): use readonly arrays for "as const" compatibility"
Zamiell dd3f919
chore: remove comments
Zamiell 7151875
Update @commitlint/types/src/rules.test-d.ts
Zamiell f265f0d
Update @commitlint/types/src/rules.test-d.ts
Zamiell 9b86ef2
chore: squash 2 commits
Zamiell b30c921
Revert "chore: squash 2 commits"
Zamiell f6ed794
fix: comment
Zamiell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /** | ||
| * Tests for "as const" compatibility: | ||
| * https://github.com/conventional-changelog/commitlint/pull/4633 | ||
| * | ||
| * These are compile-time type checks (no runtime behavior). If a line fails to compile, the | ||
| * associated type definition needs to be fixed. | ||
| */ | ||
|
|
||
| import { RuleConfigSeverity, type RulesConfig } from "./index.js"; | ||
|
|
||
| const ERROR = RuleConfigSeverity.Error; | ||
|
|
||
| const _scopeEnumObject = [ | ||
| ERROR, | ||
| "always", | ||
| { scopes: ["foo", "bar"] as const }, | ||
| ] as const; | ||
| const _scopeEnumObjectCheck: Partial<RulesConfig> = { | ||
| "scope-enum": _scopeEnumObject, | ||
| }; | ||
| void _scopeEnumObjectCheck; | ||
|
|
||
| // Simple array form: regression check that the array-form enum config | ||
| // remains assignable to RulesConfig when using `as const`. | ||
| const _scopeEnumSimple = [ERROR, "always", ["foo", "baz", "baz"]] as const; | ||
| const _scopeEnumSimpleCheck: Partial<RulesConfig> = { | ||
| "scope-enum": _scopeEnumSimple, | ||
| }; | ||
| void _scopeEnumSimpleCheck; | ||
|
|
||
| const _scopeCaseObject = [ | ||
| ERROR, | ||
| "always", | ||
| { cases: ["camel-case"] as const, delimiters: ["-"] as const }, | ||
| ] as const; | ||
| const _scopeCaseObjectCheck: Partial<RulesConfig> = { | ||
| "scope-case": _scopeCaseObject, | ||
| }; | ||
| void _scopeCaseObjectCheck; | ||
|
|
||
| // Simple array form: ensure CaseRuleConfig accepts readonly arrays. | ||
| const _scopeCaseSimple = [ERROR, "always", ["camel-case"]] as const; | ||
| const _scopeCaseSimpleCheck: Partial<RulesConfig> = { | ||
| "scope-case": _scopeCaseSimple, | ||
| }; | ||
| void _scopeCaseSimpleCheck; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.