Skip to content
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

build(ui): automatically sort imports #13813

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

agilgur5
Copy link
Contributor

@agilgur5 agilgur5 commented Oct 24, 2024

Follow-up to #12539 "Future Work" part 3, #13160 (comment), #11811 (comment), #13069 (comment), and other places I've mentioned it

Motivation

Automatically sort imports for consistent style, like Python's isort but for JS/TS

Modifications

Verification

yarn lint has no more changes, otherwise this is purely stylistic and has no semantic changes

Notes to Reviewers

- like Python's `isort` but in JS/TS using https://github.com/IanVS/prettier-plugin-sort-imports
  - with [default config](https://github.com/IanVS/prettier-plugin-sort-imports/blob/e28fa0e92832a011a923fc5e3bc5a20705102406/README.md?plain=1#L198) plus [a newline](https://github.com/IanVS/prettier-plugin-sort-imports/blob/e28fa0e92832a011a923fc5e3bc5a20705102406/README.md?plain=1#L250) before relative imports and [CSS handling](https://github.com/IanVS/prettier-plugin-sort-imports/blob/e28fa0e92832a011a923fc5e3bc5a20705102406/README.md?plain=1#L234)
    - tried to get it as close to the existing style as possible with the smallest diff and least config
  - plus specify TS version according to [`yarn.lock`](https://github.com/argoproj/argo-workflows/blob/49ff7a44ba307416282a1f5cd3b844d19bce7f88/ui/yarn.lock#L9723)

- decided to use a `prettier` plugin instead of an `eslint` plugin as there was less configuration
  - and I generally jive with letting a tool decide consistent style, although `prettier` is not quite zero config, but "low" config
  - https://github.com/import-js/eslint-plugin-import / https://github.com/un-ts/eslint-plugin-import-x would be the alternative
    - and potentially still has useful options in terms of static analysis

Signed-off-by: Anton Gilgur <[email protected]>
@agilgur5 agilgur5 marked this pull request as ready for review October 24, 2024 23:45
@agilgur5
Copy link
Contributor Author

I couldn't request a review from @Adrien-D due to not being in the "members" team -- same reason as #8790 (comment) -- so tagging in this comment instead

@agilgur5 agilgur5 merged commit ba7be67 into argoproj:main Oct 25, 2024
17 checks passed
@agilgur5 agilgur5 deleted the build-ui-sort-imports branch October 25, 2024 14:40
@terrytangyuan
Copy link
Member

Added @Adrien-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Build or GithubAction/CI issues area/ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants