@alextheman/eslint-plugin 1.0.6 → 1.0.8

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
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name2 in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -27,17 +37,17 @@ module.exports = __toCommonJS(index_exports);
27
37
 
28
38
  // package.json
29
39
  var name = "@alextheman/eslint-plugin";
30
- var version = "1.0.6";
40
+ var version = "1.0.8";
31
41
 
32
- // src/createRule.ts
42
+ // create-rule.ts
33
43
  var import_utils = require("@typescript-eslint/utils");
34
44
  var createRule = import_utils.ESLintUtils.RuleCreator((ruleName) => {
35
45
  return `https://github.com/AlexMan123456/eslint-plugin/${ruleName}`;
36
46
  });
37
- var createRule_default = createRule;
47
+ var create_rule_default = createRule;
38
48
 
39
49
  // src/rules/no-namespace-imports.ts
40
- var noNamespaceImports = createRule_default({
50
+ var noNamespaceImports = create_rule_default({
41
51
  name: "no-namespace-imports",
42
52
  meta: {
43
53
  docs: {
@@ -88,9 +98,68 @@ var noNamespaceImports = createRule_default({
88
98
  });
89
99
  var no_namespace_imports_default = noNamespaceImports;
90
100
 
101
+ // src/rules/no-relative-imports.ts
102
+ var import_path = __toESM(require("path"), 1);
103
+ var noRelativeImports = create_rule_default({
104
+ name: "",
105
+ meta: {
106
+ docs: { description: "Forbid the use of relative imports" },
107
+ messages: {
108
+ message: "Relative import from '{{source}}' is not allowed."
109
+ },
110
+ type: "suggestion",
111
+ fixable: "code",
112
+ schema: []
113
+ },
114
+ defaultOptions: [],
115
+ create(context) {
116
+ return {
117
+ ImportDeclaration(node) {
118
+ if (node.source.value.includes("./") || node.source.value.includes("../")) {
119
+ context.report({
120
+ node,
121
+ messageId: "message",
122
+ data: {
123
+ source: node.source.value
124
+ },
125
+ fix(fixer) {
126
+ if (!context.parserOptions.tsconfigRootDir) {
127
+ return null;
128
+ }
129
+ if (!node.source.value.startsWith("./") && !node.source.value.startsWith("../")) {
130
+ console.warn(
131
+ `Who the hell imports from ${node.source.value}?! Know your own project directory, Goddamnit!`
132
+ );
133
+ return null;
134
+ }
135
+ const fullImportPath = import_path.default.resolve(
136
+ import_path.default.dirname(context.physicalFilename),
137
+ node.source.value
138
+ );
139
+ const projectRelativePath = import_path.default.relative(
140
+ context.parserOptions.tsconfigRootDir,
141
+ fullImportPath
142
+ );
143
+ if (projectRelativePath.startsWith("..")) {
144
+ return null;
145
+ }
146
+ return fixer.replaceText(
147
+ node.source,
148
+ `${node.source.raw[0]}${import_path.default.posix.normalize(projectRelativePath)}${node.source.raw[0]}`
149
+ );
150
+ }
151
+ });
152
+ }
153
+ }
154
+ };
155
+ }
156
+ });
157
+ var no_relative_imports_default = noRelativeImports;
158
+
91
159
  // src/rules/index.ts
92
160
  var rules_default = {
93
- "no-namespace-imports": no_namespace_imports_default
161
+ "no-namespace-imports": no_namespace_imports_default,
162
+ "no-relative-imports": no_relative_imports_default
94
163
  };
95
164
 
96
165
  // src/index.ts
package/dist/index.d.cts CHANGED
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [{
5
5
  allow: string[];
6
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>;
7
8
  };
8
9
 
9
10
  declare const meta: {
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  "no-namespace-imports": _typescript_eslint_utils_ts_eslint.RuleModule<"message", [{
5
5
  allow: string[];
6
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>;
7
8
  };
8
9
 
9
10
  declare const meta: {
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  // package.json
2
2
  var name = "@alextheman/eslint-plugin";
3
- var version = "1.0.6";
3
+ var version = "1.0.8";
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: {
@@ -61,9 +61,68 @@ var noNamespaceImports = createRule_default({
61
61
  });
62
62
  var no_namespace_imports_default = noNamespaceImports;
63
63
 
64
+ // src/rules/no-relative-imports.ts
65
+ import path from "path";
66
+ var noRelativeImports = create_rule_default({
67
+ name: "",
68
+ meta: {
69
+ docs: { description: "Forbid the use of relative imports" },
70
+ messages: {
71
+ message: "Relative import from '{{source}}' is not allowed."
72
+ },
73
+ type: "suggestion",
74
+ fixable: "code",
75
+ schema: []
76
+ },
77
+ defaultOptions: [],
78
+ create(context) {
79
+ return {
80
+ ImportDeclaration(node) {
81
+ if (node.source.value.includes("./") || node.source.value.includes("../")) {
82
+ context.report({
83
+ node,
84
+ messageId: "message",
85
+ data: {
86
+ source: node.source.value
87
+ },
88
+ fix(fixer) {
89
+ if (!context.parserOptions.tsconfigRootDir) {
90
+ return null;
91
+ }
92
+ if (!node.source.value.startsWith("./") && !node.source.value.startsWith("../")) {
93
+ console.warn(
94
+ `Who the hell imports from ${node.source.value}?! Know your own project directory, Goddamnit!`
95
+ );
96
+ return null;
97
+ }
98
+ const fullImportPath = path.resolve(
99
+ path.dirname(context.physicalFilename),
100
+ node.source.value
101
+ );
102
+ const projectRelativePath = path.relative(
103
+ context.parserOptions.tsconfigRootDir,
104
+ fullImportPath
105
+ );
106
+ if (projectRelativePath.startsWith("..")) {
107
+ return null;
108
+ }
109
+ return fixer.replaceText(
110
+ node.source,
111
+ `${node.source.raw[0]}${path.posix.normalize(projectRelativePath)}${node.source.raw[0]}`
112
+ );
113
+ }
114
+ });
115
+ }
116
+ }
117
+ };
118
+ }
119
+ });
120
+ var no_relative_imports_default = noRelativeImports;
121
+
64
122
  // src/rules/index.ts
65
123
  var rules_default = {
66
- "no-namespace-imports": no_namespace_imports_default
124
+ "no-namespace-imports": no_namespace_imports_default,
125
+ "no-relative-imports": no_relative_imports_default
67
126
  };
68
127
 
69
128
  // src/index.ts
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@alextheman/eslint-plugin",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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'",
@@ -25,11 +27,12 @@
25
27
  "eslint-plugin-import": "^2.32.0"
26
28
  },
27
29
  "devDependencies": {
28
- "@alextheman/eslint-config-typescript-base": "^1.0.7",
30
+ "@alextheman/eslint-config-typescript-base": "^1.0.9",
29
31
  "@types/eslint": "^9.6.1",
30
32
  "@types/jest": "^30.0.0",
31
- "@typescript-eslint/rule-tester": "^8.36.0",
32
- "@typescript-eslint/utils": "^8.36.0",
33
+ "@types/node": "^24.0.13",
34
+ "@typescript-eslint/rule-tester": "^8.37.0",
35
+ "@typescript-eslint/utils": "^8.37.0",
33
36
  "eslint": "^9.31.0",
34
37
  "eslint-plugin-eslint-plugin": "^6.5.0",
35
38
  "husky": "^9.1.7",
@@ -37,5 +40,8 @@
37
40
  "ts-jest": "^29.4.0",
38
41
  "tsup": "^8.5.0",
39
42
  "typescript": "^5.8.3"
43
+ },
44
+ "dependencies": {
45
+ "@alextheman/utility": "^1.5.2"
40
46
  }
41
47
  }