eslint-plugin-gapone-plugin 0.3.14 → 0.3.15

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.
@@ -1,6 +1,9 @@
1
1
  const { isPathRelative } = require('../helpers');
2
2
  const micromatch = require('micromatch');
3
3
 
4
+ const PUBLIC_ERROR = 'PUBLIC_ERROR';
5
+ const TESTING_PUBLIC_ERROR = 'TESTING_PUBLIC_ERROR';
6
+
4
7
  /** @type {import('eslint').Rule.RuleModule} */
5
8
  module.exports = {
6
9
  meta: {
@@ -10,7 +13,7 @@ module.exports = {
10
13
  recommended: false,
11
14
  url: null, // URL to the documentation page for this rule
12
15
  },
13
- fixable: null, // Or `code` or `whitespace`
16
+ fixable: 'code', // Or `code` or `whitespace`
14
17
  schema: [
15
18
  {
16
19
  type: 'object',
@@ -25,9 +28,9 @@ module.exports = {
25
28
  },
26
29
  ], // Add a schema if the rule has options
27
30
  messages: {
28
- noPublicApiImports:
31
+ [PUBLIC_ERROR]:
29
32
  'Абсолютный импорт разрешен только из Public Api (index.ts)',
30
- noTestingPublicApiImports:
33
+ [TESTING_PUBLIC_ERROR]:
31
34
  'Тестовые данные необходимо импортировать из Public Api (testing.ts)',
32
35
  }, // Add messageId and message
33
36
  },
@@ -53,8 +56,8 @@ module.exports = {
53
56
 
54
57
  // [entities, article, model, types]
55
58
  const segments = importTo.split('/');
56
-
57
59
  const layer = segments[0];
60
+ const slice = segments[1];
58
61
 
59
62
  if (!checkingLayers[layer]) {
60
63
  return;
@@ -69,7 +72,13 @@ module.exports = {
69
72
  if (isImportNotFromPublickApi && !isTestingPublickApi) {
70
73
  context.report({
71
74
  node,
72
- messageId: 'noPublicApiImports',
75
+ messageId: PUBLIC_ERROR,
76
+ fix: (fixer) => {
77
+ return fixer.replaceText(
78
+ node.source,
79
+ `'${alias}/${layer}/${slice}'`
80
+ );
81
+ },
73
82
  });
74
83
  }
75
84
 
@@ -84,7 +93,7 @@ module.exports = {
84
93
  if (!isCurrentFileTesting) {
85
94
  context.report({
86
95
  node,
87
- messageId: 'noTestingPublicApiImports',
96
+ messageId: TESTING_PUBLIC_ERROR,
88
97
  });
89
98
  }
90
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-gapone-plugin",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "description": "plugin for production project",
5
5
  "keywords": [
6
6
  "eslint",