{"record":{"id":"5a096330b0bfd014","repo":"oxc-project/oxc","slug":"nexttick-expects-zero-or-one-parameters","errorCode":null,"errorMessage":"`nextTick` expects zero or one parameters.","messagePattern":"`nextTick` expects zero or one parameters\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/valid_next_tick.rs","lineNumber":26,"sourceCode":"\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    ///\n    /// Enforce valid `nextTick` function calls.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// `nextTick` is a function that takes either a callback or returns a Promise.","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/valid_next_tick.rs#L8-L44","documentation":"Diagnostic from the oxlint rule `vue/valid-next-tick`. In `check_call`, if a matched nextTick call has more than one argument (`call.arguments.len() > 1`), the rule reports immediately (after the zero-arg branch, before the await/callback check). Vue's `nextTick` accepts zero or one parameter — a single callback; extra arguments are ignored at runtime, which almost always means the author believed extra params (e.g. error callbacks, `this` bindings à la `promise.then(cb, errCb)`) do something.","triggerScenarios":"`nt(callback, anotherCallback)`, `Vue.nextTick(cb, extra)`, or `this.$nextTick(cb, this)` inside a component instance method in a .vue file. Any matched spelling with 2+ arguments triggers; the diagnostic span is the `nextTick` property/identifier.","commonSituations":"Treating `nextTick` like a Node-style callback API and passing an error handler; pasting `.then(success, failure)` patterns onto nextTick; passing context as a second argument.","solutions":["Keep only the callback: `this.$nextTick(callback)`.","If you need error handling, use the Promise form: `await nt().catch(handleError)` or `nt().then(cb).catch(errCb)`.","If you need `this` binding, use an arrow function capturing `this` instead of passing it as an argument."],"exampleFix":"// before\nthis.$nextTick(callback, anotherCallback);\n\n// after\nthis.$nextTick(callback);","handlingStrategy":"validation","validationCode":"for (const m of src.matchAll(/(?:this\\.\\$nextTick|Vue\\.nextTick|\\bnt)\\s*\\(([^)]*)\\)/g)) {\n  if (m[1].split(',').filter(s => s.trim()).length > 1) {\n    console.warn(`nextTick called with multiple args: ${m[0]}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["nextTick takes at most one callback; use .catch() for error handling instead of a second argument.","Do not port promise.then(success, failure) argument layouts onto nextTick."],"tags":["vue","nexttick","lint","too-many-arguments"],"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-14T05:17:10.506Z"}