oxc-project/oxc · info · OxcDiagnostic

Use the Promise returned by `nextTick` instead of passing a

Error message

Use the Promise returned by `nextTick` instead of passing a callback function.

What it means

Diagnostic from oxlint's vue/next-tick-style rule (style, autofixable, since oxlint 1.69.0). With the default "promise" option it fires when a callback is passed to nextTick instead of using the returned Promise. Mixing both styles hurts readability; the Promise form composes with async/await. The rule recognizes this.$nextTick, Vue.nextTick, and imported nextTick (via is_vue_next_tick_import).

Source

Thrown at crates/oxc_linter/src/rules/vue/next_tick_style.rs:17

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};

use crate::{
    AstNode,
    context::LintContext,
    rule::{DefaultRuleConfig, Rule},
    utils::{is_this_object, is_vue_next_tick_import},
};

fn use_promise_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(
        "Use the Promise returned by `nextTick` instead of passing a callback function.",
    )
    .with_label(span)
}

fn use_callback_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(
        "Pass a callback function to `nextTick` instead of using the returned Promise.",
    )
    .with_label(span)
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
enum NextTickOption {
    /// Require using the Promise returned by `nextTick`.
    #[default]
    #[serde(rename = "promise")]
    Promise,

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Use the Promise: await this.$nextTick() inside an async method, or this.$nextTick().then(cb)
  2. Run oxlint --fix to autofix (the rule is marked fix)
  3. If the team prefers callbacks, set the option to "callback"

Example fix

// before (option "promise", the default)
this.$nextTick(() => { this.focusInput() })
// after
await this.$nextTick()
this.focusInput()
Defensive patterns

Strategy: validation

Validate before calling

# find callback-style nextTick calls before enforcing "promise"
grep -rnE "(this\.)?\$?nextTick\(\s*[A-Za-z$_(]" --include='*.vue' --include='*.js' src

Prevention

When it happens

Trigger: Rule at default (NextTickOption::Promise) and code contains `this.$nextTick(() => {...})`, `Vue.nextTick(cb)`, or `import { nextTick } from 'vue'; nextTick(cb)`.

Common situations: Codebases migrating from Vue 2 habits (callback-style nextTick) to Vue 3 async/await style; enabling the vue style preset in oxlint and having legacy callback calls flagged.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/7ead476e764751c1. Report an issue: GitHub.