exports-last
Ensure all exports appear after other statements
💼 This rule is enabled in the following configs: recommended, typescript.
Rule Details
A module whose export statements all sit at the end shows its public surface in one place. This rule reports an export statement (export { a }, export default a, export * from 'm') that is followed by a statement that is not an export.
An inline declaration export (export const x = 1, export function f() {}) is exempt by design: it declares and exports in one statement and is written where the declaration belongs. It is not reported, and it does not push the export statements before it down either.
Imports after an export are a matter for first, not this rule.
❌ Incorrect
const a = 1;
export { a };
const b = 2;
export default run;
function run() {}✅ Correct
const a = 1;
const b = 2;
export { a, b };
export const c = 3;
const d = 4;
export default d;Options
[]No options.
When Not To Use It
When you prefer each export statement next to the code it exports.
Use this rule
npm install -D oxlint-plugin-import-next{ "jsPlugins": ["oxlint-plugin-import-next"], "rules": { "import-next/exports-last": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-import-next'], rules: { 'import-next/exports-last': 'error', }, },});oxlint-plugin-import-next re-exports eslint-plugin-import-next/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.