eslint-plugin-import-path-correct 0.0.5 → 0.0.6

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