Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLINT_DISABLE flag added #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DisjointUnionExample.validator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* tslint:disable */
/* eslint:disable */
// generated by typescript-json-validator
import Ajv = require('ajv');
import {
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/output/ComplexExample.validator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* tslint:disable */
/* eslint:disable */
// generated by typescript-json-validator
import Ajv = require('ajv');
import {MyEnum, TypeA, TypeB, RequestA, RequestB} from '../../ComplexExample';
Expand Down
2 changes: 2 additions & 0 deletions src/printValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function printTypeCollectionValidator(
});
return [
t.TSLINT_DISABLE,
t.ESLINT_DISABLE,
t.GENERATED_COMMENT,
t.IMPORT_AJV(tsConfig),
t.importNamedTypes(symbols, relativePath),
Expand Down Expand Up @@ -52,6 +53,7 @@ export function printSingleTypeValidator(
) {
return [
t.TSLINT_DISABLE,
t.ESLINT_DISABLE,
t.GENERATED_COMMENT,
t.IMPORT_INSPECT,
t.IMPORT_AJV(tsConfig),
Expand Down
5 changes: 3 additions & 2 deletions src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import stringify from 'json-stable-stringify';
import * as TJS from 'typescript-json-schema';

export const TSLINT_DISABLE = `/* tslint:disable */`;
export const ESLINT_DISABLE = `/* eslint:disable */`;
export const GENERATED_COMMENT = `// generated by typescript-json-validator`;

export const IMPORT_INSPECT = `import {inspect} from 'util';`;
Expand Down Expand Up @@ -121,7 +122,7 @@ export const VALIDATE_KOA_REQUEST_IMPLEMENTATION = `export function validateKoaR
const data = prop === 'body' ? ctx.request && (ctx.request as any).body : (ctx as any)[prop];
if (validator) {
const valid = validator(data);

if (!valid) {
ctx.throw(
400,
Expand All @@ -148,7 +149,7 @@ export const VALIDATE_IMPLEMENTATION = `export function validate(typeName: strin
if (!validator) {
throw new Error(\`No validator defined for Schema#/definitions/\${typeName}\`)
}

const valid = validator(value);

if (!valid) {
Expand Down