@alextheman/eslint-plugin 1.0.5 → 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 +32 -12
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +32 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
27
27
|
|
|
28
28
|
// package.json
|
|
29
29
|
var name = "@alextheman/eslint-plugin";
|
|
30
|
-
var version = "1.0.
|
|
30
|
+
var version = "1.0.6";
|
|
31
31
|
|
|
32
32
|
// src/createRule.ts
|
|
33
33
|
var import_utils = require("@typescript-eslint/utils");
|
|
@@ -44,23 +44,43 @@ var noNamespaceImports = createRule_default({
|
|
|
44
44
|
description: "Forbid the use of import *"
|
|
45
45
|
},
|
|
46
46
|
messages: {
|
|
47
|
-
message:
|
|
47
|
+
message: 'Import * from "{{source}}" is not allowed. Please use named imports instead.'
|
|
48
48
|
},
|
|
49
49
|
type: "suggestion",
|
|
50
|
-
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
|
+
]
|
|
51
65
|
},
|
|
52
|
-
defaultOptions: [],
|
|
66
|
+
defaultOptions: [{ allow: [""] }],
|
|
53
67
|
create(context) {
|
|
68
|
+
var _a;
|
|
69
|
+
const allowableNamedImports = (_a = context.options[0]) == null ? void 0 : _a.allow;
|
|
54
70
|
return {
|
|
55
71
|
ImportDeclaration(node) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
}
|
|
64
84
|
}
|
|
65
85
|
}
|
|
66
86
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
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", [
|
|
4
|
+
"no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [{
|
|
5
|
+
allow: string[];
|
|
6
|
+
}], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
5
7
|
};
|
|
6
8
|
|
|
7
9
|
declare const meta: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
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", [
|
|
4
|
+
"no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [{
|
|
5
|
+
allow: string[];
|
|
6
|
+
}], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
5
7
|
};
|
|
6
8
|
|
|
7
9
|
declare const meta: {
|
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.
|
|
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:
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
};
|