swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.97k stars 6.04k forks source link

[typescript-angular] Disable tslint in generated files /* tslint:disable */ #6720

Open etrich opened 7 years ago

etrich commented 7 years ago
Description

The generated TS code disables only specific tslint rules:

/ tslint:disable:no-unused-variable member-ordering /

Some other generated files do not disable any tslint rules.

The generated code is causing tslint issues depending on configured rules, such as:

Swagger-codegen version

2.3.0 - swagger-codegen-cli-2.3.0-20171004.083430-178

Steps to reproduce
Suggest a fix/enhancement

Simple fix would be to disable all tslint rules in generated files:

/ tslint:disable /

macjohnny commented 7 years ago

@etrich could you file a pull request?

wing328 commented 7 years ago

I would suggest we fix those warnings/issues reported by tslint one by one instead of disabling tslint.

@etrich would you have time to help file PRs to make the TS Angular generator better? (this is not to say we push the task to you but I'm sure the community would appreciate your help to make the TS Angular generator better in terms of the code format)

etrich commented 7 years ago

I would suggest we fix those warnings/issues reported by tslint one by one instead of disabling tslint.

Given the rules can be dynamically configured in tslint.json, it would require a generator that can be dynamically configured using these rules and able to produce code in accordance. I don't think anyone wants to go there, so we'd need to agree on a tslint ruleset, which could be the tslint.json produced by Angular CLI ng new (which uses codelyzer).

For people wanting to use "non standard" tslint rules, there would still be an opt-out in Angular CLI by adding lines in .angular-cli.json:

"lint": [{ "project": "src/tsconfig.app.json", "exclude": ["/node_modules/", "custom-path"] },

I can probably find some time to help, what's release date for 2.3.0 ?

wing328 commented 6 years ago

I can probably find some time to help, what's release date for 2.3.0 ?

We hope to release it by the end of this year.

zimme commented 6 years ago

I'll just add a note here about tslint's no-unused-variable being deprecated in favor of tsc's --noUnusedLocals and friends. Which might be something to keep in mind.

JoshuaKGoldberg commented 3 years ago

Filed a related issue for typescript-fetch at #10835, but reposting here:

Would you accept a PR to remove references to TSLint?

quezak commented 3 years ago

@JoshuaKGoldberg good point! I have the generated files excluded in my ignored eslintrc section.

However, I actually do run eslint --fix from my scripts once after the code is generated, to get rid of unused imports etc, that could later cause a typescript compilation error. Not that this matters here, just wanted to provide a point of view :)