Angular-cli: Running `ng lint` is throws `Cannot read property '1' of undefined at Rule.SelectorRule`

Created on 5 Apr 2017  路  8Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.0.0
node: 7.7.2
os: win32 x64
@angular/animations: 4.0.1
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1

Repro steps.

Running ng lint

The log given by the failure.

Cannot read property '1' of undefined
TypeError: Cannot read property '1' of undefined
at Rule.SelectorRule [as constructor] (D:\Projects\cfna\client\node_modules\codelyzer\selectorNameBase.js:21:25)
at new Rule (D:\Projects\cfna\client\node_modules\codelyzer\directiveSelectorRule.js:16:47)
at Object.loadRules (D:\Projects\cfna\client\node_modules\tslint\lib\ruleLoader.js:47:32)
at Linter.getEnabledRules (D:\Projects\cfna\client\node_modules\tslint\lib\linter.js:177:44)
at Linter.lint (D:\Projects\cfna\client\node_modules\tslint\lib\linter.js:76:33)
at files.forEach (D:\Projects\cfna\client\node_modules\@angular\cli\tasks\lint.js:37:24)
at Array.forEach (native)
at lintConfigs.map (D:\Projects\cfna\client\node_modules\@angular\cli\tasks\lint.js:30:19)
at Array.map (native)
at Class.run (D:\Projects\cfna\client\node_modules\@angular\cli\tasks\lint.js:21:14)

Desired functionality.

Having the linter run without throwing an error.

Most helpful comment

You should stick to codelyzer 2.x and tslint 4.x: they are the only one officially supported by the CLI right now. Codelyzer v3 is still in beta, you will face issue with the latest ones. We will update the CLI when they are stable enough.

If you really want to upgrade and are facing issues, you can try to open them on the Codelyzer repository

All 8 comments

Is it a newly generated project? If no can you please also post the lint version and the lint json?

What version of codelyzer are you using? Latest one seems to be problematic. 3.0.0-beta.0 works for me.

@ctrl-brk looks like I have codelyzer 3.0.0-beta.4

@vmasek looks like I have tslint 5.0.0, the project is about a 2 weeks old. Just old enough that it was the final beta version to start (couple days) before v4 was released and has been updated to v4.0 and now v4.0.1 via yarn. Nothing has been customized outside of /app which contains only a few components, pipes, guards, routes, etc.

{
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    "callable-types": true,
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "curly": true,
    "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
    ],
    "member-access": false,
    "member-ordering": [
      true,
      "static-before-instance",
      "variables-before-functions"
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-empty-interface": true,
    "no-eval": true,
    "no-inferrable-types": [true, "ignore-params"],
    "no-shadowed-variable": true,
    "no-string-literal": false,
    "no-string-throw": true,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": 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": [
      "always"
    ],
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "typeof-compare": true,
    "unified-signatures": true,
    "variable-name": false,
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],

    "directive-selector": [true, "attribute", "cf", "camelCase"],
    "component-selector": [true, "element", "cf", "kebab-case"],
    "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,
    "no-access-missing-member": true,
    "templates-use-public": true,
    "invoke-injectable": true
  }
}

Hello,
I have the same issue.

"codelyzer": "3.0.0-beta.4",
"tslint": "5.0.0"

Hi,
I am having the same issue here.

My tslint.json is pretty much the same as @mtpultz 's one.

package.json:

"codelyzer": "^3.0.0-beta.0",
"tslint": "^5.0.0",
"typescript": "~2.2.2"

You should stick to codelyzer 2.x and tslint 4.x: they are the only one officially supported by the CLI right now. Codelyzer v3 is still in beta, you will face issue with the latest ones. We will update the CLI when they are stable enough.

If you really want to upgrade and are facing issues, you can try to open them on the Codelyzer repository

Thanks @cexbrayat just to confirm reverting to use codelyzer 2.1.1 and tslint 4.5.1 and ng lint works

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings