{"record":{"id":"2fb054f1976d12c3","repo":"oxc-project/oxc","slug":"prefer-using-inline-type-specifiers-instead-of-a-t","errorCode":null,"errorMessage":"Prefer using inline type specifiers instead of a top-level type-only import.","messagePattern":"Prefer using inline type specifiers instead of a top-level type-only import\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/import/consistent_type_specifier_style.rs","lineNumber":47,"sourceCode":"    .with_label(span)\n}\n\nfn consistent_type_specifier_style_diagnostic(span: Span, mode: &Mode) -> OxcDiagnostic {\n    let (warn_msg, help_msg) = match mode {\n        Mode::Inline => (\n            \"Prefer using inline type specifiers instead of a top-level type-only import.\",\n            \"Replace top‐level import type with an inline type specifier.\",\n        ),\n        Mode::TopLevel => (\n            \"Prefer using a top-level type-only import instead of inline type specifiers.\",\n            \"Replace inline type specifiers with a top‐level import type statement.\",\n        ),\n        Mode::TopLevelIfOnlyTypeImports => (\n            \"Prefer using a top-level type-only import instead of inline type specifiers when there are only type imports.\",\n            \"Replace inline type specifiers with a top‐level import type statement.\",\n        ),\n    };\n    OxcDiagnostic::warn(warn_msg).with_help(help_msg).with_label(span)\n}\n\n#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema)]\nenum Mode {\n    /// Prefer `import type { Foo } from 'foo'` for type imports.\n    #[default]\n    #[serde(rename = \"prefer-top-level\")]\n    TopLevel,\n    /// Prefer `import { type Foo } from 'foo'` for type imports.\n    #[serde(rename = \"prefer-inline\")]\n    Inline,\n    /// Prefer `import type { Foo } from 'foo'` when all named imports are types, but allow\n    /// `import { type Foo, bar } from 'foo'` when value imports are present.\n    #[serde(rename = \"prefer-top-level-if-only-type-imports\")]\n    TopLevelIfOnlyTypeImports,\n}\n\n#[derive(Debug, Default, Clone, Serialize, Deserialize)]","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/consistent_type_specifier_style.rs#L29-L65","documentation":"The `prefer-inline` mode of `import/consistent-type-specifier-style`: type-only imports should use inline `{ type Foo }` specifiers rather than a top-level `import type` statement (declaration-file imports excepted — they always require top-level). The rule's fixer can rewrite the statement into the inline form.","triggerScenarios":"Rule configured as `[\"error\", \"prefer-inline\"]` and code containing `import type { Foo } from 'foo';` where the imported source is not a declaration file.","commonSituations":"Teams standardizing on inline specifiers to keep type and value imports from one module in a single statement; configs migrated away from the prefer-top-level default; codemods that emit top-level import type into an inline-style repo.","solutions":["Change to `import { type Foo } from 'foo';`","Merge the type specifier into an existing value import from the same module: `import { bar, type Foo } from 'foo';`","Apply `oxlint --fix` for a repo-wide conversion"],"exampleFix":"// before\nimport type { Foo } from 'foo';\nimport { bar } from 'foo';\n\n// after\nimport { type Foo, bar } from 'foo';","handlingStrategy":"validation","validationCode":"// .oxlintrc.json\n{\n  \"plugins\": [\"import\"],\n  \"rules\": { \"import/consistent-type-specifier-style\": [\"warn\", \"prefer-inline\"] }\n}\n// CI gate: npx oxlint src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one specifier style per repo and encode it in the rule config","Use oxlint --fix when flipping modes so existing imports convert in bulk","Remember declaration-file imports are exempt — they always use import type","Keep codemods' output linted in the same CI job as hand-written code"],"tags":["lint","oxlint","import-plugin","typescript","esm","style"],"backgroundTag":"type-only-import-style","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"}