Title: how to fix unexpected token parsing error?
Tags: javascript;reactjs;es6-modules
Question: The arrow works for me all time but i get an error now Parsing error: Unexpected token =&gt;
I tried checking the syntax and bracket and yeah, I dint miss any brackets.
Code :
const functions = require(&quot;firebase-functions&quot;);
const Filter = require(&quot;bad-words&quot;);
const admin = require(&quot;firebase-admin&quot;);
admin.initializeApp();
const db = admin.firestore();
exports.detectEvilUsers = functions.firestore
.document(&quot;messages/{msgId}&quot;)
.onCreate(async (doc, ctx) =&gt; {
const filter = new Filter();
const { text, uid } = doc.data();
if (filter.isProfane(text)) {
const cleaned = filter.clean(text);
await doc.ref.update({
text: &quot;I got banned for lifetime for using voilated words&quot;,
});
await db.collection(&quot;banned&quot;).doc(uid).set({});
Error :
Parsing error: Unexpected token =&gt;
And If try to change it to normal function(){} call, like this
exports.detectEvilUsers = functions.firestore
.document(&quot;messages/{msgId}&quot;)
.onCreate(async function(doc, ctx)  {
const filter = new Filter();
const { text, uid } = doc.data();
....
....
....
It gives me Parsing error:unexpected token function
Comment: @TJ 14.5 ..............

Comment: @SarveshMahajan Yeah, It says Parsing error: Unexpected token =>

Comment: Yeah I have .eslintrc.json file ,, module.exports = {
root: true,
env: {
es6: true,
node: true,
extends: [
"eslint:recommended",
"google",
rules: {
quotes: ["error", "double"],

Comment: any log explaining line number ?

Comment: yes I have, I posted in answer

Comment: What is your environment? Node?

Here is the accepted answer: Eslin.json file:
{ &quot;parser&quot;: &quot;babel-eslint&quot;, &quot;plugins&quot;: [ &quot;babel&quot; ], &quot;extends&quot;: [ &quot;plugin:prettier/recommended&quot;, &quot;plugin:react/recommended&quot; ], &quot;env&quot;: { &quot;browser&quot;: true, &quot;es6&quot;: true, &quot;jest&quot;: true }, &quot;parserOptions&quot;: { &quot;ecmaVersion&quot;: 2018, &quot;sourceType&quot;: &quot;module&quot;, &quot;ecmaFeatures&quot;: { &quot;jsx&quot;: true } }, &quot;rules&quot;: { &quot;curly&quot;: &quot;error&quot;, &quot;eqeqeq&quot;: &quot;error&quot;, &quot;guard-for-in&quot;: &quot;error&quot;, &quot;no-extend-native&quot;: &quot;error&quot;, &quot;complexity&quot;: [ &quot;error&quot;, 200 ], &quot;max-depth&quot;: [ &quot;error&quot;, 5 ], &quot;max-params&quot;: [ &quot;error&quot;, 12 ], &quot;max-statements&quot;: [ &quot;error&quot;, 200 ], &quot;no-caller&quot;: &quot;error&quot;, &quot;no-irregular-whitespace&quot;: &quot;error&quot;, &quot;no-new&quot;: &quot;error&quot;, &quot;no-undef&quot;: &quot;error&quot;, &quot;no-unused-vars&quot;: &quot;error&quot;, &quot;no-global-assign&quot;: &quot;error&quot;, &quot;react/prop-types&quot;: &quot;off&quot;, &quot;babel/semi&quot;: 1 } }
Comment for this answer: Yeah this worked :) But may I know my Eslin.json file dint work.
Comment for this answer: some attributes might be missing in your case. Kindly accept the answer if it help, thanks in advance buddy


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 6, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:05/01/21', 'FavoriteCount': 2.0, 'PostTypeId': 1, 'Tags': '<javascript><reactjs><es6-modules>', 'Title': 'how to fix unexpected token parsing error?', 'ViewCount': 316, 'id': 67345714, 'user_AboutMe': '', 'user_AccountId': 4612382.0, 'user_DisplayName': 'Sai Krishnadas', 'user_Reputation': 2235.0, 'user_Views': 410.0, 'user_id': 9222818.0}}