For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/eslint/sort-imports.md.
close

sort-imports

Added in v0.8.2

Configuration

rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'sort-imports': 'error',
    },
  },
]);

Rule Details

This rule enforces a consistent order for import declarations and for named members within an import declaration.

Examples of incorrect code for this rule:

import b from "b";
import a from "a";
import { z, a } from "values";

Examples of correct code for this rule:

import "setup";
import * as namespace from "namespace";
import { a, z } from "values";
import value from "value";

The declaration order can be customized with memberSyntaxSortOrder. ignoreCase, ignoreDeclarationSort, ignoreMemberSort, and allowSeparatedGroups provide the same controls as ESLint.

Original Documentation