{"id":19714,"library":"eslint-plugin-command","title":"eslint-plugin-command","description":"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.","status":"active","version":"3.5.2","language":"javascript","source_language":"en","source_url":"https://github.com/antfu/eslint-plugin-command","tags":["javascript","eslint-plugin","codemod","typescript"],"install":[{"cmd":"npm install eslint-plugin-command","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-command","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-command","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for rule creation and type utilities","package":"@typescript-eslint/utils","optional":false},{"reason":"Peer dependency; plugin requires ESLint to run","package":"eslint","optional":false}],"imports":[{"note":"ESM-only since v3; require() will fail.","wrong":"const { command } = require('eslint-plugin-command')","symbol":"command","correct":"import { command } from 'eslint-plugin-command'"},{"note":"Use commands array to configure multiple commands in flat config.","symbol":"commands","correct":"import { commands } from 'eslint-plugin-command'"},{"note":"Default export is a flat config-compatible plugin object.","wrong":"const command = require('eslint-plugin-command')","symbol":"default","correct":"import command from 'eslint-plugin-command'"}],"quickstart":{"code":"// eslint.config.js (flat config)\nimport command from 'eslint-plugin-command'\n\nexport default [\n  command(),\n  {\n    plugins: { command },\n    rules: {\n      'command/to-function': 'warn',\n      'command/to-promise-all': 'warn',\n    },\n  },\n]\n","lang":"typescript","description":"Shows how to set up the plugin using ESLint flat config with two commands enabled."},"warnings":[{"fix":"Use ESM imports (e.g., `import command from 'eslint-plugin-command'`). If you need CJS, stick to v2.x or use dynamic import().","message":"v3.0.0 dropped CJS support; now ESM-only.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Add rule configurations like `'command/to-function': 'warn'` to your ESLint config.","message":"The plugin does nothing unless you enable specific command rules. By default, no rules are active.","severity":"gotcha","affected_versions":"all"},{"fix":"Add the comment exactly as documented. Ensure the comment is at the top of the code block.","message":"Commands are triggered only on files with the special comment (e.g., `/// to-function`). They do not run on all files.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `command/keep-sorted-by-keys` instead.","message":"The `command/keep-sorted` command is deprecated in favor of `command/keep-sorted-by-keys`.","severity":"deprecated","affected_versions":">=3.2.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import command from 'eslint-plugin-command'` and ensure your project is ESM (e.g., set `\"type\": \"module\"` in package.json).","cause":"Using require() to import an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Run `npm install eslint-plugin-command` and add `import command from 'eslint-plugin-command'` to your flat config.","cause":"Plugin not installed or not properly referenced in ESLint config.","error":"Failed to load plugin 'command': Cannot find module 'eslint-plugin-command'"},{"fix":"Add `plugins: { command }` and use `'command/to-function': 'warn'`.","cause":"Using a command rule without registering the plugin in ESLint config.","error":"Rule 'command/to-function' is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}