0

I have the following imports in my file nodejs:

import config from 'config';
import { PassportStatic } from 'passport';
import rootPath from './handlers/rootPath';
import SSOCallback from './handlers/SSOCallback';
import authFailure from './handlers/authFailure';
import ensureAuthenticated from '../modules/auth/ensureAuthenticated';
import APIConnect from './handlers/apiConnect';
import express = require('express');

This is the tslint.json file I am using:

{
    "parser": "@typescript-eslint/parser",
    "env": {
        "es6": true,
        "node": true,
        "jest/globals": true,
        "browser": true
    },
    "parserOptions": {
        "sourceType": "module",
        "ecmaVersion": 2019,
        "project": "tsconfig.json",
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "extends": [
        "airbnb-base",
        "plugin:@typescript-eslint/recommended",
        "prettier/@typescript-eslint",
        "plugin:prettier/recommended",
        "plugin:@typescript-eslint/recommended-requiring-type-checking",
        "plugin:import/errors",
        "plugin:import/warnings",
        "plugin:import/typescript",
        "plugin:react/recommended"
    ],
    "plugins": ["prettier", "jest"],
    "rules": {
        "no-console": 0,
        "no-param-reassign": 0,
        "prettier/prettier": "error",
        "no-underscore-dangle": [
            "error",
            {
                "allow": ["__get__", "__set__"]
            }
        ],
        "import/extensions": [
            "error",
            "ignorePackages",
            {
                "js": "never",
                "jsx": "never",
                "ts": "never",
                "tsx": "never"
            }
        ]
    },
    "settings": {
        "react": {
            "version": "detect"
        }
    }
}

when i run npm run lint command i get the following Error:

8:1 error `express` import should occur before import of `./handlers/rootPath` import/order

i tried to move line 8 before import `./handlers/rootPath, but when i save it automatically git back to line 8.

Any idea how to fix it ?

  • `import express = require('express')` is not valid. Don't mix require with ES imports. For more info on imports see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import – evolutionxbox Jul 31 '20 at 12:11
  • 1
    simply use like this const express = require('express'); – deepak Jul 31 '20 at 12:14

0 Answers0