@alextheman/eslint-plugin 1.8.2 → 1.9.0
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 +62 -34
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +62 -34
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3706,7 +3706,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
3706
3706
|
|
|
3707
3707
|
// package.json
|
|
3708
3708
|
var name = "@alextheman/eslint-plugin";
|
|
3709
|
-
var version = "1.
|
|
3709
|
+
var version = "1.9.0";
|
|
3710
3710
|
|
|
3711
3711
|
// src/configs/alexPluginBase.ts
|
|
3712
3712
|
function createAlexPluginBaseConfig(plugin2) {
|
|
@@ -3982,61 +3982,89 @@ var noPluginConfigAccessFromSrcConfigs = create_rule_default({
|
|
|
3982
3982
|
var no_plugin_configs_access_from_src_configs_default = noPluginConfigAccessFromSrcConfigs;
|
|
3983
3983
|
|
|
3984
3984
|
// src/rules/no-relative-imports.ts
|
|
3985
|
-
var import_path = __toESM(require("path"), 1);
|
|
3986
3985
|
var noRelativeImports = create_rule_default({
|
|
3987
3986
|
name: "no-relative-imports",
|
|
3988
3987
|
meta: {
|
|
3989
3988
|
docs: { description: "Forbid the use of relative imports" },
|
|
3990
3989
|
messages: {
|
|
3991
3990
|
message: 'Relative import from "{{source}}" is not allowed.',
|
|
3992
|
-
stupidPath:
|
|
3991
|
+
stupidPath: "For the love of God, please do not mix relative path parts in your import statements like that! How can you possibly be ok with {{source}}?!"
|
|
3993
3992
|
},
|
|
3994
3993
|
type: "suggestion",
|
|
3995
|
-
|
|
3996
|
-
|
|
3994
|
+
schema: [
|
|
3995
|
+
{
|
|
3996
|
+
type: "object",
|
|
3997
|
+
properties: {
|
|
3998
|
+
depth: {
|
|
3999
|
+
type: "number"
|
|
4000
|
+
}
|
|
4001
|
+
},
|
|
4002
|
+
additionalProperties: false
|
|
4003
|
+
}
|
|
4004
|
+
]
|
|
3997
4005
|
},
|
|
3998
|
-
defaultOptions: [],
|
|
4006
|
+
defaultOptions: [{ depth: void 0 }],
|
|
3999
4007
|
create(context) {
|
|
4008
|
+
var _a;
|
|
4009
|
+
const depth = (_a = context.options[0]) == null ? void 0 : _a.depth;
|
|
4010
|
+
if (depth !== void 0) {
|
|
4011
|
+
if (depth % 1 !== 0) {
|
|
4012
|
+
throw new Error("NON_INTEGER_DEPTH_NOT_ALLOWED");
|
|
4013
|
+
}
|
|
4014
|
+
if (depth < 0) {
|
|
4015
|
+
throw new Error("NEGATIVE_DEPTH_NOT_ALLOWED");
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4000
4018
|
return {
|
|
4001
4019
|
ImportDeclaration(node) {
|
|
4002
4020
|
if (node.source.value.includes("./") || node.source.value.includes("../")) {
|
|
4003
|
-
if (
|
|
4004
|
-
context.report({
|
|
4021
|
+
if (depth === void 0) {
|
|
4022
|
+
return context.report({
|
|
4005
4023
|
node,
|
|
4006
|
-
messageId: "
|
|
4024
|
+
messageId: "message",
|
|
4007
4025
|
data: {
|
|
4008
4026
|
source: node.source.value
|
|
4009
4027
|
}
|
|
4010
4028
|
});
|
|
4011
|
-
return null;
|
|
4012
4029
|
}
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
if (!context.parserOptions.tsconfigRootDir) {
|
|
4021
|
-
return null;
|
|
4030
|
+
const importPathParts = node.source.value.split("/");
|
|
4031
|
+
if (importPathParts.includes(".") && importPathParts.includes("..")) {
|
|
4032
|
+
return context.report({
|
|
4033
|
+
node,
|
|
4034
|
+
messageId: "stupidPath",
|
|
4035
|
+
data: {
|
|
4036
|
+
source: node.source.value
|
|
4022
4037
|
}
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
if (projectRelativePath.startsWith("..")) {
|
|
4032
|
-
return null;
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
if (importPathParts.includes(".") && importPathParts[0] !== "." || importPathParts.includes("..") && importPathParts[0] !== "..") {
|
|
4041
|
+
return context.report({
|
|
4042
|
+
node,
|
|
4043
|
+
messageId: "stupidPath",
|
|
4044
|
+
data: {
|
|
4045
|
+
source: node.source.value
|
|
4033
4046
|
}
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4047
|
+
});
|
|
4048
|
+
}
|
|
4049
|
+
if (depth === 0 && importPathParts[0] === ".") {
|
|
4050
|
+
return;
|
|
4051
|
+
}
|
|
4052
|
+
let endOfRelativePathFound = false;
|
|
4053
|
+
for (const part of importPathParts.slice(0, depth + 1)) {
|
|
4054
|
+
if (part !== "..") {
|
|
4055
|
+
endOfRelativePathFound = true;
|
|
4056
|
+
break;
|
|
4038
4057
|
}
|
|
4039
|
-
}
|
|
4058
|
+
}
|
|
4059
|
+
if (!endOfRelativePathFound) {
|
|
4060
|
+
return context.report({
|
|
4061
|
+
node,
|
|
4062
|
+
messageId: "message",
|
|
4063
|
+
data: {
|
|
4064
|
+
source: node.source.value
|
|
4065
|
+
}
|
|
4066
|
+
});
|
|
4067
|
+
}
|
|
4040
4068
|
}
|
|
4041
4069
|
}
|
|
4042
4070
|
};
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3692,7 +3692,7 @@ var require_globals2 = __commonJS({
|
|
|
3692
3692
|
|
|
3693
3693
|
// package.json
|
|
3694
3694
|
var name = "@alextheman/eslint-plugin";
|
|
3695
|
-
var version = "1.
|
|
3695
|
+
var version = "1.9.0";
|
|
3696
3696
|
|
|
3697
3697
|
// src/configs/alexPluginBase.ts
|
|
3698
3698
|
function createAlexPluginBaseConfig(plugin2) {
|
|
@@ -3968,61 +3968,89 @@ var noPluginConfigAccessFromSrcConfigs = create_rule_default({
|
|
|
3968
3968
|
var no_plugin_configs_access_from_src_configs_default = noPluginConfigAccessFromSrcConfigs;
|
|
3969
3969
|
|
|
3970
3970
|
// src/rules/no-relative-imports.ts
|
|
3971
|
-
import path from "path";
|
|
3972
3971
|
var noRelativeImports = create_rule_default({
|
|
3973
3972
|
name: "no-relative-imports",
|
|
3974
3973
|
meta: {
|
|
3975
3974
|
docs: { description: "Forbid the use of relative imports" },
|
|
3976
3975
|
messages: {
|
|
3977
3976
|
message: 'Relative import from "{{source}}" is not allowed.',
|
|
3978
|
-
stupidPath:
|
|
3977
|
+
stupidPath: "For the love of God, please do not mix relative path parts in your import statements like that! How can you possibly be ok with {{source}}?!"
|
|
3979
3978
|
},
|
|
3980
3979
|
type: "suggestion",
|
|
3981
|
-
|
|
3982
|
-
|
|
3980
|
+
schema: [
|
|
3981
|
+
{
|
|
3982
|
+
type: "object",
|
|
3983
|
+
properties: {
|
|
3984
|
+
depth: {
|
|
3985
|
+
type: "number"
|
|
3986
|
+
}
|
|
3987
|
+
},
|
|
3988
|
+
additionalProperties: false
|
|
3989
|
+
}
|
|
3990
|
+
]
|
|
3983
3991
|
},
|
|
3984
|
-
defaultOptions: [],
|
|
3992
|
+
defaultOptions: [{ depth: void 0 }],
|
|
3985
3993
|
create(context) {
|
|
3994
|
+
var _a;
|
|
3995
|
+
const depth = (_a = context.options[0]) == null ? void 0 : _a.depth;
|
|
3996
|
+
if (depth !== void 0) {
|
|
3997
|
+
if (depth % 1 !== 0) {
|
|
3998
|
+
throw new Error("NON_INTEGER_DEPTH_NOT_ALLOWED");
|
|
3999
|
+
}
|
|
4000
|
+
if (depth < 0) {
|
|
4001
|
+
throw new Error("NEGATIVE_DEPTH_NOT_ALLOWED");
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
3986
4004
|
return {
|
|
3987
4005
|
ImportDeclaration(node) {
|
|
3988
4006
|
if (node.source.value.includes("./") || node.source.value.includes("../")) {
|
|
3989
|
-
if (
|
|
3990
|
-
context.report({
|
|
4007
|
+
if (depth === void 0) {
|
|
4008
|
+
return context.report({
|
|
3991
4009
|
node,
|
|
3992
|
-
messageId: "
|
|
4010
|
+
messageId: "message",
|
|
3993
4011
|
data: {
|
|
3994
4012
|
source: node.source.value
|
|
3995
4013
|
}
|
|
3996
4014
|
});
|
|
3997
|
-
return null;
|
|
3998
4015
|
}
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
if (!context.parserOptions.tsconfigRootDir) {
|
|
4007
|
-
return null;
|
|
4016
|
+
const importPathParts = node.source.value.split("/");
|
|
4017
|
+
if (importPathParts.includes(".") && importPathParts.includes("..")) {
|
|
4018
|
+
return context.report({
|
|
4019
|
+
node,
|
|
4020
|
+
messageId: "stupidPath",
|
|
4021
|
+
data: {
|
|
4022
|
+
source: node.source.value
|
|
4008
4023
|
}
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
if (projectRelativePath.startsWith("..")) {
|
|
4018
|
-
return null;
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
if (importPathParts.includes(".") && importPathParts[0] !== "." || importPathParts.includes("..") && importPathParts[0] !== "..") {
|
|
4027
|
+
return context.report({
|
|
4028
|
+
node,
|
|
4029
|
+
messageId: "stupidPath",
|
|
4030
|
+
data: {
|
|
4031
|
+
source: node.source.value
|
|
4019
4032
|
}
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4033
|
+
});
|
|
4034
|
+
}
|
|
4035
|
+
if (depth === 0 && importPathParts[0] === ".") {
|
|
4036
|
+
return;
|
|
4037
|
+
}
|
|
4038
|
+
let endOfRelativePathFound = false;
|
|
4039
|
+
for (const part of importPathParts.slice(0, depth + 1)) {
|
|
4040
|
+
if (part !== "..") {
|
|
4041
|
+
endOfRelativePathFound = true;
|
|
4042
|
+
break;
|
|
4024
4043
|
}
|
|
4025
|
-
}
|
|
4044
|
+
}
|
|
4045
|
+
if (!endOfRelativePathFound) {
|
|
4046
|
+
return context.report({
|
|
4047
|
+
node,
|
|
4048
|
+
messageId: "message",
|
|
4049
|
+
data: {
|
|
4050
|
+
source: node.source.value
|
|
4051
|
+
}
|
|
4052
|
+
});
|
|
4053
|
+
}
|
|
4026
4054
|
}
|
|
4027
4055
|
}
|
|
4028
4056
|
};
|