Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: support typescript linting and type checking #474

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

kabaros
Copy link
Contributor

@kabaros kabaros commented Oct 18, 2024

This PR adds support to linting and type checking typescript projects.

Notes:

  1. As part of this, I upgraded eslint to v8. This is not the latest, the latest v9 requires a new structure for eslint configs, and would mean that we'd have to pass a flag to use the old config in our projects. I plan to write an RFC for the next steps for the configs (proposing to use shared configs and using the CLI tool only as a helper for installing these configs) and I will look at upgrading eslint to v9 as part of that.

  2. I added a check to run tsc --noEmit to do a type check on Typescript projects - this is an implicit test that runs wheneever it seems a tsconfig.json in the root of the project. I think that if a consumer is using TS then they should make sure it compiles, they're free to disable rules or change the config, but it should always compile.

  3. For this to work without a module resolution, we also need to bump this outdated version of TS in app-shell: fix: bump typescript version used in app shell app-platform#885

  4. Right now, it shows the below warnning since hte eslint plugin was not updated to support the latest version of TS but that's not an issue
    image

Testing

I tested this works with route-manager-app (TS), data-entry-beta (JS), data-visualiser (JS), maintenance-app-beta (TS)

Followups:

  • update Typescript template in app-platform@alpha to use this config

implements https://dhis2.atlassian.net/browse/LIBS-696

@kabaros kabaros force-pushed the feat/support-typescript branch from 698bc92 to b94f3f8 Compare October 18, 2024 08:33
@kabaros
Copy link
Contributor Author

kabaros commented Oct 21, 2024

the one major question I have here is whether we should use eslint@8, or use eslint@9 and internally pass the flag ESLINT_USE_FLAT_CONFIG=FALSE so that it accepts old-style config files.

Note there is an official codemod for migrating the config so maybe apps can just run that: npx @eslint/migrate-config .eslintrc.json

@kabaros kabaros changed the base branch from master to alpha October 22, 2024 15:17
Copy link
Contributor

@KaiVandivier KaiVandivier left a comment

Choose a reason for hiding this comment

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

Tested and working well in Route Manager and Maintenance (beta), both TS apps -- but getting dependency quirks in JS apps due to duplicate ESlint deps

Approved for testing in alpha to see if there are local dep resolution quirks going on with yalc, and hopefully it will work on a normal NPM release 👍

@kabaros kabaros merged commit b68f69a into alpha Oct 22, 2024
9 checks passed
@kabaros kabaros deleted the feat/support-typescript branch October 22, 2024 15:28
dhis2-bot added a commit that referenced this pull request Oct 22, 2024
# [10.8.0-alpha.1](v10.7.4...v10.8.0-alpha.1) (2024-10-22)

### Features

* support typescript linting and type checking ([#474](#474)) ([b68f69a](b68f69a))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 10.8.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

kabaros added a commit that referenced this pull request Oct 24, 2024
* feat: support typescript linting and type checking (#474)

* feat: support typescript eslint

* feat: run tsc --noEmit on typescript projects

* chore: remove unused babel-eslint package

* chore(release): cut 10.8.0-alpha.1 [skip release]

# [10.8.0-alpha.1](v10.7.4...v10.8.0-alpha.1) (2024-10-22)

### Features

* support typescript linting and type checking ([#474](#474)) ([b68f69a](b68f69a))

---------

Co-authored-by: @dhis2-bot <apps@dhis2.org>
dhis2-bot added a commit that referenced this pull request Oct 28, 2024
## [10.7.5](v10.7.4...v10.7.5) (2024-10-28)

### Bug Fixes

* force a release ([2ef782a](2ef782a))

### Features

* support typescript linting and type checking ([#475](#475)) ([296dd60](296dd60)), closes [#474](#474) [#474](#474)
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants