eslint-plugin-path-checker-relative 0.0.2 → 0.0.4

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.
@@ -18,19 +18,31 @@ module.exports = {
18
18
  url: null, // URL to the documentation page for this rule
19
19
  },
20
20
  fixable: null, // Or `code` or `whitespace`
21
- schema: [], // Add a schema if the rule has options
22
- messages: {}, // Add messageId and message
21
+ schema: [
22
+ {
23
+ type: 'object',
24
+ properties: {
25
+ alias: {
26
+ type: 'string'
27
+ }
28
+ }
29
+ }
30
+ ], // Add a schema if the rule has options
31
+ messages: {
32
+ 'В рамках одного слайса все пути должны быть относительными': 'В рамках одного слайса все пути должны быть относительными'
33
+ },
23
34
  },
24
35
 
25
36
  create(context) {
37
+ const alias = context.options[0]?.alias || '';
26
38
  return {
27
39
  ImportDeclaration(node) {
40
+ const value = node.source.value;
41
+ const importTo = alias ? value.replace(`${alias}/`, '') : value
28
42
 
29
- const importTo = node.source.value;
30
-
31
- const fromFilename = context.getFilename();
43
+ const fromFilename = context.filename;
32
44
  if(shouldBeRelative(fromFilename, importTo)) {
33
- context.report(node, 'В рамках одного слайса все пути должны быть относительными')
45
+ context.report({node: node, messageId: 'В рамках одного слайса все пути должны быть относительными'})
34
46
  }
35
47
  }
36
48
  };
@@ -77,14 +89,4 @@ function shouldBeRelative(from, to) {
77
89
 
78
90
  return fromSlice === toSlice && toLayer === fromLayer
79
91
 
80
- }
81
-
82
- console.log(shouldBeRelative(
83
- '/Users/shichkov.e.g/develop/AdvancedReact/src/entities/Article',
84
- 'entities/Article/fsfssfssffsfsf'
85
- ))
86
-
87
- console.log(shouldBeRelative(
88
- '/Users/shichkov.e.g/develop/AdvancedReact/src/entities/Article',
89
- 'entities/werwerw/fsfssfssffsfsf'
90
- ))
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-path-checker-relative",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "plugin for production project",
5
5
  "keywords": [
6
6
  "eslint",
@@ -24,8 +24,9 @@
24
24
  "requireindex": "^1.2.0"
25
25
  },
26
26
  "devDependencies": {
27
- "eslint": "^9.0.0",
28
27
  "@eslint/js": "^9.0.0",
28
+ "@typescript-eslint/parser": "^8.51.0",
29
+ "eslint": "^9.0.0",
29
30
  "eslint-doc-generator": "^2.0.0",
30
31
  "eslint-plugin-eslint-plugin": "^6.0.0",
31
32
  "eslint-plugin-n": "^17.0.0",