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

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open

infra(unicorn): import-style #2901

wants to merge 3 commits into from

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 053c527
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/6648f61891a3380007aaee1a
😎 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.96%. Comparing base (7dc8a18) to head (053c527).

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2901      +/-   ##
==========================================
- Coverage   99.96%   99.96%   -0.01%     
==========================================
  Files        2977     2977              
  Lines      215422   215422              
  Branches      950      604     -346     
==========================================
- Hits       215351   215347       -4     
- Misses         71       75       +4     

see 1 file 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.

@ST-DDT ST-DDT requested a review from Shinigami92 May 13, 2024 19:47
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

3 participants