Skip to content

Commit 6f05f08

Browse files
committed
refactor: create a function to remove a let declaration
1 parent c73732d commit 6f05f08

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/rules/prefer-alias.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ const findMatchingAlias = (sourcePath, currentFile, options) => {
2727
return undefined
2828
}
2929

30+
const getImportType = importWithoutAlias => {
31+
if (importWithoutAlias |> isSiblingImport) {
32+
return 'sibling'
33+
}
34+
if (importWithoutAlias |> isSubpathImport) {
35+
return 'subpath'
36+
}
37+
38+
return 'parent'
39+
}
40+
3041
export default {
3142
create: context => {
3243
const currentFile = context.getFilename()
@@ -89,14 +100,8 @@ export default {
89100
P.relative(matchingAlias.path, absoluteImportPath)
90101
|> replace(/\\/g, '/')
91102
}`
92-
let importType
93-
if (importWithoutAlias |> isSiblingImport) {
94-
importType = 'sibling'
95-
} else if (importWithoutAlias |> isSubpathImport) {
96-
importType = 'subpath'
97-
} else {
98-
importType = 'parent'
99-
}
103+
104+
const importType = getImportType(importWithoutAlias)
100105

101106
return context.report({
102107
fix: fixer =>

0 commit comments

Comments
 (0)