Unexpected token )
See original GitHub issueTell us about your environment
- ESLint Version: 4.19.1
- Node Version: 9.11.1
- npm Version: 5.6.0
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
// Use this file as a starting point for your project's .eslintrc.
// Copy this file, and add rule overrides as needed.
{
"extends": [
"airbnb", "plugin:vue/essential",
],
"env": {
"jquery": true,
"browser": true
},
"globals": {
"App": true,
"$": true
},
"rules": {
"max-len": [2, 140, 2],
"no-param-reassign": "warn",
"no-underscore-dangle": "off",
"prefer-destructuring": [
"error",
{
"array": false,
"object": false
}
]
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
import Vue from 'vue';
export default {
getChat(token, cb, cbError) {
const url = Routes.api_v1_chat_path(token);
Vue.http.get(url).then(response => cb(response.body), () => cbError());
},
getChats(cb, cbError) {
const url = Routes.api_v1_chats_path();
Vue.http.get(url).then(response => cb(response.body), () => cbError());
},
endChat(token, cb, cbError) {
const url = Routes.api_v1_chat_path(token);
Vue.http.delete(url).then(response => cb(response.body), () => cbError());
},
chatCable: null,
chatsCable: null,
disconnectIfNecessary() {
if (this.chatCable) this.chatCable.unsubscribe();
this.chatCable = null;
},
initChatCable(store, token) {
this.disconnectIfNecessary();
if (!token) {
return;
}
this.disconnectIfNecessary();
this.chatCable = App.cable.subscriptions.create(
{
channel: 'ChatChannel',
chatToken: token,
},
{
connected() {
this.subscribe();
},
disconnected() {
console.log('WebSocket disconnected.');
},
received(data) {
const message = JSON.parse(data.message);
const prompt = JSON.parse(data.prompt);
const chat = JSON.parse(data.chat);
store.commit('receiveMessage', {
token,
chat,
message,
prompt,
});
},
sendMessage(message) {
this.perform('send_message', { message });
},
sendResponse(response) {
this.perform('send_response', { response });
},
subscribe() {
// return this.perform('subscribe');
},
},
); // THIS IS LINE 72
},
disconnectChatsCable() {
if (this.chatsCable) this.chatsCable.unsubscribe();
this.chatsCable = null;
},
initChatsCable(store) {
this.chatsCable = App.cable.subscriptions.create(
{
channel: 'ChatsChannel',
},
{
connected() {
this.subscribe();
},
disconnected() {
},
received(data) {
const chat = JSON.parse(data.chat);
store.commit('updateChat', { chat });
},
subscribe() {},
},
);
},
};
eslint app/javascript/packs/rather_chat/api/chats.js
What did you expect to happen?
This is a perfectly valid file.
What actually happened? Please include the actual, raw output from ESLint.
72:5 error Parsing error: Unexpected token )
✖ 1 problem (1 error, 0 warnings)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >syntax error: unexpected token - javascript - Stack Overflow
The error SyntaxError: Unexpected token < likely means the API endpoint didn't return JSON in its document body, such as due to a...
Read more >Have a JavaScript Unexpected Token Error? Check Your Syntax
The JavaScript's parser expects tokens and symbols in a particular order, with relevant values or variables in between. Often, an Unexpected ...
Read more >JavaScript Error Handling: Unexpected Token - GeeksforGeeks
Not follow them throws an error.An unexpected token occurs if JavaScript code has a missing or extra character { like, ) + –...
Read more >SyntaxError: Unexpected token in JavaScript | bobbyhadz
The "Uncaught SyntaxError: Unexpected token" occurs for multiple reasons: · The error is also caused if you're making an HTTP request to a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @gamut, thanks for posting the file.
There’s a dangling comma after the last function argument on line 71. Dangling commas for function arguments is only valid in ES2017 or later. I’m not sure if the airbnb config might be using ES2017, but your config file definitely does not specify an ecmaVersion explicitly so it might be using ES5 by default. In any case, if you are willing to parse your code using ES2017 spec, you should add to your config:
Thank you. Appreciate the response.
On Thu, May 17, 2018 at 6:29 PM Kevin Partington notifications@github.com wrote: