rhys-vdw / ts-auto-guard

Generate type guard functions from TypeScript interfaces
MIT License
497 stars 53 forks source link

OR statements not grouped #308

Open igorfraa opened 6 days ago

igorfraa commented 6 days ago

following generated code and causes linter error:

typedObj !== null &&
      typeof typedObj === 'object' ||
        typeof typedObj === 'function'

ESLint: Unexpected mix of '&&' and '||'. Use parentheses to clarify the intended order of operations.(no-mixed-operators)

igorfraa commented 6 days ago

according to https://github.com/rhys-vdw/ts-auto-guard/blob/9fef944b6821aae801e02e2491db81009b120396/src/index.ts#L193 it should be enclosed, but generated code is not enclosed with ts-auto-guard ^5.0.1

igorfraa commented 6 days ago

actually, looking at the code i've found ands() returned ungrouped which is embarassing linter

@rhys-vdw, could you please review merge request https://github.com/rhys-vdw/ts-auto-guard/pull/309 ? I'd like to proceed with updating the other test cases after your feedback.

rhys-vdw commented 6 days ago

You should exclude output from your linter because it's auto generated. You can use an exclude pattern like *.guard.ts.

The output can't account for every linter config, and its correctness is ensured by tests.