Tslint: [Bug] rule max-line-length ignore-pattern option does not work

Created on 28 Mar 2018  路  2Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.9.1
  • __TypeScript version__: 2.8.1
  • __Running TSLint via__: CLI

TypeScript code being linted

import {regionFilterListDefinition, regionToolbarDefinition, regionWorkListColumnDefinition, regionWorkListColumnDefinitionFixer} from '../../../definitions/regionWorkListDefinition';

with tslint.json configuration:

{
  "extends": [
    "angular-tslint-rules",
    "tslint-eslint-rules"
  ],
  "rules": {
    "angular-whitespace": [
      false,
      "check-interpolation",
      "check-pipe"
    ],
    "array-bracket-spacing": [
      true,
      "never"
    ],
    "brace-style": [
      true,
      "1tbs",
      {
        "allowSingleLine": true
      }
    ],
    "callable-types": true,
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "component-class-suffix": true,
    "component-selector": [
      true,
      "element",
      "kairos",
      "kebab-case"
    ],
    "curly": true,
    "cyclomatic-complexity": [
      true,
      35
    ],
    "directive-class-suffix": true,
    "directive-selector": [
      true,
      "attribute",
      "kairos",
      "camelCase"
    ],
    "eofline": true,
    "forin": true,
    "import-blacklist": [
      true,
      "rxjs"
    ],
    "import-spacing": true,
    "indent": [
      true,
      "spaces"
    ],
    "interface-over-type-literal": true,
    "label-position": true,
    "max-line-length": [true, 140, "^import "],
    "member-access": false,
    "member-ordering": [
      true,
      {
        "order": [
          "public-static-field",
          "public-static-method",
          "protected-static-field",
          "protected-static-method",
          "private-static-field",
          "private-static-method",
          "public-instance-field",
          "protected-instance-field",
          "private-instance-field",
          "public-constructor",
          "protected-constructor",
          "private-constructor",
          "public-instance-method",
          "protected-instance-method",
          "private-instance-method"
        ]
      }
    ],
    "newline-before-return": false,
    "newline-per-chained-call": [
      false
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "debug",
      "log",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-imports": true,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-empty-interface": true,
    "no-eval": true,
    "no-extra-boolean-cast": true,
    "no-extra-semi": true,
    "no-inferrable-types": [
      "ignore-params"
    ],
    "no-input-rename": true,
    "no-multi-spaces": true,
    "no-null-keyword": false,
    "no-output-rename": true,
    "no-shadowed-variable": true,
    "no-sparse-arrays": true,
    "no-string-literal": false,
    "no-string-throw": true,
    "no-switch-case-fall-through": true,
    "no-this-assignment": true,
    "no-trailing-whitespace": true,
    "no-unnecessary-class": [
      true,
      "allow-empty-class"
    ],
    "no-unused-expression": true,
    "no-unused-variable": true,
    "no-use-before-declare": true,
    "no-var-keyword": true,
    "object-curly-spacing": [
      true,
      "never"
    ],
    "object-literal-sort-keys": false,
    "one-line": [
      true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "pipe-naming": [
      true,
      "camelCase",
      ""
    ],
    "prefer-conditional-expression": false,
    "prefer-const": true,
    "quotemark": [
      true,
      "single"
    ],
    "radix": true,
    "semicolon": [
      true,
      "always"
    ],
    "space-before-function-paren": [
      true,
      {
        "anonymous": "always",
        "named": "never"
      }
    ],
    "ter-prefer-arrow-callback": [
      true
    ],
    "trailing-comma": [
      true,
      {
        "esSpecCompliant": true,
        "multiline": "never",
        "singleline": "never"
      }
    ],
    "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,
    "use-host-property-decorator": true,
    "use-input-property-decorator": true,
    "use-life-cycle-interface": true,
    "use-output-property-decorator": true,
    "use-pipe-transform-interface": true,
    "variable-name": [
      true,
      "check-format",
      "allow-leading-underscore",
      "ban-keywords"
    ],
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type",
      "check-typecast"
    ]
  },
  "rulesDirectory": [
    "node_modules/codelyzer"
  ]
}

Actual behavior

ERROR: 1:1 max-line-length Exceeds maximum line length of 140

Expected behavior

no errors

Bug

Most helpful comment

I think the max-line-length is wrong, asking people to right regex to configure something is a poor used experience. It would be better broken into common use case flags like ignore-imports-exports, ignore-comments etc.

All 2 comments

I think your max-line-length option is wrong.
Try

[true, {"limit": 140, "ignore-pattern": "^import "}]

I think the max-line-length is wrong, asking people to right regex to configure something is a poor used experience. It would be better broken into common use case flags like ignore-imports-exports, ignore-comments etc.

Was this page helpful?
0 / 5 - 0 ratings