Skip to content

Support ESLint 9.x #77

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

Open
ericberens opened this issue Apr 6, 2024 · 7 comments
Open

Support ESLint 9.x #77

ericberens opened this issue Apr 6, 2024 · 7 comments

Comments

@ericberens
Copy link

Similar to #42

It would be great to officially support ESLint v9.x now that it has been released.

@BenJackGill
Copy link

+1 would also love this

@moontai0724
Copy link

moontai0724 commented Sep 27, 2024

For those who want to use this plugin before it officially support v9, set this up:

// @ts-check
import pluginJs from "@eslint/js";
import { config as typedConfig, configs as tsConfigs } from "typescript-eslint";
import typescriptSortKeys from "eslint-plugin-typescript-sort-keys";

export default typedConfig(
  { ignores: ["node_modules"] },
  pluginJs.configs.recommended,
  {
    languageOptions: {
      parserOptions: {
        projectService: true,
        ecmaVersion: "latest",
        sourceType: "module",
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
  {
    files: ["**/*.ts"],
    extends: [...tsConfigs.strictTypeChecked],
  },
  {
    plugins: {
      "typescript-sort-keys": typescriptSortKeys,
    },
    rules: {
      "typescript-sort-keys/interface": "error",
      "typescript-sort-keys/string-enum": "error",
    },
  }
);

The installation progress will warn you that the version is incompatible but it's fine.

@skilbjo
Copy link

skilbjo commented Oct 7, 2024

@moontai0724 any workaround for the below? (i have the config you provided)

@Johns-MacBook-Air:config-rc $ npm run lint
> eslint .


Oops! Something went wrong! :(

ESLint: 9.12.0

ConfigError: Config (unnamed): Key "plugins": Cannot redefine plugin "typescript-sort-keys".
    at rethrowConfigError (/Users/skilbjo/dev/config-rc/node_modules/@eslint/config-array/dist/cjs/index.cjs:303:8)
    at /Users/skilbjo/dev/config-rc/node_modules/@eslint/config-array/dist/cjs/index.cjs:1098:5
    at Array.reduce (<anonymous>)
    at FlatConfigArray.getConfigWithStatus (/Users/skilbjo/dev/config-rc/node_modules/@eslint/config-array/dist/cjs/index.cjs:1091:43)
    at FlatConfigArray.getConfig (/Users/skilbjo/dev/config-rc/node_modules/@eslint/config-array/dist/cjs/index.cjs:1120:15)
    at entryFilter (/Users/skilbjo/dev/config-rc/node_modules/eslint/lib/eslint/eslint-helpers.js:286:40)
    at async NodeHfs.<anonymous> (file:///Users/skilbjo/dev/config-rc/node_modules/@humanfs/core/src/hfs.js:560:24)
    at async NodeHfs.walk (file:///Users/skilbjo/dev/config-rc/node_modules/@humanfs/core/src/hfs.js:600:3)
    at async globSearch (/Users/skilbjo/dev/config-rc/node_modules/eslint/lib/eslint/eslint-helpers.js:327:26)
    at async Promise.allSettled (index 0)

@moontai0724
Copy link

@skilbjo I've updated to my current version and also uploaded a workaround here: https://github.com/moontai0724/workaround-eslint-v9-sort-keys/blob/main/eslint.config.js

@FlorianWendelborn
Copy link

FYI there’s also https://perfectionist.dev/ which seems pretty feature-complete and can handle most other types of sorting too

@moontai0724
Copy link

@FlorianWendelborn oh my, that seems FANTASTIC!

@Smrtnyk
Copy link

Smrtnyk commented Feb 3, 2025

@infctr would you accept a PR for this?

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

No branches or pull requests

6 participants