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

infra(unicorn): import-style #2901

Merged
merged 4 commits into from
May 31, 2024
Merged

infra(unicorn): import-style #2901

merged 4 commits into from
May 31, 2024

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented May 13, 2024

Ref: #2439


Permanently disables the unicorn/import-style lint rule.

This rule defines how a specific module has to be imported aka import * as foo from 'bar' vs import { oof } from 'bar'.
Unfortunately, it has the opinion that you should import the entirety of node:path, because "they have similar functions, all likely to be utilized", which I disagree with. Since this doesn't apply to any non configured package, and the defaults are subjective (and wrong IMO), I think we should disable this.

@ST-DDT ST-DDT added p: 1-normal Nothing urgent c: infra Changes to our infrastructure or project setup labels May 13, 2024
@ST-DDT ST-DDT added this to the vAnytime milestone May 13, 2024
@ST-DDT ST-DDT requested review from a team May 13, 2024 12:15
@ST-DDT ST-DDT self-assigned this May 13, 2024
Copy link

netlify bot commented May 13, 2024

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 4848bc2
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/6658a55924ba7f0007a8a469
😎 Deploy Preview https://deploy-preview-2901.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.95%. Comparing base (9daff54) to head (4848bc2).

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2901      +/-   ##
==========================================
- Coverage   99.96%   99.95%   -0.01%     
==========================================
  Files        2986     2986              
  Lines      215926   215926              
  Branches      598      945     +347     
==========================================
- Hits       215843   215824      -19     
- Misses         83      102      +19     

see 2 files with indirect coverage changes

@@ -39,6 +39,7 @@ module.exports = defineConfig({
'prefer-exponentiation-operator': 'error',
'prefer-template': 'error',

'unicorn/import-style': 'off', // subjective & doesn't do anything for us
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'unicorn/import-style': 'off', // subjective & doesn't do anything for us
'unicorn/import-style': [
'error',
{ styles: { 'node:path': { named: true } } },
],

Copy link
Member Author

@ST-DDT ST-DDT May 13, 2024

Choose a reason for hiding this comment

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

I tried that - see first commit - and I disagree.
The only thing we are using from that preset is node:path and there we don't use it and the other imports are totally unaffected.
We can talk about that in more detail, once I can talk again, If you would like.

Or let me ask the other way round:

  • What is the benefit of enabling it that way?

Copy link
Member

Choose a reason for hiding this comment

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

For example we use it here:

import { dirname, resolve } from 'node:path';

with that rule enabled, it prefers import { dirname, resolve } from 'node:path'; over import path from 'node:path';

with that rule set to off, anykind of syntax could be used

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw for that to be the case you have to set default to false.

But what about literally any other import in the entire project?

Copy link
Member

Choose a reason for hiding this comment

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

If you would like, you can find a config for that
I would like to always prefer "named"-imports
I (personally) don't like the "default" of unicorn/import-style

Copy link
Member Author

Choose a reason for hiding this comment

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

If you would like, you can find a config for that

Would you like to give it a try?

I would like to always prefer "named"-imports

Me too, but then there is the locales: https://github.com/faker-js/faker/blob/next/src/locales/cs_CZ/lorem/index.ts#L6

I (personally) don't like the "default" of unicorn/import-style

You can disable them completely with: extendDefaultStyles

Copy link
Member

Choose a reason for hiding this comment

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

I currently have set me a restriction to not actively contribute code and work on code in Open Source this week / until I'm back from USA, so I do a semi-open-source vacation.

Copy link
Member

Choose a reason for hiding this comment

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

@fisker is unicorn/import-style not simply configurable to just and only use named for every import possible? Or is that rule not intended for that usecase?

Copy link

Choose a reason for hiding this comment

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

@fisker is unicorn/import-style not simply configurable to just and only use named for every import possible?

No, not possible.

Or is that rule not intended for that usecase?

You can send a feature request.

Copy link

Choose a reason for hiding this comment

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

What is the benefit of enabling it that way?

It can be useful to avoid different style on the same module in one repo. You can choose any style that works and you like, personally I use named/namespace for node:path too.

@ST-DDT ST-DDT requested a review from Shinigami92 May 13, 2024 19:47
@ST-DDT ST-DDT dismissed Shinigami92’s stale review May 31, 2024 09:07

Nothing we can do about it for now

@ST-DDT
Copy link
Member Author

ST-DDT commented May 31, 2024

Since there is nothing we can do about it for now, I'll go ahead and merge this.
We can reconfigure this later once that feature is added.

EDIT: I don't know if you are going to create a PR, but if you do, you probably know more about how to configure it correctly anyway, so you can also create a new PR for the correct configuration.

@ST-DDT ST-DDT merged commit a082ed2 into next May 31, 2024
23 checks passed
@ST-DDT ST-DDT deleted the infra/unicorn/import-style branch May 31, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: infra Changes to our infrastructure or project setup p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants