eslint-plugin-fsd-paths-check 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const isOnlyParentDirs = (importPath) => {
|
|
4
|
+
const normalized = importPath.replace(/\\/g, '/');
|
|
5
|
+
const segments = normalized.split('/').filter(s => s.length > 0);
|
|
6
|
+
return segments.every(s => s === '..');
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
meta: {
|
|
11
|
+
type: `suggestion`,
|
|
12
|
+
docs: {
|
|
13
|
+
description: "Resolve public API imports to direct relative paths within same module",
|
|
14
|
+
recommended: false,
|
|
15
|
+
url: null,
|
|
16
|
+
},
|
|
17
|
+
fixable: null,
|
|
18
|
+
schema: [],
|
|
19
|
+
messages: {
|
|
20
|
+
resolvePublicApiImport: `Use direct relative import instead of public API within the same module`,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
create(context) {
|
|
25
|
+
return {
|
|
26
|
+
ImportDeclaration(node) {
|
|
27
|
+
const importPath = node.source.value;
|
|
28
|
+
|
|
29
|
+
if (isOnlyParentDirs(importPath)) {
|
|
30
|
+
context.report({
|
|
31
|
+
node,
|
|
32
|
+
messageId: `resolvePublicApiImport`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
};
|