eslint-plugin-path-checker-relative 0.0.2 → 0.0.3
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.
- package/lib/rules/path-checker.js +20 -17
- package/package.json +3 -2
|
@@ -18,19 +18,32 @@ 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: [
|
|
22
|
-
|
|
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 || '';
|
|
38
|
+
console.log('ALIAS', alias)
|
|
26
39
|
return {
|
|
27
40
|
ImportDeclaration(node) {
|
|
41
|
+
const value = node.source.value;
|
|
42
|
+
const importTo = alias ? value.replace(`${alias}/`, '') : value
|
|
28
43
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const fromFilename = context.getFilename();
|
|
44
|
+
const fromFilename = context.filename;
|
|
32
45
|
if(shouldBeRelative(fromFilename, importTo)) {
|
|
33
|
-
context.report(node, 'В рамках одного слайса все пути должны быть относительными')
|
|
46
|
+
context.report({node: node, messageId: 'В рамках одного слайса все пути должны быть относительными'})
|
|
34
47
|
}
|
|
35
48
|
}
|
|
36
49
|
};
|
|
@@ -77,14 +90,4 @@ function shouldBeRelative(from, to) {
|
|
|
77
90
|
|
|
78
91
|
return fromSlice === toSlice && toLayer === fromLayer
|
|
79
92
|
|
|
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
|
-
))
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-path-checker-relative",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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",
|