{"record":{"id":"fc91da9535b8ff4f","repo":"oxc-project/oxc","slug":"avoid-using-non-standard-promise-prop-name-met","errorCode":null,"errorMessage":"Avoid using non-standard `Promise.{prop_name}` method.","messagePattern":"Avoid using non-standard `Promise\\.(.+?)` method\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/promise/spec_only.rs","lineNumber":17,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_str::CompactStr;\nuse rustc_hash::FxHashSet;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::PROMISE_STATIC_METHODS,\n};\n\nfn spec_only(prop_name: &str, member_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Avoid using non-standard `Promise.{prop_name}` method.\"))\n        .with_label(member_span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct SpecOnly(Box<SpecOnlyConfig>);\n\n#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct SpecOnlyConfig {\n    /// List of Promise static methods that are allowed to be used.\n    allowed_methods: Option<FxHashSet<CompactStr>>,\n}\n\nimpl std::ops::Deref for SpecOnly {\n    type Target = SpecOnlyConfig;\n\n    fn deref(&self) -> &Self::Target {\n        &self.0","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/promise/spec_only.rs#L1-L35","documentation":"Diagnostic from the oxlint rule `promise/spec-only` (plugin `promise`, category `restriction`). It fires on member expressions whose object is exactly the identifier `Promise` and whose static property name is NOT in the built-in PROMISE_STATIC_METHODS allowlist (the standard set: resolve, reject, all, allSettled, any, race, try, withResolvers, ...) and not whitelisted via the `allowedMethods` config option (case-sensitive set). Note it fires on property access alone - `getA(Promise.done)` is flagged even without a call. Non-standard statics tie code to specific libraries (e.g. Bluebird) or polyfills and cost maintenance.","triggerScenarios":"`Promise.done()`; `Promise.map(items, fn)` (Bluebird); `Promise.promisify(fn)`; any `Promise.<unknown>()` access; a method listed in `allowedMethods` with different casing (matching is case-sensitive per the tests).","commonSituations":"Bluebird-era codebases; legacy `Promise.done` used as terminal catch; polyfills adding statics to the global; enabling the `restriction` category during an oxlint adoption.","solutions":["Replace with a standard equivalent: `Promise.done(p)` becomes `p.catch(err => console.error(err))`","Whitelist intentional extensions: `{ \"allowedMethods\": [\"map\", \"done\"] }` (exact case)","Import the extension library under its own namespace (`Promise = require('bluebird')` locally) instead of relying on the patched global"],"exampleFix":"// before\nPromise.done(fetchThing())\n\n// after\nfetchThing().catch(err => console.error(err))","handlingStrategy":"validation","validationCode":"npx oxlint --promise/spec-only src/\n# intentional extensions:\n#   { \"rules\": { \"promise/spec-only\": [\"error\", { \"allowedMethods\": [\"map\", \"done\"] }] } }","typeGuard":"// Constrain static access to the spec surface at the type level:\ntype PromiseStatic =\n  | 'resolve' | 'reject' | 'all' | 'allSettled'\n  | 'any' | 'race' | 'try' | 'withResolvers';\nconst isSpecStatic = (name: string): name is PromiseStatic =>\n  ['resolve', 'reject', 'all', 'allSettled', 'any', 'race', 'try', 'withResolvers'].includes(name);","tryCatchPattern":null,"preventionTips":["Use standard statics; reach for `Promise.all`/`Promise.allSettled` instead of library combinators","Import extension libraries under their own namespace rather than patched globals","Keep the `allowedMethods` whitelist in shared config, exact case (matching is case-sensitive)"],"tags":["promise","async","lint","portability","oxlint"],"backgroundTag":"non-standard-promise-statics","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}