首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >定义了Eslint wong错误,但从未对所有装饰人员使用NestJ中的警告

定义了Eslint wong错误,但从未对所有装饰人员使用NestJ中的警告
EN

Stack Overflow用户
提问于 2022-09-03 11:08:25
回答 1查看 2.3K关注 0票数 7

我正在为一个项目使用NestJ框架。今天,EsLint发现了587个错误的问题。

所有装饰器都会产生此错误:

代码语言:javascript
运行
复制
warning  'IsBoolean' is defined but never used      @typescript-eslint/no-unused-vars
warning  'IsEmail' is defined but never used        @typescript-eslint/no-unused-vars
warning  'IsEnum' is defined but never used         @typescript-eslint/no-unused-vars
warning  'IsInt' is defined but never used          @typescript-eslint/no-unused-vars
warning  'IsOptional' is defined but never used     @typescript-eslint/no-unused-vars
...

所有索引文件都会生成此错误。

代码语言:javascript
运行
复制
error  No named exports found in module './users.controller'  import/export
error  No named exports found in module './users.service'     import/export
error  No named exports found in module './users.module'  

但是所有的装饰器都被使用了,而且没有索引文件有一个命名的导出。这是我的DTO类的示例。

代码语言:javascript
运行
复制
import {
  IsBoolean,
  IsEmail,
  IsEnum,
  IsInt,
  IsOptional,
  IsString,
  Matches,
  Max,
  MaxLength,
  Min,
  MinLength,
} from 'class-validator';

export class UpdateUserDto {
  @IsOptional()
  @IsString()
  @Matches(/^[a-zA-Z0-9-_.@]+$/)
  @MinLength(3)
  @MaxLength(32)
  @ToCase({strategy: 'lower'})
  @Trim()
  username?: string;
...

这是我的索引文件之一:

代码语言:javascript
运行
复制
export * from './users.controller';
export * from './users.service';
export * from './users.module';
export * from './auth.controller';
export * from './auth.service';

我的eslintrc.js:

代码语言:javascript
运行
复制
module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.json',
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint/eslint-plugin', 'import'],
  extends: [
    './node_modules/gts/',
    'plugin:@typescript-eslint/recommended',
    'prettier/@typescript-eslint',
    'plugin:prettier/recommended',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:import/typescript',
  ],
  root: true,
  env: {
    node: true,
    jest: true,
  },
  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': 'warn',
    'import/no-unresolved': 'error',
    'import/no-cycle': 'warn',
    'node/no-extraneous-import': [
      'error',
      {
        allowModules: ['express'],
      },
    ],
  },
  settings: {
    ['import/parsers']: {'@typescript-eslint/parser': ['.ts', '.tsx']},
    ['import/resolver']: {
      node: {
        extensions: ['.ts'],
        moduleDirectory: ['node_modules', 'src/'],
      },
      typescript: {
        alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
        
      },
    },
  },
};
EN

回答 1

Stack Overflow用户

发布于 2022-09-03 15:20:47

类型记录4.8.0更改了类型转录-eslint用于确定是否使用函数的基础AST。You should be able to update all of your @typescript-eslint/* packages to @5.35.1 or higher和它都应该重新开始工作了

票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73591752

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档