{"record":{"id":"40894428dd9be237","repo":"oxc-project/oxc","slug":"expected-curr-kind-syntax-before-prev-kind","errorCode":null,"errorMessage":"Expected '{curr_kind}' syntax before '{prev_kind}' syntax.","messagePattern":"Expected '(.+?)' syntax before '(.+?)' syntax\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"info","filePath":"crates/oxc_linter/src/rules/eslint/sort_imports.rs","lineNumber":27,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse oxc_str::Ident;\nuse rustc_hash::FxHashSet;\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn unexpected_syntax_order_diagnostic(\n    curr_kind: &ImportKind,\n    prev_kind: &ImportKind,\n    span: Span,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Expected '{curr_kind}' syntax before '{prev_kind}' syntax.\"))\n        .with_label(span)\n}\n\nfn sort_imports_alphabetically_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Imports should be sorted alphabetically.\").with_label(span)\n}\n\nfn sort_members_alphabetically_diagnostic(name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Member '{name}' of the import declaration should be sorted alphabetically.\"\n    ))\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct SortImports(Box<SortImportsOptions>);\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/sort_imports.rs#L9-L45","documentation":"oxlint `eslint/sort-imports`: two consecutive import declarations appear in the wrong order by member-syntax kind. `unexpected_syntax_order_diagnostic` (sort_imports.rs:27) formats 'Expected \\'{curr_kind}\\' syntax before \\'{prev_kind}\\' syntax.' Kinds are None (`import \"x\"`), All (`import * as x`), Multiple (`import {a, b}`), Single (`import x` / `import {a}`), and the default memberSyntaxSortOrder is none, all, multiple, single (confirmed by the ImportKind defaults at sort_imports.rs:350-353).","triggerScenarios":"With default order, `import a from 'a.js'` (Single) followed by `import * as b from 'b.js'` (All) — the All import should have come first, so the second declaration is flagged 'Expected \\'All\\' syntax before \\'Single\\' syntax.' Only the leading, contiguous block of import statements is checked (run_once breaks at the first non-import statement).","commonSituations":"New imports appended at the top of file without reordering; different team members using different import styles; adopting sort-imports on an existing codebase.","solutions":["Reorder the declarations to match memberSyntaxSortOrder, then alphabetical order within the same kind.","Change the order to match your convention: `{ \"memberSyntaxSortOrder\": [\"single\", \"multiple\", \"all\", \"none\"] }` (all 4 kinds must be listed).","Set `ignoreDeclarationSort: true` to stop checking declaration order entirely (member sort still applies).","Enable `allowSeparatedGroups: true` so blank-line-separated groups are sorted independently."],"exampleFix":"// before\nimport z from 'z.js';\nimport * as a from 'a.js';\n\n// after (default order: none, all, multiple, single)\nimport * as a from 'a.js';\nimport z from 'z.js';","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide the memberSyntaxSortOrder once and encode it in `.oxlintrc.json` (all 4 kinds must be listed).","Use an editor's 'organize imports' action so syntax-kind ordering stays correct automatically.","When adding an import of a different kind (e.g. `import * as x` next to existing default imports), place it per the configured order."],"tags":["eslint","oxlint","imports","sorting","style","lint"],"backgroundTag":"import-sorting","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"}