Skip to content

Commit 10ac656

Browse files
authored
Merge pull request #1 from dword-design/renovate/lock-file-maintenance
chore(deps): lock file maintenance
2 parents 95a2fc7 + 8fe0efb commit 10ac656

File tree

4 files changed

+1294
-984
lines changed

4 files changed

+1294
-984
lines changed

src/index.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const runTest = config => () => {
2525
...config.files,
2626
})
2727
const lintingConfig = {
28-
useEslintrc: false,
2928
overrideConfig: {
29+
extends: ['plugin:@dword-design/import-alias/recommended'],
3030
parserOptions: {
31-
sourceType: 'module',
3231
ecmaVersion: 2015,
32+
sourceType: 'module',
3333
},
34-
extends: ['plugin:@dword-design/import-alias/recommended'],
3534
},
35+
useEslintrc: false,
3636
}
3737
const eslintToLint = new ESLint(lintingConfig)
3838
const eslintToFix = new ESLint({ ...lintingConfig, fix: true })
@@ -56,6 +56,10 @@ const runTest = config => () => {
5656

5757
export default {
5858
'prefer-alias': {
59+
code: endent`
60+
import foo from '../foo/bar'
61+
`,
62+
filename: P.join('sub', 'index.js'),
5963
files: {
6064
'.babelrc.json': JSON.stringify({
6165
plugins: [
@@ -66,10 +70,6 @@ export default {
6670
],
6771
}),
6872
},
69-
code: endent`
70-
import foo from '../foo/bar'
71-
`,
72-
filename: P.join('sub', 'index.js'),
7373
messages: [
7474
{
7575
message:

src/rules/prefer-alias.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ const findMatchingAlias = (sourcePath, currentFile, options) => {
2020
}
2121

2222
export default {
23-
meta: {
24-
type: 'suggestion',
25-
fixable: true,
26-
},
2723
create: context => {
2824
const currentFile = context.getFilename()
2925
const folder = P.dirname(currentFile)
@@ -32,8 +28,8 @@ export default {
3228
const manager = new OptionManager()
3329
const babelConfig = manager.init({
3430
babelrc: true,
35-
root: folder,
3631
filename: currentFile,
32+
root: folder,
3733
})
3834
const plugin = babelConfig.plugins |> find({ key: 'module-resolver' })
3935
const options = plugin.options
@@ -54,8 +50,8 @@ export default {
5450
)
5551
if (!matchingAlias) {
5652
return context.report({
57-
node,
5853
message: `Unexpected parent import '${sourcePath}'. No matching alias found to fix the issue`,
54+
node,
5955
})
6056
}
6157
const absoluteImportPath = P.resolve(folder, sourcePath)
@@ -64,29 +60,33 @@ export default {
6460
|> replace(/\\/g, '/')
6561
}`
6662
return context.report({
67-
node,
68-
message: `Unexpected parent import '${sourcePath}'. Use '${rewrittenImport}' instead`,
6963
fix: fixer =>
7064
fixer.replaceTextRange(
7165
[node.source.range[0] + 1, node.source.range[1] - 1],
7266
rewrittenImport
7367
),
68+
message: `Unexpected parent import '${sourcePath}'. Use '${rewrittenImport}' instead`,
69+
node,
7470
})
7571
}
7672
const importWithoutAlias = resolvePath(sourcePath, currentFile, options)
7773
if (!(importWithoutAlias |> isParentImport) && hasAlias) {
7874
return context.report({
79-
node,
80-
message: `Unexpected subpath import via alias '${sourcePath}'. Use '${importWithoutAlias}' instead`,
8175
fix: fixer =>
8276
fixer.replaceTextRange(
8377
[node.source.range[0] + 1, node.source.range[1] - 1],
8478
importWithoutAlias
8579
),
80+
message: `Unexpected subpath import via alias '${sourcePath}'. Use '${importWithoutAlias}' instead`,
81+
node,
8682
})
8783
}
8884
return undefined
8985
},
9086
}
9187
},
88+
meta: {
89+
fixable: true,
90+
type: 'suggestion',
91+
},
9292
}

0 commit comments

Comments
 (0)