简体   繁体   English

如何配置Eslint以忽略Vue Cli 3项目中的特定错误

[英]How to configure Eslint to ignore particular errors in Vue Cli 3 project

I'm usig Snap.svg in Vue project, generated with Vue cli 3. Snap is added to vue.config.js as follows: 我使用Vue cli 3生成的Vue项目中的usig Snap.svg。按如下方式将Snap添加到vue.config.js中:

module.exports = {
  chainWebpack: config => {
    config.module
      .rule("i18n")
      .resourceQuery(/blockType=i18n/)
      .type("javascript/auto")
      .use("i18n")
      .loader("@kazupon/vue-i18n-loader")
      .end();

    config.module
      .rule("snapsvg")
      .test(require.resolve("snapsvg"))
      .use("imports-loader?this=>window,fix=>module.exports=0")
      .loader("imports-loader")
      .end();

  }
};

As well as to main.js 以及main.js

const snap = require(`imports-loader?this=>window,fix=>module.exports=0!snapsvg/dist/snap.svg.js`);

I'm using snap in my components without local import. 我在没有本地导入的组件中使用了snap。

var s = Snap(this.paper["svg-wrap"]);

The library works as excepted, svg is generated, however i keep getting Eslint errors. 该库工作异常,生成了svg,但是我一直收到Eslint错误。

error: 'Snap' is not defined (no-undef) at src\components\subpageBanner.vue:246:21:

I want to keep using Eslint in all components, but configure it to ingore this kind of errors. 我想在所有组件中继续使用Eslint,但将其配置为避免此类错误。 Is it possible? 可能吗?

如果是单个文件,则可以将以下行放在文件顶部。

 /*eslint no-undef: "warning"*/ 

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

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