@alextheman/eslint-plugin 1.0.5 → 1.0.7

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.
package/dist/index.cjs CHANGED
@@ -27,24 +27,74 @@ module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // package.json
29
29
  var name = "@alextheman/eslint-plugin";
30
- var version = "1.0.5";
30
+ var version = "1.0.7";
31
31
 
32
- // src/createRule.ts
32
+ // create-rule.ts
33
33
  var import_utils = require("@typescript-eslint/utils");
34
34
  var createRule = import_utils.ESLintUtils.RuleCreator((ruleName) => {
35
35
  return `https://github.com/AlexMan123456/eslint-plugin/${ruleName}`;
36
36
  });
37
- var createRule_default = createRule;
37
+ var create_rule_default = createRule;
38
38
 
39
39
  // src/rules/no-namespace-imports.ts
40
- var noNamespaceImports = createRule_default({
40
+ var noNamespaceImports = create_rule_default({
41
41
  name: "no-namespace-imports",
42
42
  meta: {
43
43
  docs: {
44
44
  description: "Forbid the use of import *"
45
45
  },
46
46
  messages: {
47
- message: "Import * is not allowed. Please use named imports instead."
47
+ message: 'Import * from "{{source}}" is not allowed. Please use named imports instead.'
48
+ },
49
+ type: "suggestion",
50
+ schema: [
51
+ {
52
+ type: "object",
53
+ properties: {
54
+ allow: {
55
+ type: "array",
56
+ items: {
57
+ type: "string"
58
+ },
59
+ uniqueItems: true
60
+ }
61
+ },
62
+ additionalProperties: false
63
+ }
64
+ ]
65
+ },
66
+ defaultOptions: [{ allow: [""] }],
67
+ create(context) {
68
+ var _a;
69
+ const allowableNamedImports = (_a = context.options[0]) == null ? void 0 : _a.allow;
70
+ return {
71
+ ImportDeclaration(node) {
72
+ const allSpecifiers = node.specifiers;
73
+ for (const specifier of allSpecifiers) {
74
+ if (specifier.type === "ImportNamespaceSpecifier" && !(allowableNamedImports == null ? void 0 : allowableNamedImports.includes(node.source.value))) {
75
+ context.report({
76
+ node,
77
+ messageId: "message",
78
+ data: {
79
+ source: node.source.value
80
+ }
81
+ });
82
+ return;
83
+ }
84
+ }
85
+ }
86
+ };
87
+ }
88
+ });
89
+ var no_namespace_imports_default = noNamespaceImports;
90
+
91
+ // src/rules/no-relative-imports.ts
92
+ var noRelativeImports = create_rule_default({
93
+ name: "",
94
+ meta: {
95
+ docs: { description: "Forbid the use of relative imports" },
96
+ messages: {
97
+ message: "Relative import from '{{source}}' is not allowed."
48
98
  },
49
99
  type: "suggestion",
50
100
  schema: []
@@ -53,12 +103,12 @@ var noNamespaceImports = createRule_default({
53
103
  create(context) {
54
104
  return {
55
105
  ImportDeclaration(node) {
56
- if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
106
+ if (node.source.value.includes("./") || node.source.value.includes("../")) {
57
107
  context.report({
58
108
  node,
59
109
  messageId: "message",
60
110
  data: {
61
- source: node.source
111
+ source: node.source.value
62
112
  }
63
113
  });
64
114
  }
@@ -66,11 +116,12 @@ var noNamespaceImports = createRule_default({
66
116
  };
67
117
  }
68
118
  });
69
- var no_namespace_imports_default = noNamespaceImports;
119
+ var no_relative_imports_default = noRelativeImports;
70
120
 
71
121
  // src/rules/index.ts
72
122
  var rules_default = {
73
- "no-namespace-imports": no_namespace_imports_default
123
+ "no-namespace-imports": no_namespace_imports_default,
124
+ "no-relative-imports": no_relative_imports_default
74
125
  };
75
126
 
76
127
  // src/index.ts
package/dist/index.d.cts CHANGED
@@ -1,7 +1,10 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
3
  declare const _default: {
4
- "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
4
+ "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [{
5
+ allow: string[];
6
+ }], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
7
+ "no-relative-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
5
8
  };
6
9
 
7
10
  declare const meta: {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
3
  declare const _default: {
4
- "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
4
+ "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [{
5
+ allow: string[];
6
+ }], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
7
+ "no-relative-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
5
8
  };
6
9
 
7
10
  declare const meta: {
package/dist/index.js CHANGED
@@ -1,23 +1,73 @@
1
1
  // package.json
2
2
  var name = "@alextheman/eslint-plugin";
3
- var version = "1.0.5";
3
+ var version = "1.0.7";
4
4
 
5
- // src/createRule.ts
5
+ // create-rule.ts
6
6
  import { ESLintUtils } from "@typescript-eslint/utils";
7
7
  var createRule = ESLintUtils.RuleCreator((ruleName) => {
8
8
  return `https://github.com/AlexMan123456/eslint-plugin/${ruleName}`;
9
9
  });
10
- var createRule_default = createRule;
10
+ var create_rule_default = createRule;
11
11
 
12
12
  // src/rules/no-namespace-imports.ts
13
- var noNamespaceImports = createRule_default({
13
+ var noNamespaceImports = create_rule_default({
14
14
  name: "no-namespace-imports",
15
15
  meta: {
16
16
  docs: {
17
17
  description: "Forbid the use of import *"
18
18
  },
19
19
  messages: {
20
- message: "Import * is not allowed. Please use named imports instead."
20
+ message: 'Import * from "{{source}}" is not allowed. Please use named imports instead.'
21
+ },
22
+ type: "suggestion",
23
+ schema: [
24
+ {
25
+ type: "object",
26
+ properties: {
27
+ allow: {
28
+ type: "array",
29
+ items: {
30
+ type: "string"
31
+ },
32
+ uniqueItems: true
33
+ }
34
+ },
35
+ additionalProperties: false
36
+ }
37
+ ]
38
+ },
39
+ defaultOptions: [{ allow: [""] }],
40
+ create(context) {
41
+ var _a;
42
+ const allowableNamedImports = (_a = context.options[0]) == null ? void 0 : _a.allow;
43
+ return {
44
+ ImportDeclaration(node) {
45
+ const allSpecifiers = node.specifiers;
46
+ for (const specifier of allSpecifiers) {
47
+ if (specifier.type === "ImportNamespaceSpecifier" && !(allowableNamedImports == null ? void 0 : allowableNamedImports.includes(node.source.value))) {
48
+ context.report({
49
+ node,
50
+ messageId: "message",
51
+ data: {
52
+ source: node.source.value
53
+ }
54
+ });
55
+ return;
56
+ }
57
+ }
58
+ }
59
+ };
60
+ }
61
+ });
62
+ var no_namespace_imports_default = noNamespaceImports;
63
+
64
+ // src/rules/no-relative-imports.ts
65
+ var noRelativeImports = create_rule_default({
66
+ name: "",
67
+ meta: {
68
+ docs: { description: "Forbid the use of relative imports" },
69
+ messages: {
70
+ message: "Relative import from '{{source}}' is not allowed."
21
71
  },
22
72
  type: "suggestion",
23
73
  schema: []
@@ -26,12 +76,12 @@ var noNamespaceImports = createRule_default({
26
76
  create(context) {
27
77
  return {
28
78
  ImportDeclaration(node) {
29
- if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
79
+ if (node.source.value.includes("./") || node.source.value.includes("../")) {
30
80
  context.report({
31
81
  node,
32
82
  messageId: "message",
33
83
  data: {
34
- source: node.source
84
+ source: node.source.value
35
85
  }
36
86
  });
37
87
  }
@@ -39,11 +89,12 @@ var noNamespaceImports = createRule_default({
39
89
  };
40
90
  }
41
91
  });
42
- var no_namespace_imports_default = noNamespaceImports;
92
+ var no_relative_imports_default = noRelativeImports;
43
93
 
44
94
  // src/rules/index.ts
45
95
  var rules_default = {
46
- "no-namespace-imports": no_namespace_imports_default
96
+ "no-namespace-imports": no_namespace_imports_default,
97
+ "no-relative-imports": no_relative_imports_default
47
98
  };
48
99
 
49
100
  // src/index.ts
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@alextheman/eslint-plugin",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "files": ["dist"],
7
+ "files": [
8
+ "dist"
9
+ ],
8
10
  "scripts": {
9
11
  "test": "jest",
10
12
  "format": "prettier --write --parser typescript 'src/**/*.ts' '__tests__/**/*.ts' && ESLINT_MODE=fix eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",