You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24
Original file line number
Diff line number
Diff line change
@@ -294,6 +294,30 @@ In order to add a new rule, you should:
294
294
295
295
We're more than happy to see potential contributions, so don't hesitate. If you have any suggestions, ideas or problems feel free to add new [issue](https://github.com/vuejs/eslint-plugin-vue/issues), but first please make sure your question does not repeat previous ones.
296
296
297
+
### Working with rules
298
+
299
+
Before you start writing new rule, please read the [official ESLint guide](https://eslint.org/docs/developer-guide/working-with-rules).
300
+
301
+
Next in order to get an idea how does the AST of the code that you want to check looks like, you can use one of the following applications:
302
+
-[astexplorer.net](http://astexplorer.net/) - best tool to inspect ASTs, but it doesn't support Vue templates yet
303
+
-[ast.js.org](https://ast.js.org/) - not fully featured, but supports Vue templates syntax
304
+
305
+
Since single file components in Vue are not plain JavaScript, we can't use the default parser, and we had to introduce additional one: `vue-eslint-parser`, that generates enhanced AST with nodes that represent specific parts of the template syntax, as well as what's inside the `<script>` tag.
306
+
307
+
To know more about certain nodes in produced ASTs, go here:
Check out an [example rule](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/mustache-interpolation-spacing.js) to get a better understanding of how these work.
316
+
317
+
Please be aware that regarding what kind of code examples you'll write in tests, you'll have to accordingly setup the parser in `RuleTester` (you can do it on per test case basis though). [See an example here](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/attribute-hyphenation.js#L19)
318
+
319
+
If you'll stuck, remember there are plenty of rules you can learn from already, and if you can't find the right solution - don't hesitate to reach out in issues. We're happy to help!
320
+
297
321
## :lock: License
298
322
299
323
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
0 commit comments