Skip to content

Instantly share code, notes, and snippets.

@rafaelrozon
Created November 27, 2020 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelrozon/876c9a06c0f64136674d7b381d5a9ccf to your computer and use it in GitHub Desktop.
Save rafaelrozon/876c9a06c0f64136674d7b381d5a9ccf to your computer and use it in GitHub Desktop.
TLDR How to create an ESLint Plugin
  1. Bootstrap project
  npm i -g yo generator-eslint
  mkdir eslint-plugin-my-plugin
  cd eslint-plugin-my-plugin
  yo eslint:plugin
  yo eslint:rule
  npm i
  1. Go to https://astexplorer.net/
  2. Select espree as the parser
  3. Select Eslint v4 as the transform
  4. Add sample code to lint in the top-left box. The top-right box shows the AST tree
  5. Find the node you need to target
  6. Write the rule in the bottom-left box. The bottom-right box shows the output from the rule
  7. Copy the return statement of the create function in the bottom-left box to the JavaScript rule file
  8. Add tests
  9. Save and publish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment