Skip to content

chore: migrate tslint to eslint #199

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

Merged

Conversation

the-ult
Copy link
Contributor

@the-ult the-ult commented Apr 13, 2021

What

Migrate from TSLint to ESLint
and upgrade dependencies

Why

To provide the 'best' examples possible, we should make sure the examples are making use of the best practices. Like discussed here
To help doing that, there are 2 great ESLint plugins:

To be able to use these plugins we first need to migrate from TSLint to ESLint.

This PR is a prerequisite of #198 (Adding the above plugins and improve the examples)

How

  • Upgrade to NX 12.0.3
    • Needed to be able to use the @nrwl/angular:convert-tslint-to-eslint schematic
  • Move apps/example-app/app/examples to apps/example-app/app/examples
    • Needed to be able to use the @nrwl/angular:convert-tslint-to-eslint schematic since the schematic expects the 'NX' structure for an app
  • Migrate TSLint to ESLint
    • example-app
    • jest-utils
    • testing-library
  • ESLint
    • Remove duplicate rules which are already provided by NX or other [plugin]/recommended

Troubleshooting

Removing TSLint
Could not remove tslint from the package.json due to the following errors in a migration file:

projects/testing-library/migrations/4_0_0/rules/noComponentParametersRule.ts
(2,49): error TS2307: Cannot find module 'tslint' or its corresponding type declarations.
projects/testing-library/migrations/4_0_0/rules/noComponentParametersRule.ts
(38,82): error TS2339: Property 'ruleName' does not exist on type 'Rule'.
projects/testing-library/migrations/4_0_0/rules/noComponentParametersRule.ts
(39,66): error TS2339: Property 'ruleName' does not exist on type 'Rule'.
projects/testing-library/migrations/4_0_0/rules/noComponentPropertyRule.ts
(2,49): error TS2307: Cannot find module 'tslint' or its corresponding type declarations.
projects/testing-library/migrations/4_0_0/rules/noComponentPropertyRule.ts
(19,69): error TS2339: Property 'ruleName' does not exist on type 'Rule'.
projects/testing-library/migrations/4_0_0/rules/noCreateComponentRule.ts
(2,49): error TS2307: Cannot find module 'tslint' or its corresponding type declarations.
projects/testing-library/migrations/4_0_0/rules/noCreateComponentRule.ts
(27,69): error TS2339: Property 'ruleName' does not exist on type 'Rule'.
projects/testing-library/migrations/4_0_0/rules/noCreateComponentRule.ts
(37,69): error TS2339: Property 'ruleName' does not exist on type 'Rule'.
projects/testing-library/migrations/5_1_2/rules/noAngularExtensionsImportRule.ts
(2,49): error TS2307: Cannot find module 'tslint' or its corresponding type declarations.
projects/testing-library/migrations/5_1_2/rules/noAngularExtensionsImportRule.ts
(23,69): error TS2339: Property 'ruleName' does not exist on type 'Rule'.

Checklist

  • Tests
  • Check / improve the ESLint rules
    • Are there any more duplicates which can be removed?
  • Documentation
    • Adjust documentation on testing-library to the github examples
      • src is added as root of example-app -> apps/example-app/app/examples/src instead of apps/example-app/app/examples
  • Ready to merge

arjen.althoff and others added 20 commits April 12, 2021 16:45
Use NX migrations to upgrade NX.
Upgrades Angular to 11.2.9
To be more in line with the NX defaults, the application files are moved to the ./src folder.

The tslint-to-eslint migration was failing.
Might have been due to being a flattened project.
Remove all angular-eslint/recommended rules.
These are provided by the @nrwl/nx plugin

fix(eslint): remove duplicate rules

Remove all eslint/recommended rules.
These are provided by the @nrwl/nx plugin
Somehow the npm run format does not fix all prettier issues.
Therefore ran prettier separate.

Added the .prettierignore file
Update deprecated imports
remove duplicate rules from:
- 'eslint:recommended',
- 'plugin:@typescript-eslint/eslint-recommended',
Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

I noticed that the "ready to merge" checkbox isn't checked.
What would still need to be done in order to get this merged?

From my point of view, this is looking great already and I would lean towards removing TSLint and the migrations.

One remark, there's a link to the example app in the README, that should be updated to the new location.

@the-ult
Copy link
Contributor Author

the-ult commented Apr 14, 2021

Wasn't sure I could check it or the reviewer (you) should 😇
I'll try and remove the migration and the TSLint and fix the README

the-ult added 3 commits April 14, 2021 20:50
By removing the obsolete TSLint dependency, we need to remove the migrations as well. Since these depend on TSLint specific properties/types

BREAKING CHANGE: migrations for v4.0.0 and v5.1.2 are no longer available
@the-ult the-ult changed the title WIP: feat: migrate tslint to eslint feat: migrate tslint to eslint Apr 14, 2021
@the-ult
Copy link
Contributor Author

the-ult commented Apr 14, 2021

BTW:
I tried updating the:

@testing-library/dom          7.29.4  7.29.4  7.30.3  node_modules/@testing-library/dom         angular-testing-library
@testing-library/user-event   12.8.3  12.8.3  13.1.2  node_modules/@testing-library/user-event  angular-testing-library

but these updates caused issues with fakeAsync etc. So I thought it would be best to leave these updates to separate PR by someone with more knowledge of the testing-library 😇

For example: Updating 'only' @testing-library/dom to 7.30.3 results in:

 FAIL   ATL  projects/testing-library/tests/wait-for.spec.ts
  ● allows to override options

    expect(received).rejects.toThrow()

    Received promise resolved instead of rejected
    Resolved to value: <div>Success</div>

      34 |   fireEvent.click(screen.getByTestId('button'));
      35 |
    > 36 |   await expect(waitForATL(() => screen.getByText('Success'), { timeout: 200 })).rejects.toThrow(
         |         ^
      37 |     /Unable to find an element with the text: Success/i,
      38 |   );
      39 | });

      at expect (../../node_modules/expect/build/index.js:134:15)
      at tests/wait-for.spec.ts:36:9
      at fulfilled (../../node_modules/tslib/tslib.js:114:62)
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:407:30)
      at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:3765:43)
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:406:56)
      at Zone.Object.<anonymous>.Zone.run (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:167:47)
      at ../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1325:38
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invokeTask (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:441:35)
      at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvokeTask (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:3796:43)
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invokeTask (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:440:64)
      at Zone.Object.<anonymous>.Zone.runTask (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:212:51)
      at drainMicroTaskQueue (../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:627:39)

@the-ult
Copy link
Contributor Author

the-ult commented Apr 14, 2021

Should we/somebody update the documentation on the testing-library/docs page after merging?

@timdeschryver
Copy link
Member

timdeschryver commented Apr 14, 2021

Yep, those failing tests with the latest version of dom testing library are on our radar (that's why it's currently pinned).
I'll give this another look tomorrow morning, but I think this can be merged 🎉
Thanks in advance!

Once it's merged, we'll update the docs.

@the-ult
Copy link
Contributor Author

the-ult commented Apr 15, 2021

After it is merged I'll start the PR with the testing-library eslint rules 👍

@timdeschryver timdeschryver merged commit a9383fa into testing-library:master Apr 15, 2021
@timdeschryver timdeschryver changed the title feat: migrate tslint to eslint chore: migrate tslint to eslint Apr 15, 2021
@timdeschryver
Copy link
Member

Thanks @the-ult !
@all-contributors please add @the-ult for code

@allcontributors
Copy link
Contributor

@timdeschryver

I've put up a pull request to add @the-ult! 🎉

@the-ult
Copy link
Contributor Author

the-ult commented Apr 15, 2021

@timdeschryver I adjusted the url on testing-library.com as well.

@github-actions
Copy link

🎉 This PR is included in version 10.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants