We use the same validation pipe for the application code and unit tests. To make it reusable, we created an object to store the validation pipe options like this:
app.useGlobalPipes(
new ValidationPipe({
...validationPipeOptions,
})
);
This breaks the linting, the stack trace looks like this:
> nx run backend:lint
Linting "backend"...
> NX Cannot read properties of undefined (reading 'name')
Occurred while linting /home/user/Webdevelopment/Freelancing/Client/repository/apps/backend/src/test/controller-utils.ts:76
Rule: "@darraghor/nestjs-typed/should-specify-forbid-unknown-values"
TypeError: Cannot read properties of undefined (reading 'name')
Occurred while linting /home/user/Webdevelopment/Freelancing/Client/repository/apps/backend/src/test/controller-utils.ts:76
Rule: "@darraghor/nestjs-typed/should-specify-forbid-unknown-values"
at /home/user/Webdevelopment/Freelancing/Client/repository/node_modules/.pnpm/@darraghor+eslint-plugin-nestjs-typed@3.21.2_@typescript-eslint+parser@5.59.2_class-validator_h7qfkjnhkslhix4uwhkjr3zqvq/node_modules/@darraghor/eslint-plugin-nestjs-typed/dist/rules/shouldSpecifyForbidUnknownValues/shouldSpecifyForbidUnknownValuesRule.js:19:160
at Array.find (<anonymous>)
at checkObjectExpression (/home/user/Webdevelopment/Freelancing/Client/repository/node_modules/.pnpm/@darraghor+eslint-plugin-nestjs-typed@3.21.2_@typescript-eslint+parser@5.59.2_class-validator_h7qfkjnhkslhix4uwhkjr3zqvq/node_modules/@darraghor/eslint-plugin-nestjs-typed/dist/rules/shouldSpecifyForbidUnknownValues/shouldSpecifyForbidUnknownValuesRule.js:19:142)
at shouldTriggerNewExpressionHasProperty (/home/user/Webdevelopment/Freelancing/Client/repository/node_modules/.pnpm/@darraghor+eslint-plugin-nestjs-typed@3.21.2_@typescript-eslint+parser@5.59.2_class-validator_h7qfkjnhkslhix4uwhkjr3zqvq/node_modules/@darraghor/eslint-plugin-nestjs-typed/dist/rules/shouldSpecifyForbidUnknownValues/shouldSpecifyForbidUnknownValuesRule.js:49:46)
at NewExpression (/home/user/Webdevelopment/Freelancing/Client/repository/node_modules/.pnpm/@darraghor+eslint-plugin-nestjs-typed@3.21.2_@typescript-eslint+parser@5.59.2_class-validator_h7qfkjnhkslhix4uwhkjr3zqvq/node_modules/@darraghor/eslint-plugin-nestjs-typed/dist/rules/shouldSpecifyForbidUnknownValues/shouldSpecifyForbidUnknownValuesRule.js:86:82)
at ruleErrorHandler (/home/user/Webdevelopment/Freelancing/Client/repository/node_modules/.pnpm/eslint@8.39.0/node_modules/eslint/lib/linter/linter.js:1045:28)
at /home/user/Webdevelopment/Freelancing/Client/repository/node_modules/.pnpm/eslint@8.39.0/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/home/user/Webdevelopment/Freelancing/Client/repository/node_modules/.pnpm/eslint@8.39.0/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/home/user/Webdevelopment/Freelancing/Client/repository/node_modules/.pnpm/eslint@8.39.0/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
It works fine when using it as intended like:
app.useGlobalPipes(
new ValidationPipe({
forbidUnknownValues: false
})
);
We use the same validation pipe for the application code and unit tests. To make it reusable, we created an object to store the validation pipe options like this:
This breaks the linting, the stack trace looks like this:
It works fine when using it as intended like: