代码之家  ›  专栏  ›  技术社区  ›  user944513

为什么在webstorm中添加了代码缩进或美化分号?

  •  3
  • user944513  · 技术社区  · 7 年前

    我在Angular项目中使用Webstorm,在 arrow function中我面临分号问题。

    当我删除此 分号 时,它会删除此错误。但以后每当我用 command+option+l美化我的文件时,分号插入到 arrow中。 function

    提出解决方案

    1. 如何更改tslint设置,使其不显示错误?
    2. 或者我需要更改什么Intellij设置,以便它不会在美化或缩进时添加 分号

    tslint file

    < PRE> >代码> “rulesdirectory”:。[ “节点模块/代码分析器” , “规则”:{ “箭头返回速记”:正确, “可调用类型”:真, “类名”:真, “注释格式”:。[ 真的, “检查空间” , “卷曲”:真的, “折旧”:。{ “severity”:“警告” } “Eofrine”:对, “福林”:真的, “导入黑名单”:。[ 真的, “RXJS/RX” , “导入间距”:真, “缩进”: 真的, “空间” , “类型文字上的接口”:真, “标签位置”:正确, “最大线条长度”:。[ 真的, 一百四十 , “成员访问”:错误, “会员订购”:。[ 真的, { “订单”: “静态场”, “实例字段”, “静态方法”, “实例方法” ] } , “没有ARG”:真的, “无位”:正确, “没有控制台”: 真的, “调试”, “信息” “时间” “时间终结”, “痕迹” , “无构造”:正确, “无调试程序”:正确, “无重复超级”:正确, “no empty”:错误, “无空接口”:真, “无评估”:正确, “无可推断类型”:。[ 真的, “忽略参数” , “无误用新”:正确, “无非空断言”:真, “无阴影变量”:真, “no string literal”:错误, “无抛弦”:正确, “无开关箱掉入”:正确, “无尾随空格”:正确, “没有不必要的初始值设定项”:正确, “无未使用的表达式”:真, “声明前不使用”:正确, “no var关键字”:真, “对象文字排序键”:假, “一条线”: 真的, “检查左大括号”, “支票捕获”, “检查其他”, “检查空白” , “prefer const”:对, “QuotoMARK”: 真的, “单身” , “基数”:真的, “分号”: 真的, “永远” , “三重等于”:。[ 真的, “允许空检查” , “typedef whitespace”:。[ 真的, { “call signature”:“nospace”, “index signature”:“nospace”, “parameter”:“nospace”, “property declaration”:“nospace”, “变量声明”:“nospace” } , “统一签名”:正确, “变量名”:假, “空白”: 真的, “检查分支”, “检查DECL”, “检查操作员”, “检查分隔符”, “检查类型” , “前缀无输出”:真, “使用输入属性修饰器”:真, “使用输出属性修饰器”:真, “使用主机属性修饰器”:真, “无输入重命名”:真, “无输出重命名”:真, “使用寿命周期界面”:真, “使用管道转换接口”:真, “组件类后缀”:真, “指令类后缀”:真 } } < /代码> < enter image description here

    当我取下这个的时候 semicolon 它消除了这个错误。但以后每当我用 命令+选项+L 分号插入 箭头 功能。

    提出解决方案

    1. 如何更改tslint设置,使其不显示错误?
    2. 或者我需要更改什么Intellij设置,以便它不会添加 分号 关于美化或缩进?

    锡林特文件

    {
      "rulesDirectory": [
        "node_modules/codelyzer"
      ],
      "rules": {
        "arrow-return-shorthand": true,
        "callable-types": true,
        "class-name": true,
        "comment-format": [
          true,
          "check-space"
        ],
        "curly": true,
        "deprecation": {
          "severity": "warn"
        },
        "eofline": true,
        "forin": true,
        "import-blacklist": [
          true,
          "rxjs/Rx"
        ],
        "import-spacing": true,
        "indent": [
          true,
          "spaces"
        ],
        "interface-over-type-literal": true,
        "label-position": true,
        "max-line-length": [
          true,
          140
        ],
        "member-access": false,
        "member-ordering": [
          true,
          {
            "order": [
              "static-field",
              "instance-field",
              "static-method",
              "instance-method"
            ]
          }
        ],
        "no-arg": true,
        "no-bitwise": true,
        "no-console": [
          true,
          "debug",
          "info",
          "time",
          "timeEnd",
          "trace"
        ],
        "no-construct": true,
        "no-debugger": true,
        "no-duplicate-super": true,
        "no-empty": false,
        "no-empty-interface": true,
        "no-eval": true,
        "no-inferrable-types": [
          true,
          "ignore-params"
        ],
        "no-misused-new": true,
        "no-non-null-assertion": true,
        "no-shadowed-variable": true,
        "no-string-literal": false,
        "no-string-throw": true,
        "no-switch-case-fall-through": true,
        "no-trailing-whitespace": true,
        "no-unnecessary-initializer": true,
        "no-unused-expression": true,
        "no-use-before-declare": true,
        "no-var-keyword": true,
        "object-literal-sort-keys": false,
        "one-line": [
          true,
          "check-open-brace",
          "check-catch",
          "check-else",
          "check-whitespace"
        ],
        "prefer-const": true,
        "quotemark": [
          true,
          "single"
        ],
        "radix": true,
        "semicolon": [
          true,
          "always"
        ],
        "triple-equals": [
          true,
          "allow-null-check"
        ],
        "typedef-whitespace": [
          true,
          {
            "call-signature": "nospace",
            "index-signature": "nospace",
            "parameter": "nospace",
            "property-declaration": "nospace",
            "variable-declaration": "nospace"
          }
        ],
        "unified-signatures": true,
        "variable-name": false,
        "whitespace": [
          true,
          "check-branch",
          "check-decl",
          "check-operator",
          "check-separator",
          "check-type"
        ],
        "no-output-on-prefix": true,
        "use-input-property-decorator": true,
        "use-output-property-decorator": true,
        "use-host-property-decorator": true,
        "no-input-rename": true,
        "no-output-rename": true,
        "use-life-cycle-interface": true,
        "use-pipe-transform-interface": true,
        "component-class-suffix": true,
        "directive-class-suffix": true
      }
    }
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   nipuna777    7 年前

    这似乎是tslint的预期行为。 您可以在此处找到相关的Github问题: https://github.com/palantir/tslint/issues/1476

    您应该能够通过设置 ignore-bound-class-methods 财产。

    "semicolon": [true, "always", "ignore-bound-class-methods"]
    
    推荐文章