eslint-plugin-big-react-app-plugin 0.0.2 → 0.0.4

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,27 +1,37 @@
1
- const path = require('path');
2
1
  "use strict";
3
- export const meta = {
4
- type: null, // `problem`, `suggestion`, or `layout`
5
- docs: {
6
- description: "feature sliced relative path checker",
7
- category: "Fill me in",
8
- recommended: false,
9
- url: null, // URL to the documentation page for this rule
2
+
3
+ const path = require('path');
4
+
5
+ module.exports = {
6
+ meta: {
7
+ type: null, // `problem`, `suggestion`, or `layout`
8
+ docs: {
9
+ description: "feature sliced relative path checker",
10
+ category: "Fill me in",
11
+ recommended: false,
12
+ url: null, // URL to the documentation page for this rule
13
+ },
14
+ fixable: null, // Or `code` or `whitespace`
15
+ schema: [], // Add a schema if the rule has options
10
16
  },
11
- fixable: null, // Or `code` or `whitespace`
12
- schema: [], // Add a schema if the rule has options
13
- };
14
- export function create(context) {
15
- return {
16
- ImportDeclaration(node) {
17
- const importTo = node.source.value;
18
- const importFrom = context.getFilename();
19
- if(shouldBeRelative(importFrom, importTo)){
20
- context.report(node, "В рамках одного модуля должны использоваться относительные импорты");
17
+
18
+ create(context) {
19
+ return {
20
+ ImportDeclaration(node) {
21
+ // example app/entities/Article
22
+ const importTo = node.source.value;
23
+
24
+ // example C:\Users\tim\Desktop\javascript\production_project\src\entities\Article
25
+ const fromFilename = context.getFilename();
26
+
27
+ if(shouldBeRelative(fromFilename, importTo)) {
28
+ context.report(node, 'В рамках одного слайса все пути должны быть относительными');
29
+ }
21
30
  }
22
- }
23
- };
24
- }
31
+ };
32
+ },
33
+ };
34
+
25
35
  const layers = {
26
36
  "entities":"entities",
27
37
  "features":"features",
@@ -38,7 +48,7 @@ const shouldBeRelative = (from, to)=>{
38
48
  const toLayer = toArray[0];
39
49
  //"C:\Users\ADMIN\Documents\GitHub\ulbi\big-app-react\src\entities\Article\model\types\artcile.ts"
40
50
  const toSlice = toArray[1];
41
- if(!toLayer || !toSlice || layers[toArray]){
51
+ if(!toLayer || !toSlice || !layers[toArray]){
42
52
  return false
43
53
  }
44
54
  //нормализуем путь
@@ -47,7 +57,7 @@ const shouldBeRelative = (from, to)=>{
47
57
 
48
58
  const fromLayer = fromArray[1];
49
59
  const fromSlice = fromArray[2];
50
- if(!fromLayer || !fromSlice || layers[fromArray]){
60
+ if(!fromLayer || !fromSlice || !layers[fromArray]){
51
61
  return false
52
62
  }
53
63
  return toSlice === fromSlice && toLayer === fromLayer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-big-react-app-plugin",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "plugin for prod proj",
5
5
  "keywords": [
6
6
  "eslint",