@alextheman/eslint-plugin 1.0.4 → 1.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.
package/dist/index.cjs CHANGED
@@ -20,13 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- default: () => index_default
23
+ meta: () => meta,
24
+ rules: () => rules_default
24
25
  });
25
26
  module.exports = __toCommonJS(index_exports);
26
27
 
27
28
  // package.json
28
29
  var name = "@alextheman/eslint-plugin";
29
- var version = "1.0.4";
30
+ var version = "1.0.6";
30
31
 
31
32
  // src/createRule.ts
32
33
  var import_utils = require("@typescript-eslint/utils");
@@ -43,23 +44,43 @@ var noNamespaceImports = createRule_default({
43
44
  description: "Forbid the use of import *"
44
45
  },
45
46
  messages: {
46
- message: "Import * is not allowed. Please use named imports instead."
47
+ message: 'Import * from "{{source}}" is not allowed. Please use named imports instead.'
47
48
  },
48
49
  type: "suggestion",
49
- schema: []
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
+ ]
50
65
  },
51
- defaultOptions: [],
66
+ defaultOptions: [{ allow: [""] }],
52
67
  create(context) {
68
+ var _a;
69
+ const allowableNamedImports = (_a = context.options[0]) == null ? void 0 : _a.allow;
53
70
  return {
54
71
  ImportDeclaration(node) {
55
- if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
56
- context.report({
57
- node,
58
- messageId: "message",
59
- data: {
60
- source: node.source
61
- }
62
- });
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
+ }
63
84
  }
64
85
  }
65
86
  };
@@ -78,4 +99,8 @@ var meta = {
78
99
  version,
79
100
  namespace: "alextheman"
80
101
  };
81
- var index_default = { meta, rules: rules_default };
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ meta,
105
+ rules
106
+ });
package/dist/index.d.cts CHANGED
@@ -1,14 +1,15 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
3
  declare const _default: {
4
- meta: {
5
- name: string;
6
- version: string;
7
- namespace: string;
8
- };
9
- rules: {
10
- "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
11
- };
4
+ "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [{
5
+ allow: string[];
6
+ }], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
12
7
  };
13
8
 
14
- export { _default as default };
9
+ declare const meta: {
10
+ name: string;
11
+ version: string;
12
+ namespace: string;
13
+ };
14
+
15
+ export { meta, _default as rules };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
3
  declare const _default: {
4
- meta: {
5
- name: string;
6
- version: string;
7
- namespace: string;
8
- };
9
- rules: {
10
- "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
11
- };
4
+ "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [{
5
+ allow: string[];
6
+ }], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
12
7
  };
13
8
 
14
- export { _default as default };
9
+ declare const meta: {
10
+ name: string;
11
+ version: string;
12
+ namespace: string;
13
+ };
14
+
15
+ export { meta, _default as rules };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "@alextheman/eslint-plugin";
3
- var version = "1.0.4";
3
+ var version = "1.0.6";
4
4
 
5
5
  // src/createRule.ts
6
6
  import { ESLintUtils } from "@typescript-eslint/utils";
@@ -17,23 +17,43 @@ var noNamespaceImports = createRule_default({
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
21
  },
22
22
  type: "suggestion",
23
- schema: []
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
+ ]
24
38
  },
25
- defaultOptions: [],
39
+ defaultOptions: [{ allow: [""] }],
26
40
  create(context) {
41
+ var _a;
42
+ const allowableNamedImports = (_a = context.options[0]) == null ? void 0 : _a.allow;
27
43
  return {
28
44
  ImportDeclaration(node) {
29
- if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
30
- context.report({
31
- node,
32
- messageId: "message",
33
- data: {
34
- source: node.source
35
- }
36
- });
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
+ }
37
57
  }
38
58
  }
39
59
  };
@@ -52,7 +72,7 @@ var meta = {
52
72
  version,
53
73
  namespace: "alextheman"
54
74
  };
55
- var index_default = { meta, rules: rules_default };
56
75
  export {
57
- index_default as default
76
+ meta,
77
+ rules_default as rules
58
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/eslint-plugin",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",