Skip to content

Authing/eslint-plugin-authing-nestjs

Repository files navigation

eslint-plugin-authing-nestjs

authing

eslint-plugin-authing-nestjs is an MIT-licensed open source project for nestjs framework

Install

npm install --save-dev eslint-plugin-authing-nestjs

or

yarn add eslint-plugin-authing-nestjs -D

Usage

Configure it in your configuration file:

  • Add to plugins section:

  • Add to extends or rules section:

module.exports = {
  plugins: ['authing-nestjs'],
  extends: [
    'plugin:authing-nestjs/recommended'
  ],
  // *** Usage: refer to unit test documents for specific rules ***
  rules: {
    // It is forbidden to use parameters in the @Body, eg: @Body("name")
    'authing-nestjs/forbid_body_parameters': 'warn', // default 'error'

    // It is forbidden to read body from Req, eg: req.body
    'authing-nestjs/forbid_read_body_from_req': 'warn',

    // The @Body type annotation in the function must be a class, eg: @Body() dto: ClassDto
    'authing-nestjs/use_class_as_type_in_method_of_controller': 'warn',

    // Each DTO field must have a class validator
    // There must be at least 2 class validators for a DTO with IsOptional
    // For nested DTO,Type and ValidateNested must appear at the same time
    'authing-nestjs/use_class_validator_to_dto': 'warn',
    
    // ... more
  }
}

Changelog

Detailed changes for each release are documented in the release notes.

Contribution

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push -u origin my-new-feature)
  • Create new Pull Request

Help

Join us on forum: #authing-chat

License

MIT

Copyright (c) 2022 Authing

Links