Repository: vuejs/eslint-plugin-vue

Issue #349: token.type.endsWith is not a function with vue/script-indent
Created: 2018-01-15T09:45:58Z
Tell us about your environment

ESLint Version: 4.15.0
eslint-plugin-vue Version: 4.2.0
Node Version: 8.9.1

Please show your full configuration:

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint',
    ecmaVersion: 2017,
    sourceType: 'module'
  },
  env: {
    node: true,
    browser: true
  },
  extends: [
    'plugin:vue/recommended',
    'standard'
  ],
  rules: {
    "vue/script-indent": ["error", 2, {
      "baseIndent": 1,
      "switchCase": 0,
      "ignores": []
    }]
...
What did you do? Please include the actual source code causing the issue.

return (
  // it's inside node_modules
  /node_modules/.test(module.context) &&
  // and not a CSS file (due to extract-text-webpack-plugin limitation)
  !/\.css$/.test(module.request)
)
What actually happened? Please include the actual, raw output from ESLint.
TypeError: token.type.endsWith is not a function
    at isComment (eslint-plugin-vue/lib/utils/indent-common.js:186:120)
    at Array.every (<anonymous>)
    at :matches(Program, VElement[parent.type!='VElement']):exit (eslint-plugin-vue/lib/utils/indent-common.js:1493:37)
    at listeners.(anonymous function).forEach.listener (eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.leaveNode (eslint/lib/util/node-event-generator.js:303:14)
    at CodePathAnalyzer.leaveNode (eslint/lib/code-path-analysis/code-path-analyzer.js:630:23)

The token passed into isComment: (it's the ! before the regexp)
{
  "type": {
    "label": "!",
    "beforeExpr": true,
    "startsExpr": true,
    "rightAssociative": false,
    "isLoop": false,
    "isAssign": false,
    "prefix": true,
    "postfix": false,
    "binop": null,
    "updateContext": null
  },
  "value": "!",
  "start": 963,
  "end": 964,
  "loc": {
    "start": {
      "line": 26,
      "column": 10
    },
    "end": {
      "line": 26,
      "column": 11
    }
  },
  "range": [
    963,
    964
  ]
}

Duplicate issue #396: TypeError: token.type.endsWith is not a function when having multiline v-show statement with `!` on the start of one of the lines.
Created: 2018-02-16T18:57:29Z
Tell us about your environment

ESLint Version: 4.17.0
eslint-plugin-vue Version:4.2.2
Node Version: 9.3.0

Please show your full configuration:


module.exports = {
    "env": {
        "browser": true,
        "es6": true,
        "amd": true
    },
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": "babel-eslint",
        "sourceType": "module",
        "allowImportExportEverywhere": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:vue/recommended"
    ]
};


What did you do? Please include the actual source code causing the issue.

<template>
                  <a class="class" @click="handler(index)"
                    v-show="something > 3 &&
                    !somethingElse[index]">{{OtherThing}}</a>
</template>
What did you expect to happen?
What actually happened? Please include the actual, raw output from ESLint.
Token {
  type:
   TokenType {
     label: '!',
     keyword: undefined,
     beforeExpr: true,
     startsExpr: true,
     rightAssociative: false,
     isLoop: false,
     isAssign: false,
     prefix: true,
     postfix: false,
     binop: null,
     updateContext: null },
  value: '!',
  start: 7539,
  end: 7540,
  loc:
   SourceLocation {
     start: { line: 141, column: 20 },
     end: { line: 141, column: 21 } },
  range: [ 7539, 7540 ] }
token.type.endsWith is not a function
TypeError: token.type.endsWith is not a function
    at isComment (/project/node_modules/eslint-plugin-vue/lib/utils/indent-common.js:186:118)
    at Array.every (<anonymous>)
    at EventEmitter.:matches(Program, VElement[parent.type!='VElement']):exit (/project/node_modules/eslint-plugin-vue/lib/utils/indent-common.js:1502:37)
    at EventEmitter.emit (events.js:159:13)
    at NodeEventGenerator.applySelector (/project/node_modules/vue-eslint-parser/index.js:2730:26)
    at NodeEventGenerator.applySelectors (/project/node_modules/vue-eslint-parser/index.js:2744:22)
    at NodeEventGenerator.leaveNode (/project/node_modules/vue-eslint-parser/index.js:2755:14)
    at traverse (/project/node_modules/vue-eslint-parser/index.js:117:13)
    at traverseNodes (/project/node_modules/vue-eslint-parser/index.js:120:5)
    at scriptVisitor.Program:exit (/project/node_modules/vue-eslint-parser/index.js:3188:25)

This ! in the start of the line somehow made eslint throw this error.
This may be https://github.com/mysticatea/vue-eslint-parser bug. Let me know if I should move it there.

Closing comment (2018-02-17T06:22:35Z): Thank you for this report. However, this looks a duplicate of #349. It's a bug in babel-eslint. Please track that issue.