{"record":{"id":"fb65f1137a30a4b6","repo":"oxc-project/oxc","slug":"promise-constructor-parameters-must-be-named-to-ma","errorCode":null,"errorMessage":"Promise constructor parameters must be named to match `{pattern}`","messagePattern":"Promise constructor parameters must be named to match `(.+?)`","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/promise/param_names.rs","lineNumber":21,"sourceCode":"use serde::Deserialize;\n\nuse oxc_ast::{\n    AstKind,\n    ast::{BindingPattern, Expression, FormalParameter, FormalParameters},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::deserialize_regex_option,\n};\n\nfn param_names_diagnostic(span: Span, pattern: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Promise constructor parameters must be named to match `{pattern}`\"\n    ))\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ParamNames(Box<ParamNamesConfig>);\n\n#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]\n#[serde(deny_unknown_fields, rename_all = \"camelCase\", default)]\npub struct ParamNamesConfig {\n    /// Regex pattern used to validate the `resolve` parameter name. If provided, this pattern\n    /// is used instead of the default `^_?resolve$` check.\n    #[serde(default, deserialize_with = \"deserialize_regex_option\")]\n    resolve_pattern: Option<Regex>,\n    /// Regex pattern used to validate the `reject` parameter name. If provided, this pattern\n    /// is used instead of the default `^_?reject$` check.\n    #[serde(default, deserialize_with = \"deserialize_regex_option\")]","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/promise/param_names.rs#L3-L39","documentation":"Diagnostic from the oxlint rule `promise/param-names` (plugin `promise`, category `style`). The Promise constructor uses the Revealing Constructor pattern: `new Promise(executor)` passes `(resolve, reject)` positionally. This rule enforces conventional names so readers never have to check the order: by default the first parameter must match `^_?resolve$` and the second `^_?reject$`; the `resolvePattern`/`rejectPattern` config options (regex strings) replace those defaults. It only checks `new Promise(...)` calls with exactly one argument that is a function or arrow expression, and only plain `BindingIdentifier` parameters.","triggerScenarios":"`new Promise(function (reject, resolve) {})` (swapped order); `new Promise((ok, fail) => {})` (non-standard names); `new Promise(yes => {})`; or standard names that fail a custom configured pattern.","commonSituations":"Teams porting eslint-plugin-promise configs to oxlint; code that deliberately uses domain-specific names and needs the pattern options; accidental parameter swaps that still 'work' but read dangerously.","solutions":["Rename the executor parameters to `resolve` and `reject` (an optional leading underscore for unused ones is allowed)","If custom names are a team convention, configure them: `{ \"resolvePattern\": \"^yes$\", \"rejectPattern\": \"^no$\" }`","For promisifying libraries, prefer `util.promisify` so no executor is written at all"],"exampleFix":"// before\nnew Promise((ok, fail) => {\n  doWork().then(ok, fail)\n})\n\n// after\nnew Promise((resolve, reject) => {\n  doWork().then(resolve, reject)\n})","handlingStrategy":"validation","validationCode":"npx oxlint --promise/param-names src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on `(resolve, reject)` - never swapped, never renamed","If custom names are required, encode them in shared config (`resolvePattern`/`rejectPattern`) not per file","Prefer `util.promisify` so executors disappear entirely"],"tags":["promise","async","lint","naming-convention","oxlint"],"backgroundTag":"promise-constructor-param-names","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}