5 ms·
ah a perfect chance to get some Prettier+Typescript help! I am using Prettier+Typescript+React and when I do methods within classes, Prettier adds a semicolon f
by swyx 9y ago
ah a perfect chance to get some Prettier+Typescript help! I am using Prettier+Typescript+React and when I do methods within classes, Prettier adds a semicolon for me at the end of each class which `tslint` doesnt like. As far as I can tell, there is no setting for Prettier to ignore ONLY semicolons WITHIN classes, its just a blanket on or off. And its somehow not respecting tslint's semicolon preference. Any idea how to fix this?
```
class Demo extends React.Component<{}, {}> {
someStuff() {
// some code
}; // prettier adds this ; for me, i have to tslint:disable-line every time
}
```
- seepel 9y agoWe just turn off tslint formatting rules. There isn’t really a need for them if you are using prettier.
- swyx 9y agooh. unfortunately my team lead insists on having them. thanks anyway.
- mceachen 9y agotslint, while quite useful last year, still had (and has) known bugs with unused variables, missing/incorrect type assertions, and other annoyances. Most new versions of TypeScript expand on their `strict` rules, and just enabling `strict` in your tsconfig, as well as using prettier, is arguably a more robust superset of seatbelts than tslint offered. I deleted tslint from all my TS projects several months ago and don't miss it at all.
- saranshk 9y agoI don't think they will add them. They are very opinionated and skeptical about adding configuration options. If there is more of those, then again everyone will try and have an opinion of their own and it will end up being like ESLint. Also that will lead to a lot of time spent on understanding the configuration file which will be a disadvantage as well since currently prettier just works!
- b-glad 9y agoNpm install tslint-config-prettier and add it to the extends array in tslint.json to switch tslint rules to be compatible with prettier
- swyx 9y agoappreciate the tip, have an upvote
- NegativeLatency 9y agoI don’t use semicolons ;)