{"id":19943,"library":"eslint-plugin-sort-keys","title":"eslint-plugin-sort-keys","description":"Autofix-enabled fork of ESLint's built-in sort-keys rule. Current stable version is 2.3.5. It automatically sorts object keys alphabetically with an autofix, unlike the core rule which only warns. It also moves associated comments with properties, supports minKeys threshold, and is intended for ESLint flat config. The package is maintained, with bug fixes released periodically.","status":"active","version":"2.3.5","language":"javascript","source_language":"en","source_url":"https://github.com/namnm/eslint-plugin-sort-keys","tags":["javascript","eslint","sort keys","sort object","autofix","fixable"],"install":[{"cmd":"npm install eslint-plugin-sort-keys","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-sort-keys","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-sort-keys","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin requires ESLint to function","package":"eslint","optional":false}],"imports":[{"note":"CommonJS only; no default export in ESM","wrong":"import sortKeysPlugin from 'eslint-plugin-sort-keys'","symbol":"default","correct":"const sortKeysPlugin = require('eslint-plugin-sort-keys')"},{"note":"The rule name is 'sort-keys-fix', not 'sort-keys'. The plugin prefix is 'sort-keys'.","wrong":"rules: { 'sort-keys': 'warn' }","symbol":"sort-keys-fix rule","correct":"plugins: ['sort-keys'], rules: { 'sort-keys/sort-keys-fix': 'warn' }"},{"note":"In ESLint flat config, plugins must be an object, not an array.","wrong":"plugins: ['sort-keys']","symbol":"flat config (eslint.config.js)","correct":"plugins: { 'sort-keys': require('eslint-plugin-sort-keys') }"}],"quickstart":{"code":"// Install: npm install --save-dev eslint eslint-plugin-sort-keys\n// File: eslint.config.js\nmodule.exports = {\n  plugins: ['sort-keys'],\n  rules: {\n    'sort-keys': 0, // disable core sort-keys to avoid duplication\n    'sort-keys/sort-keys-fix': 'warn', // or 'error' to enforce\n  },\n};\n\n// Example object that will be autofixed:\n// { c: 1, a: 2, b: 3 } -> { a: 2, b: 3, c: 1 }","lang":"javascript","description":"Shows installation and configuration for autofix sort-keys, including disabling core rule and using plugin rule."},"warnings":[{"fix":"Use 'sort-keys/sort-keys-fix' as the rule name.","message":"Rule name is 'sort-keys-fix', not 'sort-keys'. Using 'sort-keys' in rules will apply the core rule without autofix.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use plugins: { 'sort-keys': require('eslint-plugin-sort-keys') } in eslint.config.js.","message":"Flat config requires plugins to be an object, not an array.","severity":"gotcha","affected_versions":">=2.3.0"},{"fix":"This fork is still active; however, consider migrating to ESLint's built-in sort-keys if autofix is not critical.","message":"The plugin is a fork of leo-buneev/eslint-plugin-sort-keys-fix which is no longer maintained.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Run ESLint with --fix multiple times or ensure you are using v2.3.5+ which improves comment handling.","message":"Multiple runs may be needed to fully sort if comments or nested objects are involved.","severity":"gotcha","affected_versions":">=2.2.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev eslint-plugin-sort-keys and verify package.json includes it.","cause":"Plugin not installed or incorrectly referenced in config.","error":"ESLint couldn't find the plugin \"sort-keys\"."},{"fix":"Use 'sort-keys/sort-keys-fix': 'warn' (string severity). Options object is supported but optional.","cause":"Rule name or options are not correct.","error":"Configuration for rule \"sort-keys/sort-keys-fix\" is invalid."},{"fix":"Use ESLint >=8 and plugin >=2.3.0. For ESLint 9 flat config, ensure flat config usage as shown.","cause":"Plugin version incompatible with ESLint version.","error":"TypeError: Cannot read properties of undefined (reading 'getSourceCode')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}