@alextheman/eslint-plugin 1.8.1 → 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 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.8.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: 'Who the hell imports from "{{source}}"?! Know your own project directory, Goddamnit!'
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
- fixable: "code",
3996
- schema: []
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 (!node.source.value.startsWith("./") && !node.source.value.startsWith("../")) {
4004
- context.report({
4021
+ if (depth === void 0) {
4022
+ return context.report({
4005
4023
  node,
4006
- messageId: "stupidPath",
4024
+ messageId: "message",
4007
4025
  data: {
4008
4026
  source: node.source.value
4009
4027
  }
4010
4028
  });
4011
- return null;
4012
4029
  }
4013
- context.report({
4014
- node,
4015
- messageId: "message",
4016
- data: {
4017
- source: node.source.value
4018
- },
4019
- fix(fixer) {
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
- const fullImportPath = import_path.default.resolve(
4024
- import_path.default.dirname(context.physicalFilename),
4025
- node.source.value
4026
- );
4027
- const projectRelativePath = import_path.default.relative(
4028
- context.parserOptions.tsconfigRootDir,
4029
- fullImportPath
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
- return fixer.replaceText(
4035
- node.source,
4036
- `${node.source.raw[0]}${import_path.default.posix.normalize(projectRelativePath)}${node.source.raw[0]}`
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
@@ -2,7 +2,7 @@ import { Linter } from 'eslint';
2
2
  import { Config } from 'prettier';
3
3
 
4
4
  var name = "@alextheman/eslint-plugin";
5
- var version = "1.8.1";
5
+ var version = "1.9.0";
6
6
 
7
7
  declare const prettierRules: Config;
8
8
 
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Linter } from 'eslint';
2
2
  import { Config } from 'prettier';
3
3
 
4
4
  var name = "@alextheman/eslint-plugin";
5
- var version = "1.8.1";
5
+ var version = "1.9.0";
6
6
 
7
7
  declare const prettierRules: Config;
8
8
 
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.8.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: 'Who the hell imports from "{{source}}"?! Know your own project directory, Goddamnit!'
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
- fixable: "code",
3982
- schema: []
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 (!node.source.value.startsWith("./") && !node.source.value.startsWith("../")) {
3990
- context.report({
4007
+ if (depth === void 0) {
4008
+ return context.report({
3991
4009
  node,
3992
- messageId: "stupidPath",
4010
+ messageId: "message",
3993
4011
  data: {
3994
4012
  source: node.source.value
3995
4013
  }
3996
4014
  });
3997
- return null;
3998
4015
  }
3999
- context.report({
4000
- node,
4001
- messageId: "message",
4002
- data: {
4003
- source: node.source.value
4004
- },
4005
- fix(fixer) {
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
- const fullImportPath = path.resolve(
4010
- path.dirname(context.physicalFilename),
4011
- node.source.value
4012
- );
4013
- const projectRelativePath = path.relative(
4014
- context.parserOptions.tsconfigRootDir,
4015
- fullImportPath
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
- return fixer.replaceText(
4021
- node.source,
4022
- `${node.source.raw[0]}${path.posix.normalize(projectRelativePath)}${node.source.raw[0]}`
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/eslint-plugin",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,8 +11,8 @@
11
11
  "test": "vitest run",
12
12
  "test-watch": "vitest",
13
13
  "format": "npm run build && prettier --write --parser typescript \"src/**/*.ts\" \"tests/**/*.ts\" && eslint --fix --suppress-all \"src/**/*.ts\" \"tests/**/*.ts\" && rm -f eslint-suppressions.json",
14
- "lint": "npm run build && eslint \"src/**/*.ts\" \"tests/**/*.ts\" && prettier --check --parser typescript \"src/**/*.ts\" \"tests/**/*.ts\"",
15
- "update-dependencies": "npx npm-check-updates -u && npm install",
14
+ "lint": "npm run build && tsc --noEmit && eslint \"src/**/*.ts\" \"tests/**/*.ts\" && prettier --check --parser typescript \"src/**/*.ts\" \"tests/**/*.ts\"",
15
+ "update-dependencies": "bash -c 'npx npm-check-updates -u \"$@\" && npm install' --",
16
16
  "prepare": "husky",
17
17
  "build": "tsup",
18
18
  "change-major": "npm version major -m \"Change version number to v%s\"",
@@ -24,24 +24,24 @@
24
24
  "license": "ISC",
25
25
  "type": "module",
26
26
  "peerDependencies": {
27
- "@typescript-eslint/eslint-plugin": ">=8.37.0",
28
- "@typescript-eslint/parser": ">=8.37.0",
29
- "eslint": ">=9.31.0",
30
- "eslint-config-prettier": ">=10.1.8",
31
- "eslint-import-resolver-typescript": ">=4.4.4",
32
- "eslint-plugin-import": ">=2.32.0",
27
+ "@typescript-eslint/eslint-plugin": "^8.37.0",
28
+ "@typescript-eslint/parser": "^8.37.0",
29
+ "eslint": "^9.31.0",
30
+ "eslint-config-prettier": "^10.1.8",
31
+ "eslint-import-resolver-typescript": "^4.4.4",
32
+ "eslint-plugin-import": "^2.32.0",
33
33
  "eslint-plugin-perfectionist": "^4.15.0",
34
- "eslint-plugin-prettier": ">=5.5.3",
35
- "eslint-plugin-react": ">=7.37.5",
36
- "eslint-plugin-react-hooks": ">=5.2.0",
37
- "eslint-plugin-react-refresh": ">=0.4.20"
34
+ "eslint-plugin-prettier": "^5.5.3",
35
+ "eslint-plugin-react": "^7.37.5",
36
+ "eslint-plugin-react-hooks": "^5.2.0",
37
+ "eslint-plugin-react-refresh": "^0.4.20"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/common-tags": "^1.8.4",
41
41
  "@types/eslint": "^9.6.1",
42
42
  "@types/node": "^24.3.0",
43
- "@typescript-eslint/rule-tester": "^8.40.0",
44
- "@typescript-eslint/utils": "^8.40.0",
43
+ "@typescript-eslint/rule-tester": "^8.41.0",
44
+ "@typescript-eslint/utils": "^8.41.0",
45
45
  "eslint-plugin-eslint-plugin": "^7.0.0",
46
46
  "globals": "^16.3.0",
47
47
  "husky": "^9.1.7",