eslint-plugin-big-react-app-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.
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ const {isPathRelative} = require("../helpers")
3
+ module.exports = {
4
+ meta: {
5
+ type: null,
6
+ docs: {
7
+ description: "description",
8
+ category: "Fill me in",
9
+ recommended: false,
10
+ url: null,
11
+ },
12
+ fixable: null,
13
+ schema: [
14
+ {
15
+ type:"object",
16
+ properties:
17
+ {
18
+ alias:{
19
+ type: 'string'
20
+ }
21
+ }
22
+ }
23
+ ],
24
+ },
25
+
26
+
27
+ create(context) {
28
+ const checkingLayers = {
29
+ "entities":"entities",
30
+ "features":"features",
31
+ "pages":"pages",
32
+ "widgets":"widgets",
33
+ }
34
+ const alias = context.options[0]?.alias ?? "";
35
+ return {
36
+ ImportDeclaration(node) {
37
+ // example app/entities/Article
38
+ const value = node.source.value;
39
+ const importTo = alias ? value.replace(`${alias}/`, "") : value;
40
+ if(isPathRelative(importTo)){
41
+ return;
42
+ }
43
+ //[enteties, article, ... далее еще что-то может быть]
44
+ const segments = importTo.split('/')
45
+ const layer = segments[0]//получаем слой
46
+ if(!checkingLayers[layer]){
47
+ return;
48
+ }
49
+
50
+ const isImportNotFromPublicApi = segments.lenght > 2;
51
+
52
+ if(isImportNotFromPublicApi) {
53
+ context.report({node: node, message: 'Абсолютный импорт разрешен только из Public Api(index.ts)'});
54
+ }
55
+ }
56
+ };
57
+ },
58
+ };
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "eslint-plugin-big-react-app-plugin",
3
+ "version": "0.1.1",
4
+ "description": "plugin for prod proj",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslintplugin",
8
+ "eslint-plugin"
9
+ ],
10
+ "author": "Vasilii",
11
+ "main": "lib/index.js",
12
+ "scripts": {
13
+ "lint": "eslint .",
14
+ "test": "mocha tests --recursive"
15
+ },
16
+ "dependencies": {
17
+ "requireindex": "^1.2.0"
18
+ },
19
+ "devDependencies": {
20
+ "eslint": "^8.0.1",
21
+ "eslint-plugin-eslint-plugin": "^4.0.1",
22
+ "eslint-plugin-node": "^11.1.0",
23
+ "mocha": "^9.1.3"
24
+ },
25
+ "engines": {
26
+ "node": "12.x || 14.x || >= 16"
27
+ },
28
+ "peerDependencies": {
29
+ "eslint": ">=6"
30
+ },
31
+ "license": "ISC"
32
+ }
@@ -10,7 +10,17 @@ module.exports = {
10
10
  url: null,
11
11
  },
12
12
  fixable: null,
13
- schema: [],
13
+ schema: [
14
+ {
15
+ type:"object",
16
+ properties:
17
+ {
18
+ alias:{
19
+ type: 'string'
20
+ }
21
+ }
22
+ }
23
+ ],
14
24
  },
15
25
 
16
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-big-react-app-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "plugin for prod proj",
5
5
  "keywords": [
6
6
  "eslint",