eslint-plugin-laygrd-plugin 0.0.8 → 0.0.9

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.
@@ -4,7 +4,16 @@ const isPathRelative = (p) => {
4
4
 
5
5
  const normalizePathSeparators = (filename) => filename.replace(/\\/g, '/');
6
6
 
7
+ const getCurrentFileSegments = (filePath) => {
8
+ const normalizedPath = filePath.replace(/[\\]+/g, "/")
9
+ const projectPath = normalizedPath?.split('src')[1]
10
+ const segments = projectPath?.split('/')
11
+
12
+ return segments;
13
+ }
14
+
7
15
  module.exports = {
8
16
  isPathRelative,
9
17
  normalizePathSeparators,
18
+ getCurrentFileSegments,
10
19
  };
@@ -4,7 +4,7 @@
4
4
  */
5
5
  "use strict";
6
6
 
7
- const { isPathRelative, normalizePathSeparators } = require('../helpers');
7
+ const { isPathRelative, getCurrentFileSegments } = require('../helpers');
8
8
 
9
9
  //------------------------------------------------------------------------------
10
10
  // Rule Definition
@@ -78,10 +78,10 @@ const shouldPathBeRelative = (curFile, impSrc) => {
78
78
  return false;
79
79
  }
80
80
 
81
- const normalizedPath = curFile.split('src')[1]; // 'C:\Users\rosti\Desktop\projects\blog-app\src\entities\Article\ui\ArticleList' -> \entities\Article\ui\ArticleList
82
- const projectFileArray = normalizePathSeparators(normalizedPath).split('/'); // \entities\Article\ui\ArticleList -> [ '', 'entities', 'Article', 'ui', 'ArticleList' ]
83
- const curFileLayer = projectFileArray[1]; // entities
84
- const curFileSlice = projectFileArray[2]; // Article
81
+ const segments = getCurrentFileSegments(curFile) // 'C:\Users\rosti\Desktop\projects\blog-app\src\entities\Article\ui\ArticleList' -> \entities\Article\ui\ArticleList
82
+ // \entities\Article\ui\ArticleList -> [ '', 'entities', 'Article', 'ui', 'ArticleList' ]
83
+ const curFileLayer = segments[1]; // entities
84
+ const curFileSlice = segments[2]; // Article
85
85
 
86
86
  if ( !curFileLayer || !curFileSlice || !layers[curFileLayer] ) {
87
87
  return false;
@@ -9,7 +9,7 @@
9
9
  //------------------------------------------------------------------------------
10
10
 
11
11
  const micromatch = require('micromatch');
12
- const { isPathRelative, normalizePathSeparators } = require('../helpers');
12
+ const { isPathRelative, getCurrentFileSegments } = require('../helpers');
13
13
 
14
14
  /** @type {import('eslint').Rule.RuleModule} */
15
15
  module.exports = {
@@ -61,10 +61,7 @@ module.exports = {
61
61
 
62
62
  const getCurrentFileLayer = () => {
63
63
  const currentFilePath = context.getFilename();
64
-
65
- const normalizedPath = normalizePathSeparators(currentFilePath);
66
- const projectPath = normalizedPath?.split('src')[1];
67
- const segments = projectPath.split('/');
64
+ const segments = getCurrentFileSegments(currentFilePath)
68
65
 
69
66
  return segments[1];
70
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-laygrd-plugin",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "some usefull fsd rule-checkers",
5
5
  "keywords": [
6
6
  "eslint",