ESLint:插件代码检测工具

官网
中文教程

  • 安装Eslint

    npm i eslint g

  • 配置文件 .eslintrc.json

    eslint --init
    
  • eslint test.js

    1:5  error  'username' is assigned a value but never used                    no-unused-vars
    3:4  error  Expected a conditional expression and instead saw an assignment  no-cond-assign
    3:4  error  Unexpected constant condition                                    no-constant-condition
    3:4  error  'a' is not defined                                               no-undef
    4:5  error  Unexpected console statement                                     no-console
    7:5  error  'age' is assigned a value but never used                         no-unused-vars
    9:1  error  'number' is not defined                                          no-undef
    
  • 安装vscode eslint插件 ESLint

  • 在Visual Studio Code中,需要安装这么一个插件,可以有效的解决因为马虎,粗心,大意书写代码时的错误。

你可能感兴趣的:(ESLint:插件代码检测工具)