question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

token.type.endsWith is not a function with vue/script-indent

See original GitHub issue

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
  ]
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
nagwancommented, Jan 17, 2022

i faced the same issue and fixed by updating “eslint-plugin-vue”: “^8.3.0”

5reactions
Titans1001commented, Oct 19, 2021

to solve:

remove babel-eslint

add “eslint”: “7.30.0”, “eslint-plugin-vue”: “6.2.2”, “@babel/eslint-parser”: “7.15.8”,

.eslintrc.js edit: parserOptions: { parser: ‘@babel/eslint-parser’ },

success

Read more comments on GitHub >

github_iconTop Results From Across the Web

token.type.endsWith is not a function vue eslint 问题解决_ ...
订阅专栏. 1. 问题原因. 今天用vue-cli搭建了一个脚手架发现let / await / async 关键字不能用会直接报错. token.type.endsWith is not a function.
Read more >
Eslint with vue2 - Get Help - Vue Forum
TypeError : token.type.endsWith is not a function. after searching for a while I saw I github thread and some replayies referring to start ......
Read more >
vue eslint报错:TypeError: token.type.endsWith is not a function
原文地址:https://jue.leheavengame.com/article/61b4946d3a91de0b5dc12930 问题发现维护了很久的vue项目,发现eslint会报错:Type.
Read more >
Failed to Load Plugin Vue in eslintrc.js When Building
... is not a function. Build does not get completed because of this issue. This issue does not occur if I run npm...
Read more >
eslint-plugin-vue @ 5.1.0 .. 5.2.2 - Package Diff
rules/require-prop-type-constructor'), ... + 'v-on-function-call': require('. ... + message: 'Boolean prop should not set a default (Vue defaults it to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found