Ad

Eslint Parsing Error: Unexpected Token Up In Migration.js

in my previous project i used this syntax for migration to mongoDB:

my_migration.js //
'use strict';

import slug from 'slugify';

module.exports = {

  async up(db) {
    const categories = [
        {
            title: 'football',
            slug: slug('football'),
            createdAt: new Date().getTime(),
            updatedAt: new Date().getTime()
        },
    ];

    await db.collection('categories').insertMany(categories);
  }
};

And it works, but an another project(Nextjs, Reactjs, Nodejs) I have eslint error:

[eslint] Parsing error: Unexpected token up
(method) up(db: any): Promise<void>

What I am doing incorrect? Thanks for any help.

Ad

Answer

eslintrc.js/
"parserOptions": {
    "ecmaFeatures": {
        "experimentalObjectRestSpread": true,
        "jsx": true
    },
    "ecmaVersion": 2017,
    "sourceType": "module"
},
Ad
source: stackoverflow.com
Ad