{"record":{"id":"39f56f2ce180ea4c","repo":"oxc-project/oxc","slug":"await-the-promise-returned-by-nexttick-or-pass-a","errorCode":null,"errorMessage":"Await the Promise returned by `nextTick` or pass a callback function.","messagePattern":"Await the Promise returned by `nextTick` or pass a callback function\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/valid_next_tick.rs","lineNumber":21,"sourceCode":"    ast::{CallExpression, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::Rule,\n    utils::{is_in_vue_component_instance_method, is_this_object, is_vue_next_tick_import},\n};\n\nfn should_be_function_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`nextTick` is a function.\").with_label(span)\n}\n\nfn missing_callback_or_await_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Await the Promise returned by `nextTick` or pass a callback function.\")\n        .with_label(span)\n}\n\nfn too_many_parameters_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`nextTick` expects zero or one parameters.\").with_label(span)\n}\n\nfn either_await_or_callback_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Either await the Promise or pass a callback function to `nextTick`.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ValidNextTick;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/valid_next_tick.rs#L3-L39","documentation":"Diagnostic from the oxlint rule `vue/valid-next-tick`. In `check_call`, when a matched `nextTick`/`Vue.nextTick`/`this.$nextTick` call has zero arguments, the rule checks `is_awaited_promise`: the call is 'consumed' if its parent is an await expression, return statement, variable declarator, assignment, an expression-bodied arrow, a `.then` member access, or an element of an array inside a `Promise.*` call. If none apply, the floating call is reported — `nextTick()` returns a Promise, and discarding it means the following code runs before the DOM update flush.","triggerScenarios":"Zero-argument `nt()`, `Vue.nextTick()`, or `this.$nextTick()` inside a component instance method where the result is not consumed — plain expression statement in `mounted()`, or `async mounted() { nt(); ... }` without `await`. Accepted shapes include `await nt()`, `return nt()`, `const q = nt()`, `() => nt()`, `nt().then(cb)`, and `Promise.all([nt(), x])`.","commonSituations":"Porting `this.$nextTick(callback)` to Promise style and dropping both the callback and the `await`; calling `nextTick()` in non-async hooks where the author assumed it blocks; fire-and-forget calls left after refactors.","solutions":["Await it: make the hook async and write `await nextTick()` before code that depends on the DOM update.","Or chain it: `nextTick().then(() => { ... })`.","Or store/return the promise (`const q = nextTick()`) if you intentionally defer handling — the rule accepts those shapes.","If the call is genuinely fire-and-forget, add `void nextTick()` is NOT in the accepted parent list — restructure to one of the accepted forms instead."],"exampleFix":"// before\nasync mounted() {\n  this.$nextTick();\n  this.doSomethingWithDom();\n}\n\n// after\nasync mounted() {\n  await this.$nextTick();\n  this.doSomethingWithDom();\n}","handlingStrategy":"validation","validationCode":"// crude: zero-arg nextTick() call not preceded by await and not followed by .then\nconst re = /(?<!await\\s)(?:this\\.\\$nextTick|Vue\\.nextTick|\\bnt)\\s*\\(\\s*\\)(?!\\s*\\.)/g;\nif (re.test(src)) console.warn('Floating nextTick() call — its Promise is discarded');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make the enclosing hook async and await the call whenever later code touches the DOM.","Prefer the awaited Promise style consistently across the codebase."],"tags":["vue","nexttick","async","promise","lint"],"backgroundTag":"vue-nexttick-misuse","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"}