webstorm(2017.3.2)搭建eslint,毛病提醒和自动修复

先看看结果

有毛病提醒和快捷键自动修复。
《webstorm(2017.3.2)搭建eslint,毛病提醒和自动修复》

我装置的插件

1.预备 在node环境装置eslint等插件

注重: 需提早装置好node环境

// 除了eslint是必需的,能够按需装置
npm i -g eslint eslint-config-standard eslint-plugin-html eslint-plugin-import eslint-plugin-node eslint-plugin-promise 

《webstorm(2017.3.2)搭建eslint,毛病提醒和自动修复》

2. 在webstorm设置

node和eslint的途径是软件自动猎取的,记得选中enable;去设置内里设置你的自动修复快捷键

《webstorm(2017.3.2)搭建eslint,毛病提醒和自动修复》
《webstorm(2017.3.2)搭建eslint,毛病提醒和自动修复》

3. 末了一步,在项目中设置.eslintrc.js或.eslintrc, webstorm会自动挪用。

// https://eslint.org/docs/user-guide/configuring
// 本身按需设置咯
module.exports = {
  root: true,
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module'
  },
  env: {
    browser: true
  },
  // https://github.com/standard/standard/blob/master/docs/RULES-en.md
  extends: 'standard',
  // required to lint *.vue files
  plugins: [
    'html'
  ],
  // add your custom rules here
  rules: {
    // allow async-await
    'generator-star-spacing': 'off',
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  }
}
    原文作者:SmartCoder
    原文地址: https://segmentfault.com/a/1190000013938070
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞