#Unable to configure the eslint for formating import

16 messages · Page 1 of 1 (latest)

muted quarry
#

Eslint config file:

module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.json',
    tsconfigRootDir: __dirname,
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint/eslint-plugin', 'import'],
  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:prettier/recommended',
  ],
  root: true,
  env: {
    node: true,
    jest: true,
  },
  ignorePatterns: ['.eslintrc.js'],
  rules: {
    '@typescript-eslint/interface-name-prefix': 'off',
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    'import/order': [
      'error',
      {
        groups: ['builtin', 'external', 'internal', 'parent', 'sibling'],
        pathGroups: [
          {
            pattern: '@nestjs/**',
            group: 'external',
            position: 'before',
          },
        ],
        'newlines-between': 'always',
      },
    ],
    'import/newline-after-import': ['error', { count: 1 }],
    'import/no-unresolved': 'error',
  },
};
#

TS config file:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "ES2021",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false
  },
  // Use dynamic polling instead of native system events
  "watchOptions": {
    "watchFile": "dynamicPriorityPolling",
    "watchDirectory": "dynamicPriorityPolling",
    "excludeDirectories": ["**/node_modules", "dist"]
  }
}

#

Service Code

import * as crypto from 'crypto';

import { Response, Request } from 'express';
import { JwtService } from '@nestjs/jwt';
import {
  Injectable,
  UnauthorizedException,
  BadRequestException,
} from '@nestjs/common';
import { UserService } from 'src/modules/user/user.service';
import { ConfigService } from 'src/modules/config/config.service';
import { AuthPayloadType } from 'src/common/types/auth.types';
import { AuthProvidersEnum } from 'src/common/enums/auth-providers.enum';
import { EmailNotificationService } from 'src/modules/email-notification/email-notification.service';
import * as speakeasy from 'speakeasy';
import * as qrcode from 'qrcode';
import { IUser } from 'src/common/types/user.type';
import { MESSAGES } from 'src/common/messages/index';
import { createHashVerifier } from 'src/common/lib/en-decryption.lib';
import { v4 as uuidv4 } from 'uuid';
import { plainToInstance } from 'class-transformer';
import { UserResponseDto } from 'src/common/dtos/user-response.dto';
import { transformToDto } from 'src/common/lib/transform-to-dto.lib';

import { CompleteGoogleProfileDto } from './dtos/complete-google-profile-dto';
import { SignupDto } from './dtos/signup.dto';
#

My code is working fine:

But after ading the support for eslitn-plugin-import i am getting errorlike this
*
Unable to resolve path to module src/modules/user/user.service'.eslintimport/no-unresolved

Unable to resolve path to module 'src/common/types/request.type'.eslintimport/no-unresolved
*

when i remove eslint import plugin i am getting no error

#

<@&520649667684466710>

mellow larkBOT
#

Please do not tag the moderators unless someone is breaking server rules. The mods are here to help enforce the rules of the server, and while most of them are knowledgeable about Nest, they are not the only ones able to solve your question.