简体   繁体   English

如何处理 AirBNB 配置中冲突的 eslint 规则

[英]How to deal with conflicting eslint rules in AirBNB configuration

I'm a noob trying to write a POC in Vue.我是一个尝试在 Vue 中编写 POC 的菜鸟。 I'm using ESLint with the AirBNB configuration, and am running into a conflict.我在 AirBNB 配置中使用 ESLint,但遇到了冲突。

Here is the error catching part of my Axios call:这是我的 Axios 调用的错误捕获部分:

  .catch((error) => {
    errorMsg.value = error;
    console.log('Error is ' + error);
    console.log(`Error is {error}`);
  });

And here is the linter errors I am receiving:这是我收到的 linter 错误:

  50:21  error  Unexpected string concatenation  prefer-template
  51:21  error  Strings must use singlequote     quotes

✖ 2 problems (2 errors, 0 warnings)

Because of these two conflicting rules, it appears I cannot get the output I want.由于这两个相互冲突的规则,我似乎无法获得我想要的输出。 What am I doing wrong?我究竟做错了什么?

String interpolation in JS requires a $ sign. JS 中的字符串插值需要$符号。 So you should be using:所以你应该使用:

.catch((error) => {
    errorMsg.value = error;
    console.log('Error without interpolation'); // Single quotes for simple strings
    console.log(`Error is ${error}`); // Template for interpolation
  });

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

相关问题 如何从eslint-config-airbnb有选择地启用eslint规则 - How to selectively enable eslint rules from eslint-config-airbnb eslint规则不能与airbnb规则一起使用? - eslint rules not working with airbnb rule? 如何在 VS Code 编辑器中使用 ESLint + Airbnb 规则 + TypeScript + Stylelint 为 SCSS 配置 Vue CLI 4,并在保存时自动修复? - How to configure Vue CLI 4 with ESLint + Airbnb rules + TypeScript + Stylelint for SCSS, in VS Code editor with autofix on save? 带有 Airbnb 风格指南的 ESLint 不适用于所有规则 - ESLint with Airbnb style guide does not work for all rules 插件内所有规则的 ESLint 共享配置 - ESLint shared configuration for all rules within a plugin 如何处理时间表冲突事件? - How to deal with conflicting schedule events? 如何避免Airbnb ESLint中的“箭头函数期望返回值”错误 - How to avoid “Arrow function expect to return a value” error in Airbnb ESLint 如何正确安装eslint-config-airbnb? `UNMET PEER DEPENDENCY` - How to install eslint-config-airbnb properly ? `UNMET PEER DEPENDENCY` 如何忽略标准中的 eslint 规则 - How to ignore eslint rules in standard 如何忽略StandardJS / ESLint中的规则? - How to ignore rules in StandardJS/ESLint?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM