eslint-plugin-fsd-paths-check 0.0.11 → 0.0.13

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.
@@ -1,16 +1,17 @@
1
1
  const { isPathRelative } = require("./isPathRelative");
2
2
  const path = require("path");
3
3
 
4
- function isSameModuleImport(from, to, fsdLayers) {
4
+ function isSameModuleImport(from, to, fsdLayers, noSlicesLayers) {
5
5
  if(isPathRelative(to)) {
6
6
  return false;
7
7
  }
8
8
 
9
+ const noSliceLayersInternal = noSlicesLayers ?? {};
9
10
  const toArray = to.split('/');
10
11
  const toLayer = toArray[0];
11
12
  const toSlice = toArray[1];
12
13
 
13
- if(!toLayer || !toSlice || !fsdLayers[toLayer]) {
14
+ if(!toLayer || !fsdLayers[toLayer] || (!noSliceLayersInternal[toLayer] && !toSlice)) {
14
15
  return false;
15
16
  }
16
17
 
@@ -25,11 +26,11 @@ function isSameModuleImport(from, to, fsdLayers) {
25
26
  const fromLayer = fromArray[0];
26
27
  const fromSlice = fromArray[1];
27
28
 
28
- if(!fromLayer || !fromSlice || !fsdLayers[fromLayer]) {
29
+ if(!fromLayer || !fsdLayers[fromLayer] || (!noSliceLayersInternal[fromLayer] && !fromSlice)) {
29
30
  return false;
30
31
  }
31
32
 
32
- return fromSlice === toSlice && fromLayer === toLayer;
33
+ return fromLayer === toLayer && (noSliceLayersInternal[fromLayer] || fromSlice === toSlice);
33
34
  }
34
35
 
35
36
  module.exports = {
@@ -9,6 +9,12 @@ const fsdLayers = {
9
9
  'features': 'features',
10
10
  'widgets': 'widgets',
11
11
  'pages': 'pages',
12
+ 'app': 'app',
13
+ }
14
+
15
+ const noSlicesLayers = {
16
+ 'shared': 'shared',
17
+ 'app': 'app',
12
18
  }
13
19
 
14
20
  module.exports = {
@@ -51,7 +57,7 @@ const importExportDeclaration = (context) => (node) => {
51
57
  const pathTo = alias ? value.replace(`${alias}`, ``) : value;
52
58
  const currentFile = context.getFilename();
53
59
 
54
- if(isSameModuleImport(currentFile, pathTo, fsdLayers)) {
60
+ if(isSameModuleImport(currentFile, pathTo, fsdLayers, noSlicesLayers)) {
55
61
  context.report({
56
62
  node,
57
63
  messageId: `useRelativePathWithinSlice`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-fsd-paths-check",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Plugin to check feature sliced design paths correctness",
5
5
  "keywords": [
6
6
  "eslint",