简体   繁体   English

ESLINT忽略诸如“多余分号”之类的警告的设置

[英]Settings for ESLINT to ignore warnings like “extra semicolon”

I'm using the Atom Code Editor for a VueJS Project with ESLINT (feross). 我将Atom代码编辑器用于带有ESLINT(feross)的VueJS项目。 By trying to quickly prototype a layout I get these errors. 通过尝试快速制作布局原型,我得到了这些错误。

Missing space before opening brace 撑开前缺少空间
Strings must use singlequote 字符串必须使用单引号
Extra semicolon 多余的分号

During the prototype phase I would like ESLINT/ATOM to disable/ignore these errors and render the site anyways. 在原型阶段,我希望ESLINT / ATOM禁用/忽略这些错误并以任何方式呈现该网站。 How to do that? 怎么做?

You could temporarily turn off eslint. 您可以暂时关闭eslint。 In my setup, inspecting build/webpack.base.conf.js shows the following snippet: 在我的设置中,检查build/webpack.base.conf.js显示以下代码段:

  module: {
    rules: [
      ...(config.dev.useEslint ? [createLintingRule()] : []),
      {
        test: /\.vue$/,

The linting rule will enable eslint. 插入规则将启用eslint。 Lets avoid that and set config.dev.useEslint to false . 让我们避免这种情况,并将config.dev.useEslint设置为false Go to config/index.js and alter the following snippet: 转到config/index.js并更改以下代码段:

// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: false,

In your .eslintrc file, do the following: 在您的.eslintrc文件中,执行以下操作:

  "rules": {
    "space-before-blocks": "off",
    "quotes": "off",
    "no-extra-semi": "off"
  }

This will turn off the above rules. 这将关闭上述规则。 I would suggest instead of turning it off let it throw warning, so in future you remember to fix these issues. 我建议不要关闭它,而要发出警告,所以将来您记得要解决这些问题。

ESLint has an awesome documentation: https://eslint.org/docs/rules/ ESLint有一个很棒的文档: https ://eslint.org/docs/rules/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM