eslint-plugin-path-checker-relative 0.0.9 → 0.0.10

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.
@@ -9,6 +9,9 @@ const path = require("path");
9
9
  const isPathRelative = require("../helpers");
10
10
  const micromatch = require("micromatch");
11
11
 
12
+ const PUBLIC_ERROR = "PUBLIC_ERROR";
13
+ const TESTING_PUBLIC_ERROR = "TESTING_PUBLIC_ERROR";
14
+
12
15
  /** @type {import('eslint').Rule.RuleModule} */
13
16
  module.exports = {
14
17
  meta: {
@@ -18,7 +21,7 @@ module.exports = {
18
21
  recommended: false,
19
22
  url: null, // URL to the documentation page for this rule
20
23
  },
21
- fixable: null, // Or `code` or `whitespace`
24
+ fixable: "code", // Or `code` or `whitespace`
22
25
  schema: [
23
26
  {
24
27
  type: "object",
@@ -33,9 +36,9 @@ module.exports = {
33
36
  },
34
37
  ],
35
38
  messages: {
36
- "Абсолютный импорт разрешен только из Public API (index.ts)":
39
+ PUBLIC_ERROR:
37
40
  "Абсолютный импорт разрешен только из Public API (index.ts)",
38
- "Тестовые данные необходимо импортировать из publicApi/testing.ts":
41
+ TESTING_PUBLIC_ERROR:
39
42
  "Тестовые данные необходимо импортировать из publicApi/testing.ts",
40
43
  },
41
44
  },
@@ -62,6 +65,7 @@ module.exports = {
62
65
  const segment = importTo.split("/");
63
66
 
64
67
  const layer = segment[0];
68
+ const slice = segment[1];
65
69
 
66
70
  if (!checkingLayers[layer]) {
67
71
  return;
@@ -75,8 +79,10 @@ module.exports = {
75
79
  if (isImportNotFromPublicApi && !isTestingPublicApi) {
76
80
  context.report({
77
81
  node,
78
- messageId:
79
- "Абсолютный импорт разрешен только из Public API (index.ts)",
82
+ messageId: PUBLIC_ERROR,
83
+ fix: (fixer) => {
84
+ return fixer.replaceText(node.source, `'${alias}/${layer}/${slice}'`)
85
+ }
80
86
  });
81
87
  }
82
88
 
@@ -90,8 +96,7 @@ module.exports = {
90
96
  if (!isCurrentFileTesting) {
91
97
  context.report({
92
98
  node,
93
- messageId:
94
- "Тестовые данные необходимо импортировать из publicApi/testing.ts",
99
+ messageId: TESTING_PUBLIC_ERROR,
95
100
  });
96
101
  }
97
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-path-checker-relative",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "plugin for production project",
5
5
  "keywords": [
6
6
  "eslint",