Closed KaelWD closed 6 years ago
Thank you for this issue.
This looks like a bug of babel-eslint
.
As ESLint AST spec, the type
must be a string. Would you report it to https://github.com/babel/babel-eslint ?
Same thing's happening here:
search (val) {
if (!val) {
this.docSearch.autocomplete.autocomplete.close()
}
}
Having the same issue, is there any workarounds until the upstream issue is solved?
The fix was finally released in babel-eslint 8.2.1, so it just needs to be updated in this project.
Updating the following resolved the issue for me:
"eslint-plugin-vue": "^4.3.0",
"babel-eslint": "^8.2.1"
Just a note, after updating babel-eslint
and eslint-plugin-vue
, i'm still having the same issue in this case:
"babel-eslint": "^8.2.1",
"eslint-plugin-vue": "^4.4.0",
Tell us about your environment:
Please show your full configuration:
{
"parserOptions": {
"parser": "babel-eslint"
},
"env": {
"browser": true,
"es6": true
},
"extends": [
"plugin:vue/essential",
"airbnb-base"
],
"plugins": [
"vue"
],
"rules": {
"max-len": ["error", 80],
"semi": ["error", "never"],
"indent": ["off", "always"],
"comma-dangle": ["error", "never"],
"arrow-parens": ["error", "as-needed"],
"consistent-return": ["off", "always"],
"no-useless-escape": ["off", "always"],
"quote-props": ["error", "consistent-as-needed"],
"vue/script-indent": ["error", 2, { "baseIndent": 1 }],
"import/no-unresolved": ["off", "always"],
"import/extensions": ["off", "always", {
"js": "never",
"vue": "never",
"json": "never"
}]
}
}
What did you do? Please include the actual source code causing the issue.
I ran the lint to a file that contains:
const typeGroup = obj =>
!emptyObject(obj) && !typeLeaf(obj)
What actually happened? Please include the actual, raw output from ESLint.
yarn run v1.5.1
$ eslint --ext .js,.vue ./src
token.type.endsWith is not a function
TypeError: token.type.endsWith is not a function
at isComment (/rafael/sample/node_modules/eslint-plugin-vue/lib/utils/indent-common.js:186:118)
at Array.every (<anonymous>)
at :matches(Program, VElement[parent.type!='VElement']):exit (/rafael/sample/frontend/node_modules/eslint-plugin-vue/lib/utils/indent-common.js:1523:37)
at listeners.(anonymous function).forEach.listener (/rafael/sample/frontend/node_modules/eslint/lib/util/safe-emitter.js:47:58)
at Array.forEach (<anonymous>)
at Object.emit (/rafael/sample/frontend/node_modules/eslint/lib/util/safe-emitter.js:47:38)
at NodeEventGenerator.applySelector (/rafael/sices/frontend/node_modules/eslint/lib/util/node-event-generator.js:251:26)
at NodeEventGenerator.applySelectors (/rafael/sample/frontend/node_modules/eslint/lib/util/node-event-generator.js:280:22)
at NodeEventGenerator.leaveNode (/rafael/sices/frontend/node_modules/eslint/lib/util/node-event-generator.js:303:14)
at CodePathAnalyzer.leaveNode (/rafael/sample/frontend/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:630:23)
error An unexpected error occurred: "Command failed.
Exit code: 1
It works fine including the braces and return:
const typeGroup = obj => {
return !emptyObject(obj) && !typeLeaf(obj)
}
With inline statement:
const typeGroup = obj => !emptyObject(obj) && !typeLeaf(obj)
or with parent:
const typeGroup = obj =>
(!emptyObject(obj) && !typeLeaf(obj))
But got this issue doing this:
const typeGroup = obj =>
!emptyObject(obj) && !typeLeaf(obj)
I'm running into this as well, with a similar setup as above. However, my error is happening internally in a library I have installed, Vuetify. I can't upgrade the chain of deps for babel because of this error.
I debugged the "isComment" function that's erroring and am seeing token is not a string in this case:
TokenType {
label: '!',
keyword: undefined,
beforeExpr: true,
startsExpr: true,
rightAssociative: false,
isLoop: false,
isAssign: false,
prefix: true,
postfix: false,
binop: null,
updateContext: null }
That's what the token looks like and is clearly different than the rest. I'm not entirely sure why.
Actually, it has nothing to do with the library. It really is as described by @rafaelkendrik . Break a conditional statement to a new line and it'll break your builds. I was able to work around it by removing those breaks, but it's definitely an issue somewhere in the stream.
This was resolved. Please upgrade babel-eslint
.
Thank you.
@mysticatea quick question. Is it fixed the the 9.0.0 beta? Or 8.2.6?
@gabaum10 It was 8.2.2.
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
Thanks @Titans1001, I ended up with
"@babel/eslint-parser": "^7.15.8",
"@vue/cli-plugin-eslint": "^5.0.0-beta.6",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^7.20.0",
i faced the same issue and fixed by updating "eslint-plugin-vue": "^8.3.0"
TypeError: token.type.endsWith is not a function Occurred while linting not work
in my case solved by change to disabled instead of readonly
<vue-autosuggest
id="vi-boat-name"
v-model="form.dm_river_boat.boat_name"
v-uppercase
:suggestions="[{ data: form.dm_river_boat.dm_river_boats }]"
:get-suggestion-value="getSuggestionValue"
:input-props="{
id: 'autosuggest__input',
class: 'form-control',
placeholder: 'Boat Name',
readonly: $can('manage', 'special') ? true : $router.currentRoute.params.id !== undefined ? false : null
solved by change to disabled instead of readonly
disabled: $can('manage', 'special') ? true : $router.currentRoute.params.id !== undefined ? false : null
}"
@focus="getSuggestionValueFocus($event, 'dm_river_boat', 'boat_name')"
@input="searchForm($event, 'dm_river_boat/', 'dm_river_boat', 'boat_name')"
>
i use "vue-autosuggest": "2.2.0",
no need to update everything is fine with me.
这个需要升级eslint 配置,原来的作者不推荐使用了
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年9月25日(星期天) 中午11:31 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [vuejs/eslint-plugin-vue] token.type.endsWith is not a function with vue/script-indent (#349)
in my case solved by change to disabled instead of readonly
<vue-autosuggest id="vi-boat-name" v-model="form.dm_river_boat.boat_name" v-uppercase :suggestions="[{ data: form.dm_river_boat.dm_river_boats }]" :get-suggestion-value="getSuggestionValue" :input-props="{ id: 'autosuggest__input', class: 'form-control', placeholder: 'Boat Name', readonly: $can('manage', 'special') ? true : $router.currentRoute.params.id !== undefined ? false : null solved by change to disabled instead of readonly disabled: $can('manage', 'special') ? true : $router.currentRoute.params.id !== undefined ? false : null }" @focus="getSuggestionValueFocus($event, 'dm_river_boat', 'boat_name')" @input="searchForm($event, 'dm_river_boat/', 'dm_river_boat', 'boat_name')" >
i use "vue-autosuggest": "2.2.0", no need to update everything is fine with me.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Tell us about your environment
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
What actually happened? Please include the actual, raw output from ESLint.
The token passed into
isComment
: (it's the!
before the regexp)