By simply reading the docs it isn't clear if that rule applies only to the import of the three listed modules (util, path, chalk) or all modules when using the default "plugin:unicorn/recommended"
.
My first assumption was that style default
was prioritized over the other, while in fact it's only the three modules shown that are affected.
import * as React from "react";
.import * as path from "node:path";
.Sometimes a module contains unrelated functions, like `util`, thus it is a good practice to enforce destructuring or named imports here. Other times, in modules like `path`, it is good to use default import as they have similar functions, all likely to be utilized.
+This rule applies only to specified modules in `styles` option. If a module is not listed in `styles`, it will not be linted.
This rule defines 4 import styles:
### styles
Type: `object`
-You can extend default import styles per module by passing the `styles` option.
+You can extend the import styles accepted for each module individually by passing the `styles` option and adding a key for each module.
Default options per module are:
tsconfig.json
Since default configuration for tsconfig.json
are false
for both allowSyntheticDefaultImports
and esModuleInterop
, using default import is not authorized; it raise error TS1259.
Sometimes a module contains unrelated functions, like `util`, thus it is a good practice to enforce destructuring or named imports here. Other times, in modules like `path`, it is good to use default import as they have similar functions, all likely to be utilized.
+π« Using the default configuration of this rule will contradict with configuration of TypeScript `allowSyntheticDefaultImports = false` and `esModuleInterop = false`. In such case, you can disable this rule or extend the styles to allow `namespace` import style for the module that requires it like `path` or `react`.
This rule defines 4 import styles:
Feel free to use another emoji, I used the dizzy one, since I was so dizzy or figuring this out π !
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too