# The analysis and modification of rules of ESLint

Posted on Jul 3, 2019

var Vue = new Vue({})


new Vue({})


arjenzhou: Hi, because I customized the rules, so I want to build and run eslint locally, what should I do?

platinumazure: @arjenzhou You should be able to install ESLint locally with npm install –save-dev eslint, and then run with ./node_modules/.bin/eslint. Am I missing something?

arjenzhou: @platinumazure Thanks for your reply. Because of my work, I must modify the original rule (no-new) and, I want to repackage(I don’t know whether right or not because I haven’t get touch js before) it with the source code and test it locally. I think npm install will push eslint from npm repository, please correct me at your pleasure. typo: push -> pull

platinumazure: @arjenzhou Your best option in this case is to create a custom rule, rather than trying to edit the original rule in-place. See here for a way to pull in custom rules in a particular directory of your project. (Note: This assumes you don’t intend to redistribute your custom no-new implementation. If you might want to redistribute it, you should look at creating a plugin.) See here for how to create a rule. (In your case, you could either put the rule file in some directory in your project and then use –rulesdir to pull it in, or you could put the rule in a plugin.) When creating your rule, you could copy the source of no-new and make the necessary changes. Also, depending on the type of change, eslint-rule-composer could be a useful tool to help you create the rule.

arjenzhou: @platinumazure I am not going to use it in my project, rather than using it in all my projects so, I want to repackage it then I can use it global. platinumazure: @arjenzhou Then you’ll want to create a plugin, publish it to an npm repository (maybe privately/within a scope), and use the rule from the plugin. All your projects can consume the plugin as a dependency or devDependency.

arjenzhou: Can I get the value of the node of AST? I want to log the vaule of node and its child and parent nodes @platinumazure I notice the doc isn’t enough for me https://eslint.org/docs/developer-guide/working-with-rules#contextreport Finally I solve by node.name Thanks you a lot! @platinumazure

## 抽象语法树

Javascript Parser 将 JS 代码转换成 AST，代码扫描工具通过 AST 对代码进行分析检查[1],之后，我们查看源码具体分析规则的实现。