Registry / testing / eslint-plugin-sort-keys

eslint-plugin-sort-keys

JSON →
library2.3.5jsnpmunverified

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.

npm install eslint-plugin-sort-keys
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-SORT
E
eslint-plugin-sort-keys
testingjavascriptv2.3.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const sortKeysPlugin = require('eslint-plugin-sort-keys')
import sortKeysPlugin from 'eslint-plugin-sort-keys'
CommonJS only; no default export in ESM
sort-keys-fix rule
plugins: ['sort-keys'], rules: { 'sort-keys/sort-keys-fix': 'warn' }
rules: { 'sort-keys': 'warn' }
The rule name is 'sort-keys-fix', not 'sort-keys'. The plugin prefix is 'sort-keys'.
flat config (eslint.config.js)
plugins: { 'sort-keys': require('eslint-plugin-sort-keys') }
plugins: ['sort-keys']
In ESLint flat config, plugins must be an object, not an array.

Shows installation and configuration for autofix sort-keys, including disabling core rule and using plugin rule.

// Install: npm install --save-dev eslint eslint-plugin-sort-keys // File: eslint.config.js module.exports = { plugins: ['sort-keys'], rules: { 'sort-keys': 0, // disable core sort-keys to avoid duplication 'sort-keys/sort-keys-fix': 'warn', // or 'error' to enforce }, }; // Example object that will be autofixed: // { c: 1, a: 2, b: 3 } -> { a: 2, b: 3, c: 1 }
Debug
Known issues
gotchaRule name is 'sort-keys-fix', not 'sort-keys'. Using 'sort-keys' in rules will apply the core rule without autofix.
fix
Use 'sort-keys/sort-keys-fix' as the rule name.
affects: >=2.0.0
gotchaFlat config requires plugins to be an object, not an array.
fix
Use plugins: { 'sort-keys': require('eslint-plugin-sort-keys') } in eslint.config.js.
affects: >=2.3.0
deprecatedThe plugin is a fork of leo-buneev/eslint-plugin-sort-keys-fix which is no longer maintained.
fix
This fork is still active; however, consider migrating to ESLint's built-in sort-keys if autofix is not critical.
affects: >=2.0.0
gotchaMultiple runs may be needed to fully sort if comments or nested objects are involved.
fix
Run ESLint with --fix multiple times or ensure you are using v2.3.5+ which improves comment handling.
affects: >=2.2.0
Errors
Common errors & fixes
ESLint couldn't find the plugin "sort-keys".
Plugin not installed or incorrectly referenced in config.
fix
Run npm install --save-dev eslint-plugin-sort-keys and verify package.json includes it.
Configuration for rule "sort-keys/sort-keys-fix" is invalid.
Rule name or options are not correct.
fix
Use 'sort-keys/sort-keys-fix': 'warn' (string severity). Options object is supported but optional.
TypeError: Cannot read properties of undefined (reading 'getSourceCode')
Plugin version incompatible with ESLint version.
fix
Use ESLint >=8 and plugin >=2.3.0. For ESLint 9 flat config, ensure flat config usage as shown.
Upgrade
Version history
2.3.5latest on npm
Audit
Dependencies
eslintrequiredpeer dependency; plugin requires ESLint to function
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-sort-keys — npm install eslint-plugin-sort-keys · libregistry