-
-
Notifications
You must be signed in to change notification settings - Fork 420
Description
Let me set the scene, we have 2 files, one file has the variable and the other imports it, the variables name is chartProps and its imported via
import { chartProps } from "./chart"after running eslint . --fix the variable's name changes to chartProperties which is good, but the import in the other file becomes
import { chartProps as chartProperties } from "./chart"which is completely wrong, the rule already changed the variables name in the first file so this leads to an incorrect auto-fix in the import.
There's no real way to handle this, we can try to use the changed variables name in the import so the import becomes
import { chartProperties } from "./chart"But this quickly runs into the same issue because we can't be sure that the file that we are importing from is getting hit with the eslint fix, so editing the import to chartProperties could still lead to an inaccurate auto-fix since the variable might not have ever changed, however it's definitely safer than aliasing it to what it should be, it's going to lead to less broken code in most cases.
My suggestion is to completely remove auto-fix from this rule.
unicorn/prevent-abbreviations
// BEFORE AUTO-FIX
// chart.ts
export const chartProps {
...
}
// volumeChart.ts
import { chartProps } from "./chart"
// AFTER AUTO-FIX
// chart.ts
export const chartProperties {
...
}
// volumeChart.ts
import { chartProps as chartProperties } from "./chart"