Skip to content

Commit

Permalink
release: v1.0.11 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyiming0803 committed Feb 11, 2022
1 parent 4e0b23c commit 111bd68
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-authing-nestjs",
"version": "1.0.10",
"version": "1.0.11",
"license": "MIT",
"description": "ESLint rules for nestjs framework",
"main": "dist/index.js",
Expand Down
50 changes: 25 additions & 25 deletions src/rules/use-class-validator-to-dto/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import {
} from 'estree'
import { getDecoratorByName } from '../../utils'

interface IConfig {
node: ClassDeclaration
}

export const bodyParamMap = new Map()
export const preClassMap = new Map()
export const postClassMap = new Map()
Expand All @@ -21,6 +25,27 @@ export const messages = {
invalidTypeWithValidateNested: 'Type and ValidateNested must appear at the same time'
}

export function forEachClassDefinitionBody(
node: ClassDeclaration,
context: IContext,
config: IConfig,
validateDto: IValidateDtoFn,
isNested: boolean
) {
node.body.body.forEach((nodeItem: MethodDefinition | PropertyDefinition) => {
checkDtoClassValidator(nodeItem, context, config)
checkDtoClassValidatorLength(nodeItem, context, config)
if (
isNested &&
nodeItem?.decorators?.length &&
nodeItem.decorators.find(decorator => decorator.expression.callee.name === 'ValidateNested')
) {
checkTypeWithValidateNested(node, nodeItem.decorators, context)
checkNestedDto(nodeItem, context, validateDto)
}
})
}

export function $MethodDefinition(node: MethodDefinition, context: IContext) {
const bodyParam: Pattern | undefined = node.value.params.find(p => getDecoratorByName(p, 'Body'))

Expand All @@ -41,10 +66,6 @@ export function $MethodDefinition(node: MethodDefinition, context: IContext) {
}
}

interface IConfig {
node: ClassDeclaration
}

function checkDtoClassValidator(
nodeItem: MethodDefinition | PropertyDefinition,
context: IContext,
Expand Down Expand Up @@ -100,24 +121,3 @@ function checkTypeWithValidateNested(node: BaseNode, decorators: IDecorator[], c
})
}
}

export function forEachClassDefinitionBody(
node: ClassDeclaration,
context: IContext,
config: IConfig,
validateDto: IValidateDtoFn,
isNested: boolean
) {
node.body.body.forEach((nodeItem: MethodDefinition | PropertyDefinition) => {
checkDtoClassValidator(nodeItem, context, config)
checkDtoClassValidatorLength(nodeItem, context, config)
if (
isNested &&
nodeItem?.decorators?.length &&
nodeItem.decorators.find(decorator => decorator.expression.callee.name === 'ValidateNested')
) {
checkTypeWithValidateNested(node, nodeItem.decorators, context)
checkNestedDto(nodeItem, context, validateDto)
}
})
}

0 comments on commit 111bd68

Please sign in to comment.