@sj_lk/eslint-plugin-sj-plugin 0.1.0 → 0.1.1
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 +14 -2
- package/package.json +2 -2
|
@@ -12,16 +12,28 @@ const rule = {
|
|
|
12
12
|
url: null, // URL to the documentation page for this rule
|
|
13
13
|
},
|
|
14
14
|
fixable: null, // Or `code` or `whitespace`
|
|
15
|
-
schema: [
|
|
15
|
+
schema: [
|
|
16
|
+
{
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
alias: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'alias for the rule',
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
], defaultOptions: [{alias: ''}], // Add a schema if the rule has options
|
|
16
26
|
messages: {
|
|
17
27
|
someProblem: 'В рамках одного слайса все пути должны быть относительными',
|
|
18
28
|
}, // Add messageId and message
|
|
19
29
|
},
|
|
20
30
|
|
|
21
31
|
create(context) {
|
|
32
|
+
const alias = context.options[0]?.alias || ''
|
|
22
33
|
return {
|
|
23
34
|
ImportDeclaration(node) {
|
|
24
|
-
const
|
|
35
|
+
const value = node.source.value
|
|
36
|
+
const importTo = alias ? value.replace(`${alias}/`, '') : value
|
|
25
37
|
const fromFilename = context.filename
|
|
26
38
|
|
|
27
39
|
if(shouldBeRelative(fromFilename, importTo)) {
|