-
Notifications
You must be signed in to change notification settings - Fork 39
Replace tslint
with eslint
and prettier
#227
Replace tslint
with eslint
and prettier
#227
Conversation
It looks like @JamesLefrere hasn't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement at the following URL: https://cla.parity.io Once you've signed, please reply to this thread with Many thanks, Parity Technologies CLA Bot |
1 similar comment
It looks like @JamesLefrere hasn't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement at the following URL: https://cla.parity.io Once you've signed, please reply to this thread with Many thanks, Parity Technologies CLA Bot |
[clabot:check] |
It looks like @JamesLefrere signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
1 similar comment
It looks like @JamesLefrere signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very nice work @JamesLefrere, a huge thank you! It's been in a corner of my head to switch to typescript-eslint, since apparently that's the official way TS is going.
There's only one small thing that bugs me: spaces after function names. Is there a way to change .eslintrc to add this rule? In all parity JS/TS projects we have semistandard as the final styleguide (prettier being an optional step before), so I'd like to stick with that in this repo too.
Apart from that, everything lgtm.
Thanks @amaurymartiny, hope it helps. Hmm, it seems like it might be quite a pain to keep those extra spaces because of the Prettier team's choice. Here are the possible approaches I can see:
I'd honestly recommend not using standard (also because I'm not quite on board with some of the rules like no trailing commas), but I understand that's not really doable :) Let me know what you think and I'll go for it. |
How about just adding a couple of additional rules in .eslintrc (those that make prettier compatible with standard, i.e. spaces, maybe 1-2 others?), would that be possible?
Unfortunately we started to stick with semistandard in all parity projects, so that's a hard requirement. Additionally, I don't think prettier is enough, as it's only a formatter, whereas standard also checks code quality rules. If adding rules in .eslintrc is not possible, then I guess 1 or 2 both seem okay to me too, which is similar to what we did in fether: https://github.com/paritytech/fether/blob/master/scripts/lint-files.sh |
98af1a9
to
c564ebd
Compare
* Add and configure `eslint` and `prettier` for the monorepo; add a `lint` script accessible via `yarn lint` * Remove `tslint` * Add a `typecheck` script to the monorepo and each package; given that `tslint` used to do this, and `eslint` doesn't, it needs to be run separately * Codemod: run `yarn lint` on the project, which leads to some minor changes (e.g. spaces before function names, which sadly [isn't supported by Prettier](prettier/prettier#3847) * All rules with errors that couldn't be trivially fixed have been disabled; these should be re-enabled gradually * Made some small adjustments/eslint disabling for some files due to differences between tslint and eslint semistandard * Fixed a bug with the `inTraceFilter` formatter thanks to eslint
c564ebd
to
2bdc033
Compare
Right, got it. I had another look at this, and it makes more sense to mirror the previous setup a bit more by simply extending the eslint config for standard/semistandard. Easy! There are just a few deviations with this config and the tslint implementation, but since there were so few errors (under 10), I added some Also, eslint helpfully pointed out a minor bug: https://github.com/paritytech/js-libs/pull/227/files#diff-d4e5e510316e79663700052bab19cddcR237 I also took your suggestion and used the same setup for the linting script as Fether 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm! I'll just try to import all these files into Fether, and check that nothing breaks. If so, then I'll merge.
Thanks again @JamesLefrere |
In the process of having a look through #21 , I thought it would be helpful to be able to retain clean formatting/etc while making changes everywhere. Thankfully, the
typescript-eslint
packages make this easy to do now, andtslint
is being deprecated by its maintainers in favour of this.The workflow changes just slightly: a
typecheck
script has been added, because althoughtslint
runstsc
and exits with any errors,eslint
is only concerned with code formatting, and doesn't do type checking. This has been added to the monorepo and each package (and Travis, and the readme :)The other noticeable thing is the spaces before function names; unfortunately, enforcing this rule with prettier isn't possible with the official eslint/prettier, so I hope it's acceptable to lose those.
This PR makes the following changes:
eslint
andprettier
for the monorepotslint
yarn lint
on the project, which leads to some minor changes (e.g. spaces before function names, which sadly isn't supported by Prettiertypecheck
script to the monorepo and each package; given thattslint
used to do this, andeslint
doesn't, it needs to be run separatelyIdeally, future PRs can make the typescript linting rules stricter (rather than keep them turned off).
I also tested this with Fether, and it seems fine to me?
Cheers