Skip to content

Commit 3f393e3

Browse files
docs(linter): Add configuration option docs for promise/no-callback-in-promise rule. (#15176)
Part of #14743. Generated docs: ```md ## Configuration This rule accepts a configuration object with the following properties: ### callbacks type: `string[]` default: `["callback", "cb", "done", "next"]` List of callback function names to check for within Promise `then` and `catch` methods. ### exceptions type: `string[]` default: `[]` List of callback function names to allow within Promise `then` and `catch` methods. ``` --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 5c2df4c commit 3f393e3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

crates/oxc_linter/src/rules/promise/no_callback_in_promise.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use oxc_ast::{
55
use oxc_diagnostics::OxcDiagnostic;
66
use oxc_macros::declare_oxc_lint;
77
use oxc_span::{CompactStr, GetSpan, Span};
8+
use schemars::JsonSchema;
89

910
use crate::{AstNode, context::LintContext, rule::Rule};
1011

@@ -17,14 +18,21 @@ fn no_callback_in_promise_diagnostic(span: Span) -> OxcDiagnostic {
1718
#[derive(Debug, Default, Clone)]
1819
pub struct NoCallbackInPromise(Box<NoCallbackInPromiseConfig>);
1920

20-
#[derive(Debug, Clone)]
21+
#[derive(Debug, Clone, JsonSchema)]
22+
#[serde(rename_all = "camelCase", default)]
2123
pub struct NoCallbackInPromiseConfig {
24+
/// List of callback function names to check for within Promise `then` and `catch` methods.
2225
callbacks: Vec<CompactStr>,
26+
/// List of callback function names to allow within Promise `then` and `catch` methods.
27+
exceptions: Vec<CompactStr>,
2328
}
2429

2530
impl Default for NoCallbackInPromiseConfig {
2631
fn default() -> Self {
27-
Self { callbacks: vec!["callback".into(), "cb".into(), "done".into(), "next".into()] }
32+
Self {
33+
callbacks: vec!["callback".into(), "cb".into(), "done".into(), "next".into()],
34+
exceptions: Vec::new(),
35+
}
2836
}
2937
}
3038

@@ -72,6 +80,7 @@ declare_oxc_lint!(
7280
NoCallbackInPromise,
7381
promise,
7482
correctness,
83+
config = NoCallbackInPromiseConfig,
7584
);
7685

7786
impl Rule for NoCallbackInPromise {

0 commit comments

Comments
 (0)