简体   繁体   English

JetBrains WebStorm自动格式与ESLint规则无案例声明冲突

[英]JetBrains WebStorm auto format conflict with ESLint rule no-case-declarations

When setting up ESLint for my project I found that the auto format feature of JetBrains IDE's conflict with the ESLint rule 'no-case-declarations'. 为我的项目设置ESLint时,我发现JetBrains IDE的自动格式功能与ESLint规则“无案例声明”冲突。

The problem is that JetBrains' IDE formats a switch statement such that the block is (non-indented) on a newline which is unwanted behavior but I cannot find a option to turn this behaviour off. 问题是JetBrains的IDE格式化一个switch语句,使得块在换行符上是(非缩进的),这是不需要的行为,但我找不到关闭此行为的选项。

For example, when reformatting this code 例如,重新格式化此代码时

switch(test){
  case 1: {
    let bla = getBlaForTest(test);
  }
}

It will be auto formatted to 它将自动格式化为

switch(test){
  case 1: 
  {
    let bla = getBlaForTest(test);
  }
}

Which gives an ESLint error that the indenting is wrong (which it is in my opinion). 这给出了ESLint错误,即缩进是错误的(在我看来是这样)。

Does anyone know if this is a limitation of WebStorm or if there is a more advanced way to manage the auto format rules? 有谁知道这是否是WebStorm的限制,或者是否有更高级的方法来管理自动格式规则?

This behaviour is fixed already and fix will be available in WebStorm 2016.2 . 此行为已得到修复,修复将在WebStorm 2016.2中提供

You can try WebStorm 2016.2 EAP build right now -- http://blog.jetbrains.com/webstorm/2016/05/webstorm-2016-2-eap-162-232/ 您现在可以尝试使用WebStorm 2016.2 EAP版本 - http://blog.jetbrains.com/webstorm/2016/05/webstorm-2016-2-eap-162-232/

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

相关问题 如果不在开关盒内声明块作用域,是否会导致内存泄漏? (ESLint无大小写声明) - Does it cause a memory leak if you do not declare block scope inside a switch case? (ESLint no-case-declarations) 不允许在循环内声明变量的 ESLint 规则? - ESLint rule for not allowing variable declarations inside a loop? 在WebStorm中更改自动导入格式 - Change auto import format in WebStorm 关闭 ESLint 规则(在 React 应用程序中,使用 WebStorm) - Turn off ESLint rule (in React app, using WebStorm) JetBrains WebStorm智能感知 - JetBrains WebStorm intellisense 带TypeScript的函数名称的ESlint规则(首字母小写的camelCase) - ESlint rule for function names with TypeScript (camelCase with lower case for first letter) 无法修复 switch 语句中缩进 case 语句的 eslint 规则 - Cannot fix eslint rule on indenting case statements in switch statement JetBrains WebStorm中的JavaScript变色 - JavaScript variable color in JetBrains WebStorm JetBrains WebStorm 中的自定义关键字颜色 - Custom keyword colors in JetBrains WebStorm 在PhpStorm / WebStorm中自动格式化包含HTML的带有缩进的字符串数组 - Auto format an array of strings containing HTML with indentation in PhpStorm/WebStorm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM