Registry / testing / eslint-plugin-command

eslint-plugin-command

JSON →
library3.5.2jsnpmunverified

ESLint plugin that does nothing by default but provides comment-driven micro-codemod transformations. Current stable version is 3.5.2. It is actively maintained by Anthony Fu with regular releases. Key differentiators: unlike traditional ESLint rules that enforce code style, this plugin triggers on-demand transforms via special comments (e.g., `/// to-function`, `/// to-promise-all`, `/// reverse-if-else`), leveraging ESLint's fix infrastructure. It is ESM-only since v3, requires ESLint 9+ flat config, and ships TypeScript types. Peer dependencies include @typescript-eslint/utils and eslint.

npm install eslint-plugin-command
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-COMM
E
eslint-plugin-command
testingjavascriptv3.5.2
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.

command
import { command } from 'eslint-plugin-command'
const { command } = require('eslint-plugin-command')
ESM-only since v3; require() will fail.
commands
import { commands } from 'eslint-plugin-command'
Use commands array to configure multiple commands in flat config.
default
import command from 'eslint-plugin-command'
const command = require('eslint-plugin-command')
Default export is a flat config-compatible plugin object.

Shows how to set up the plugin using ESLint flat config with two commands enabled.

// eslint.config.js (flat config) import command from 'eslint-plugin-command' export default [ command(), { plugins: { command }, rules: { 'command/to-function': 'warn', 'command/to-promise-all': 'warn', }, }, ]
Debug
Known issues
breakingv3.0.0 dropped CJS support; now ESM-only.
fix
Use ESM imports (e.g., `import command from 'eslint-plugin-command'`). If you need CJS, stick to v2.x or use dynamic import().
affects: >=3.0.0
gotchaThe plugin does nothing unless you enable specific command rules. By default, no rules are active.
fix
Add rule configurations like `'command/to-function': 'warn'` to your ESLint config.
affects: all
gotchaCommands are triggered only on files with the special comment (e.g., `/// to-function`). They do not run on all files.
fix
Add the comment exactly as documented. Ensure the comment is at the top of the code block.
affects: all
deprecatedThe `command/keep-sorted` command is deprecated in favor of `command/keep-sorted-by-keys`.
fix
Use `command/keep-sorted-by-keys` instead.
affects: >=3.2.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module
Using require() to import an ESM-only package.
fix
Use `import command from 'eslint-plugin-command'` and ensure your project is ESM (e.g., set `"type": "module"` in package.json).
Failed to load plugin 'command': Cannot find module 'eslint-plugin-command'
Plugin not installed or not properly referenced in ESLint config.
fix
Run `npm install eslint-plugin-command` and add `import command from 'eslint-plugin-command'` to your flat config.
Rule 'command/to-function' is not defined
Using a command rule without registering the plugin in ESLint config.
fix
Add `plugins: { command }` and use `'command/to-function': 'warn'`.
Upgrade
Version history
3.5.2latest on npm
Audit
Dependencies
@typescript-eslint/utilsrequiredRequired for rule creation and type utilities
eslintrequiredPeer dependency; plugin requires ESLint to run
Agent activity
5 hits · last 30 days
node
4
Resources
eslint-plugin-command — npm install eslint-plugin-command · libregistry