Skip to main content
interlace
Plugin: import-nextRules

enforce-import-order

Enforces a specific order for import statements

💼 This rule is enabled in the following configs: recommended, typescript. 🔧 This rule is automatically fixable by the --fix CLI option.

Rule Details

This rule aims to prevent issues related to enforce-import-order.

Options

[
  {
    "type": "object",
    "properties": {
      "groups": {
        "type": "array",
        "items": {
          "type": "string",
          "enum": [
            "builtin",
            "external",
            "internal",
            "parent",
            "sibling",
            "index",
            "object",
            "type",
            "side-effect"
          ]
        }
      },
      "internalPatterns": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "alphabetize": {
        "type": "object",
        "properties": {
          "order": {
            "type": "string",
            "enum": [
              "asc",
              "desc",
              "ignore"
            ]
          },
          "caseInsensitive": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "newlinesBetween": {
        "type": "string",
        "enum": [
          "always",
          "never",
          "ignore"
        ]
      }
    },
    "additionalProperties": false
  }
]

Implementation

OWASP Foundation

  • Category: A00:2021 - General Security

Use this rule

npm install -D oxlint-plugin-import-next
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-import-next"],  "rules": {    "import-next/enforce-import-order": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-import-next'],    rules: {      'import-next/enforce-import-order': '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.