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

feat!: add import sorting rule #126

Merged
merged 3 commits into from
Apr 5, 2023
Merged

feat!: add import sorting rule #126

merged 3 commits into from
Apr 5, 2023

Conversation

SgtPooki
Copy link
Member

@SgtPooki SgtPooki commented Jan 31, 2023

Lint import sorting, and support auto-fixing of import order. see ipfs/aegir#1178 for an example

SgtPooki added a commit to ipfs/aegir that referenced this pull request Jan 31, 2023
This PR shows an example of what changes ipfs/eslint-config-ipfs#126
would enforce. All of this these changes (except package.json) were done
by running `npm run lint -- --fix`.

CALLOUTS:
1. eslint was failing with locally linked package on missing plugins.
1. lint fix was called twice, with the first run failing due to an empty
line the first fix runthrough didn't fix.
1. tsc seems to be failing for aegir
@achingbrain achingbrain changed the title chore: add import sorting rule feat!: add import sorting rule Feb 1, 2023
Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

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

LGTM. I don't love all the empty lines between groups of imports because you frequently have one lone import in a group which just looks weird sitting there all on it's own, but I don't hate them either.

I updated the title to be feat!: because feature will break linting for pretty much every project, though it's easy to fix.

One caveat is that --fix only moves the imports around - it doesn't move the accompanying // @ts-expect-error no types comments we have in lots of places above imports of modules that don't ship with types.

achingbrain added a commit to ipfs/protons that referenced this pull request Feb 1, 2023
ipfs/eslint-config-ipfs#126 will introduce
linting rules on import sorting so order imports during building
in a way that will comply with the new linting rules.
achingbrain added a commit to ipfs/protons that referenced this pull request Feb 2, 2023
ipfs/eslint-config-ipfs#126 will introduce
linting rules on import sorting so order imports during building
in a way that will comply with the new linting rules.
@SgtPooki
Copy link
Member Author

One caveat is that --fix only moves the imports around - it doesn't move the accompanying // @ts-expect-error no types comments we have in lots of places above imports of modules that don't ship with types.

Yea, that's important. we could update the rule to support moving associated comments, but I haven't looked into that.

@SgtPooki SgtPooki marked this pull request as ready for review February 13, 2023 19:37
Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

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

A few suggestions to make this a bit simpler.

ts.js Outdated Show resolved Hide resolved
ts.js Outdated Show resolved Hide resolved
js.js Outdated Show resolved Hide resolved
@achingbrain achingbrain merged commit b580e0b into main Apr 5, 2023
@achingbrain achingbrain deleted the chore/import-sort branch April 5, 2023 15:52
achingbrain added a commit that referenced this pull request Apr 5, 2023
Lint import sorting, and support auto-fixing of import order. see ipfs/aegir#1178 for an example

---------

Co-authored-by: Alex Potsides <alex@achingbrain.net>
github-actions bot pushed a commit that referenced this pull request Apr 5, 2023
## [4.0.0](v3.1.7...v4.0.0) (2023-04-05)

### ⚠ BREAKING CHANGES

* `await` is not allowed before `return` unless it is inside a `try/catch` in which case it is required

Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
* previously jsx and tsx files were not linted, now they are
* add import sorting rule (#126)

### Features

* add import sorting rule ([#126](#126)) ([1462d09](1462d09))
* lint jsx ([#140](#140)) ([fb5e5b6](fb5e5b6))

### Bug Fixes

* only require `await`ing promises returned from inside try/catch blocks ([#133](#133)) ([a6e4a7b](a6e4a7b)), closes [#130](#130)

### Trivial Changes

* convert to aegir project ([81d8ba3](81d8ba3))
* **deps:** bump eslint-config-standard-with-typescript from 27.0.1 to 34.0.1 ([#135](#135)) ([fc9aa6f](fc9aa6f))
* **deps:** bump eslint-plugin-jsdoc from 39.9.1 to 40.1.1 ([#139](#139)) ([bd1422b](bd1422b))
* fix linting ([adffc58](adffc58))
* use unified ci ([2674c56](2674c56))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants