Skip to content

Conversation

@dario-piotrowicz
Copy link
Contributor

migration to eslint as tslint has been deprecated

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

ng lint runs the deprecated tslint

Issue Number: N/A

What is the new behavior?

ng lint runs eslint

Does this PR introduce a breaking change?

  • Yes
  • No

@google-cla google-cla bot added the cla: yes label Jul 11, 2021
@dario-piotrowicz
Copy link
Contributor Author

Hi @gkalpak 🙂

So, the migration is looking.... good?... hopefully? 😅

Screenshot at 2021-07-11 10-41-04

I opened this draft PR so start a bit of a discussion and see how you see this, I hope you don't mind 🙂

@dario-piotrowicz
Copy link
Contributor Author

First of all, what do you think of the incompatible typescript version? is this something we can accept or it's a deal breaker? 🤔

(I would not want to downgrade the current typescript just to accommodate eslint)

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work (as usual), @dario-piotrowicz ❤️
Just a few minor comments, but this is looking very promising 😃

@dario-piotrowicz
Copy link
Contributor Author

Awesome work (as usual), @dario-piotrowicz
Just a few minor comments, but this is looking very promising

Thanks a lot for the kind words!!!! 🙂

Well, your comments don't seem to be "just a few" 😅 (I'm going to check them out now!),
I really hope I am not burdening you with this 😓
thank you so very much for taking the time to review the PR 🥰


By the way, could you comment on the typescript version warning? don't you see it as a problem here? 🙂

@dario-piotrowicz dario-piotrowicz force-pushed the aio-tslint-to-eslint branch 4 times, most recently from a8959cb to 3dc0712 Compare July 13, 2021 23:14
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for making the changes, @dario-piotrowicz 👍
Getting closer 🏃‍♂️

Well, your comments don't seem to be "just a few" 😅

Given the size of the PR, they were really "just a few" 😛

I really hope I am not burdening you with this 😓
thank you so very much for taking the time to review the PR 🥰

It would have taken me much more time to do the actual work myself, so thank you for taking it on 💪

By the way, could you comment on the typescript version warning? don't you see it as a problem here? 🙂

Sorry, I meant to comment on that, but then forgot.
Yeah, it's not ideal, but I don't think it is a problem here (as long as linting passes 😅).

[NOTE-TO-SELF] Unresolved comments from previous review:
#42820 (comment), #42820 (comment), #42820 (comment), #42820 (comment), #42820 (comment), #42820 (comment)

@dario-piotrowicz dario-piotrowicz force-pushed the aio-tslint-to-eslint branch 5 times, most recently from 2f32874 to 2acf9d5 Compare July 14, 2021 21:57
@dario-piotrowicz
Copy link
Contributor Author

@gkalpak I think that it's looking good 😃

I was about to put this as ready for review but I noticed that the test_aio is failing and it is because of the example-lint and tools-lint scripts which don't work anymore as they use tslint which has been removed as part of the migration

I did not notice those before (and I am not sure what they are about), I will have a look tomorrow, hopefully once these are taken care of we will be in a good place with this 🙂

@gkalpak
Copy link
Member

gkalpak commented Jul 15, 2021

I was about to put this as ready for review but I noticed that the test_aio is failing and it is because of the example-lint and tools-lint scripts which don't work anymore as they use tslint which has been removed as part of the migration

Ah, good point, @dario-piotrowicz. For now, I think it is better to just focus on migrating the AIO app to eslint and keep tslint for the other scripts that need it (to keep the PR scope manageable). In a follow-up PR we can look into switching to eslint for more AIO scripts.

@dario-piotrowicz dario-piotrowicz force-pushed the aio-tslint-to-eslint branch 4 times, most recently from 6fe6c1b to 6355be4 Compare July 15, 2021 13:38
@gkalpak gkalpak added the target: patch This PR is targeted for the next patch release label Jul 16, 2021
@ngbot ngbot bot modified the milestone: Backlog Jul 16, 2021
@gkalpak gkalpak removed the request for review from aikithoughts July 16, 2021 13:24
@dario-piotrowicz
Copy link
Contributor Author

dario-piotrowicz commented Jul 16, 2021

Looks awesome
Thank you so much for taking care of this, @dario-piotrowicz

And the detailed commit message is super helpful too

One last question regarding:

for some reason the "no-console" rule would not work in eslint and has been substituted with an equivalent "no-restricted-syntax" one

What exactly didn't work with the no-console rule? (I've never had problems with it in other projects )

Reviewed-for: global-docs-approvers

thanks!!!!! 😍

about the "no-console", sorry that's just another silly mistake of mine 🙈 😅

I just checked and it does work, the issue now is that the eslint rule has the allows option in which you specify which methods you want to allow, whilst the tslint rule made you specify the ones that you didn't want to allow

so with no-restricted-syntax I am keeping the same exact behaviour here, if I had to do the same with no-console I think I'd have to specify quite some methods 😢 (https://developer.mozilla.org/en-US/docs/Web/API/Console#methods)

Alternatively I can just put no-console and only allow log, warn and error, that should also be pretty similar I think

what do you think the best solution here would be? 🙂

( once you let me know I'll update the commit message and eventually change the rules 🙂 )

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I think enabling the no-console rule and only allowing log, warn and error is fine. (We could also consider info and debug, but they are not used anywhere, we can leave them out for now.)

@dario-piotrowicz
Copy link
Contributor Author

@gkalpak should be all good now 😃

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 🚀 :shipit:

migrate aio to eslint as tslint has been deprecated, the migration is restricted to the aio app and
its e2e tests and does not include the other tools, for such reason both tslint and codelyzer have not
been removed (to be done in a next PR)

some minor tweaks needed to be applied to the code so that it would adhere to the new ESLinting behaviour

most TSLint rules have been substituted with their ESLint equivalent, with some exceptions:
  * [whitespace] does not have an ESLint equivalent (suggested to be handled by prettier)
  * [import-spacing] does not have an ESLint equivalent (suggested to be handled by prettier)
  * [ban] replaced with [no-restricted-syntax] as there is no (official/included) ESLint equivalent

some rules have minor different behaviours compared to their TSLint counterparts:
  * @typescript-eslint/naming-convention:
    - typescript-eslint does not enforce uppercase for const only.
  * @typescript-eslint/no-unused-expressions:
    - The TSLint optional config "allow-new" is the default ESLint behavior and will no longer be ignored.
  * arrow-body-style:
    - ESLint will throw an error if the function body is multiline yet has a one-line return on it.
  * eqeqeq:
    - Option "smart" allows for comparing two literal values, evaluating the value of typeof and null comparisons.
  * no-console:
    - Custom console methods, if they exist, will no longer be allowed.
  * no-invalid-this:
    - Functions in methods will no longer be ignored.
  * no-underscore-dangle:
    - Leading and trailing underscores (_) on identifiers will now be ignored.
  * prefer-arrow/prefer-arrow-functions:
    - ESLint does not support allowing standalone function declarations.
    - ESLint does not support allowing named functions defined with the function keyword.
  * space-before-function-paren:
    - Option "constructor" is not supported by ESLint.
    - Option "method" is not supported by ESLint.

additional notes:
  * the current typescript version used by the aio app is 4.3.5, which is not supported by typescript-eslint (the supported
    versions are >=3.3.1 and <4.3.0). this causes a warning message to appear during linting, this issue should
    likely/hopefully disappear in the future as typescript-eslint catches up
  * The new "no-console" rule is not completely equivalent to what we had prior the migration, this is because TSLint's "no-console"
    rule let you specify the methods you did not want to allow, whilst ESLint's "no-console" lets you specify the methods that you do
    want to allow, so and in order not to have a very long list of methods in the ESLint rule it's been decided for the time being
    to simply only allow the "log", "warn" and "error" methods
  * 4 dependencies have been added as they have been considered necessary (see: angular#42820 (comment))

extra:
  * the migration has been performed by following: https://github.com/angular-eslint/angular-eslint#migrating-an-angular-cli-project-from-codelyzer-and-tslin
  * more on typescript-eslint at: https://github.com/typescript-eslint/typescript-eslint
@gkalpak gkalpak removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jul 20, 2021
@gkalpak gkalpak removed the request for review from alan-agius4 July 20, 2021 14:25
@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 20, 2021
@alxhub alxhub added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jul 20, 2021
@alxhub
Copy link
Member

alxhub commented Jul 20, 2021

I switched this to target: minor because it doesn't merge cleanly into the current patch branch (12.1.x). Given the nature of this change, I think this is probably fine.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes refactoring Issue that involves refactoring or code-cleanup target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants