Support ESLint 9.x
Opened this issue · 6 comments
ericberens commented
BenJackGill commented
+1 would also love this
moontai0724 commented
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 commented
@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 commented
@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 commented
FYI there’s also https://perfectionist.dev/ which seems pretty feature-complete and can handle most other types of sorting too
moontai0724 commented
@FlorianWendelborn oh my, that seems FANTASTIC!