Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import order rule not working #3134

Open
Arian94 opened this issue Dec 31, 2024 · 3 comments
Open

import order rule not working #3134

Arian94 opened this issue Dec 31, 2024 · 3 comments

Comments

@Arian94
Copy link

Arian94 commented Dec 31, 2024

import jsPlugin from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import jsx11yPlugin from "eslint-plugin-jsx-a11y";
import prettierPluginRecommended from "eslint-plugin-prettier/recommended";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import reactRefreshPlugin from "eslint-plugin-react-refresh";
import eslintConfigPrettier from "eslint-config-prettier";
import { includeIgnoreFile } from "@eslint/compat";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");

/** @type { import("eslint").Linter.Config[] } */
export default [
  includeIgnoreFile(gitignorePath),
  jsPlugin.configs.recommended,
  importPlugin.flatConfigs.recommended,
  importPlugin.flatConfigs.typescript,
  jsx11yPlugin.flatConfigs.recommended,
  reactPlugin.configs.flat.recommended,
  eslintConfigPrettier,
  //! make prettierPlugin the last plugin to override previous rules.
  prettierPluginRecommended,
  {
    plugins: {
      "react-hooks": reactHooksPlugin.configs.recommended,
      "react-refresh": reactRefreshPlugin,
    },
    rules: {
      "import/order": [
        "error",
        {
          groups: [
            "builtin",
            "external",
            "internal",
            "parent",
            "sibling",
            "index",
            "object",
            "type",
          ],
          "newlines-between": "always",
        },
      ],
    },
    settings: {
    "import/resolver": {
      "typescript": true,
      "node": true,
    },
  },
    ignores: ["eslint.config.js", "commitlint.config.js"],
  },
];
@ljharb
Copy link
Member

ljharb commented Dec 31, 2024

You’ll have to elaborate on what’s not working.

@Arian94
Copy link
Author

Arian94 commented Jan 1, 2025

It doesn't order imports alphabetically for example.

@ljharb
Copy link
Member

ljharb commented Jan 2, 2025

@Arian94 it's not supposed to, unless you enable the alphabetize option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants