Can't use async rule configuration
See original GitHub issueExpected Behavior
In a typescript project, provide an asynchronous list for the scope-enum rule, as described in the doc https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md
Current Behavior
Typescript complains of a type mismatch and the code is not compiled
Affected packages
- types
Possible Solution
I don’t think the QualifiedConfig type is correct for the async option. It should probably be (() => Promise<RuleConfigTuple<T>>)
instead.
Steps to Reproduce (for bugs)
- Try to compile the typescript configuration provided to javascript with
tsc
commitlint.config.ts
import type { RulesConfig } from '@commitlint/types';
import { RuleConfigSeverity } from '@commitlint/types';
const { Error } = RuleConfigSeverity;
export const rules: Partial<RulesConfig> = {
'scope-enum': () => Promise.resolve([Error, 'always', ['one', 'two', 'three']]),
};
export default {
rules,
};
Context
I want to restrict commit scopes to a predefined list that cannot be defined synchronously. I have to define a custom rule/plugin to work around this issue.
Your Environment
Executable | Version |
---|---|
commitlint --version |
14.1.0 |
git --version |
V2.33.1 |
node --version |
v16.12.0 |
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Async/Await - Best Practices in Asynchronous Programming
Async all the way, Don't mix blocking and async code, Console main method. Configure context, Use ConfigureAwait(false) when you can, Methods that require ......
Read more >Is it possible to use async await in rules? - Auth0 Community
Yes, you can use async/await in a rule. You can use it in a function that you define, or you can use it...
Read more >How do I get a warning in Visual Studio when async methods ...
From Options,. Go to Text Editor → Basic → Code Style → Naming; Select Manage Specifications and Add New Specification; Select Method, ...
Read more >Can't use async functions and generators · Issue #17 - GitHub
I've found that regeneratorRuntime is disabled. I'm trying to run react-coroutine in the setup of preact and preact-cli but I'm not able to...
Read more >How we can assure Async Business rule run and how
Hi. I have created a REST outbound service API and while testing i successfully called the 3rd party API. Using the preview script...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yes all existing tests are fine with the change
agree, that looks like the right place, thanks
I’ll open the PR once I have the time to add a couple tests
No rush, thanks a lot!