View all files | ||||
Comment-as-command for one-off codemod with ESLint.
eslint-plugin-command-half.movESLint Plugin Command is a special kind of ESLint plugin, that by default, does nothing. Instead of checking for code quality, it serves as a micro-codemod tool triggers by special comments on-demand, resuse the infrastructure of ESLint.
For example, one of the built-in commands, /// to-function allows you to convert a single arrow function expression to a function declaration.
Will be transformed to this when you hit save with your editor or run eslint . --fix. After executing the command, the comment will also be removed along with the transformation:
One more example that /// to-promise-all converts a sequence of await expressions to await Promise.all():
Will be transformed to:
Refer to the documentation for more details.
MIT License © 2024-PRESENT Anthony Fu