-
Notifications
You must be signed in to change notification settings - Fork 407
Use single quote literals in output for tslint #42
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
Conversation
bfabdef
to
8181b0c
Compare
When I run Unfortunately this didn't help. Then I noticed some failed tests in the commit history here: https://github.com/bcherny/json-schema-to-typescript/commits/master It looks like this might be circle specific issue because I don't have any failed tests on my end. |
notice circleCI is expecting many |
I found problem... it has nothing to do with the `#Arrray# mentioned in last comment. I just misread the logging. The problem is that there is a indent whitespace issue . I observed this problem in some of my JSONSchema to TS interface compile output elsewhere this morning too. Pull up these two strings from circleCI and scroll towards the end of the line. (or put it in your fav diff tool). Notice some lines aren't indented for some reason... export enum NamedIntegerEnum {\n One = 1,\n Two = 2,\n Three = 3\n}\nexport enum ImpliedNamedIntegerEnum {\n Four = 4,\n Five = 5,\n Six = 6\n}\nexport interface Enum {\n stringEnum: 'a' | 'b' | 'c';\n impliedStringEnum: 'a' | 'b' | 'c';\n literalWithSingleQuote: 'Some \\'string\\' with inner single quote' | 'b' | 'c';\n booleanEnum: true;\n impliedBooleanEnum: true;\n integerEnum: -1 | 0 | 1;\n impliedIntegerEnum: -1 | 0 | 1;\n numberEnum?: -1.1 | 0 | 1.2;\n namedIntegerEnum?: NamedIntegerEnum;\n impliedNamedIntegerEnum: ImpliedNamedIntegerEnum;\n impliedHeterogeneousEnum?: -20.1 | null | 'foo' | false;\n}
export enum NamedIntegerEnum {\n One = 1,\n Two = 2,\n Three = 3\n}\nexport enum ImpliedNamedIntegerEnum {\n Four = 4,\n Five = 5,\n Six = 6\n}\nexport interface Enum {\n stringEnum: 'a' | 'b' | 'c';\n impliedStringEnum: 'a' | 'b' | 'c';\n literalWithSingleQuote: 'Some \\'string\\' with inner single quote' | 'b' | 'c';\n booleanEnum: true;\n impliedBooleanEnum: true;\n integerEnum: -1 | 0 | 1;\nimpliedIntegerEnum: -1 | 0 | 1;\nnumberEnum ?: -1.1 | 0 | 1.2;\nnamedIntegerEnum ?: NamedIntegerEnum;\nimpliedNamedIntegerEnum: ImpliedNamedIntegerEnum;\nimpliedHeterogeneousEnum ?: -20.1 | null | 'foo' | false;\n} Now the question is... why does circleCI have different results than my local machine (and presumably yours too because I doubt you pushed your commits to master if the tests failed like circleCI). And why does some of my output for different JSON schema sometimes miss the indent. |
@darcyparker I'm aware of the whitespace issue, and am looking at it. My hunch is it's related to unix vs windows line endings, but I need to look at it more closely. Will review + merge this PR once the build issue is resolved. |
Great - glad you are on it. |
This fails for you locally sometimes? Are you running OSX? |
Tests always pass.
But I have seen indent issues today (not last week) for some json schema
outside this repo.
I am on Debian Linux.
|
@darcyparker Ready to go on my end |
975110a
to
a88455a
Compare
Thanks - BTW: updated comments look nice. |
@darcyparker I see what you're going for here, but I think it could be overcomplicating things. What do you think? |
@bcherny - I understand your concern. You're right that JSON.stringify is probably best. It's unexpected that the output style of the compiler is different than the project (semicolons and double quotes...) But I agree it is best to use JSON.stringify because it is correct and simpler. As I reflect on this, people are going to have different preferences for tslint (I prefer semicolons and single quotes for example) and the typescript definition output from the compiler will never satisfy everyone's preferences. So it is probably best to advise people to use a formatter such as https://github.com/vvakame/typescript-formatter to tune the output. ( |
I will close this... Do you want any of the following commits in a new pull request? Clean dist_tests before building tests, disable some tslint rules in test schemas, fix tslint no-consecutive-blank-lines, fix tslint missing whitespace, fix tslint unnecessary semicolon They are pretty minor I know.... so maybe you'll get them in future update. |
@darcyparker Sure - feel free to put all except |
I agree.
Also agreed! I removed the auto formatter in 1aa7317 because it was causing those occasional indentation issues on CI. We can also use tslint directly or maybe tslint-fix. In any case, this is pretty low priority. Filed #45 to track it. |
@bcherny - I revised this pull request based on last week's feedback to add tests. It is also rebased on top of the latest master.
I am not sure if the tests are where you'd like them. Some of the existing cases already test the single quotes. But I put some explicit ones here: 8181b0c#diff-632988bf801a8c538f18e7c4e222d9caR7