Registry / testing / eslint-plugin-sort-react-dependency-arrays

eslint-plugin-sort-react-dependency-arrays

JSON →
library1.0.0jsnpmunverified

ESLint plugin to enforce alphanumerically sorted React hook dependency arrays (useEffect, useLayoutEffect, etc.). Version 1.0.0 stable, requires Node >=18.18 or 20+. Differentiators: automatic fix with --fix, no external runtime dependencies beyond ESLint >=7, and focuses solely on sorting rather than comprehensive dependency checks. Lightweight alternative to eslint-plugin-react-hooks for ordering only.

npm install eslint-plugin-sort-react-dependency-arrays
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-SORT
E
eslint-plugin-sort-react-dependency-arrays
testingjavascriptv1.0.0
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.

rules
import { rules } from 'eslint-plugin-sort-react-dependency-arrays'
const rules = require('eslint-plugin-sort-react-dependency-arrays').rules
ESM export; the package is ESM-only. CommonJS require still works for Node, but named import is preferred.
configs
import { configs } from 'eslint-plugin-sort-react-dependency-arrays'
import configs from 'eslint-plugin-sort-react-dependency-arrays'
configs is a named export, not default.
plugin
import sortReactDepArrPlugin from 'eslint-plugin-sort-react-dependency-arrays'
const sortReactDepArrPlugin = require('eslint-plugin-sort-react-dependency-arrays')
Default export is the plugin object. With CommonJS, require returns the default.

Configures the plugin and shows a sorted vs unsorted dependency array in useEffect.

// .eslintrc.json { "plugins": ["sort-react-dependency-arrays"], "rules": { "sort-react-dependency-arrays/sort": "error" } } // Example React component import { useEffect } from 'react'; function MyComponent({ flag, value }) { useEffect(() => { // ... }, [value, flag]); // <-- sorted correctly (alphabetically) useEffect(() => { // ... }, [flag, value]); // <-- will trigger lint error; use --fix to reorder }
Debug
Known issues
gotchaThe rule only sorts arrays, it does not validate missing dependencies.
fix
Combine with eslint-plugin-react-hooks/exhaustive-deps for full coverage.
affects: >=1.0.0
gotchaAutofix may break order if dependencies have side effects or implicit ordering.
fix
Review autofixed output; the rule assumes alphabetical is always safe.
affects: >=1.0.0
breakingNode versions below 18.18.0 are not supported.
fix
Upgrade Node to >=18.18, >=20, or >=22.
affects: >=1.0.0
deprecatedESLint v8 is deprecated; use ESLint v9 if possible.
fix
Upgrade ESLint to v9 (flat config). The plugin still works with v8 but may not receive updates.
affects: >=1.0.0
gotchaOnly works with React hooks dependency arrays; does not sort other arrays.
fix
Use for React hooks only; for general array sorting, use other plugins.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'sort-react-dependency-arrays' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-sort-react-dependency-arrays'
Plugin not installed or missing from node_modules.
fix
Run `npm install eslint-plugin-sort-react-dependency-arrays --save-dev`
TypeError: ruleMapper is not a function
Using an older ESLint version (<7) that does not support custom rules properly.
fix
Upgrade ESLint to >=7: `npm install eslint@^7 --save-dev`
Parsing error: The keyword 'import' is reserved
Using 'import' in .eslintrc.json (which must be valid JSON).
fix
Use 'plugins' array with string names, not import statements inside config.
Cannot read properties of undefined (reading 'sort')
Dependency array is dynamically constructed (e.g., using spread).
fix
Rewrite to use a static array literal for the autofix to work.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
eslintrequiredPeer dependency; requires ESLint >=7
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-sort-react-dependency-arrays — npm install eslint-plugin-sort-react-dependency-arrays · libregistry