@alextheman/eslint-plugin 1.0.7 → 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 +39 -1
- package/dist/index.js +29 -1
- package/package.json +8 -4
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,7 +37,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
27
37
|
|
|
28
38
|
// package.json
|
|
29
39
|
var name = "@alextheman/eslint-plugin";
|
|
30
|
-
var version = "1.0.
|
|
40
|
+
var version = "1.0.8";
|
|
31
41
|
|
|
32
42
|
// create-rule.ts
|
|
33
43
|
var import_utils = require("@typescript-eslint/utils");
|
|
@@ -89,6 +99,7 @@ var noNamespaceImports = create_rule_default({
|
|
|
89
99
|
var no_namespace_imports_default = noNamespaceImports;
|
|
90
100
|
|
|
91
101
|
// src/rules/no-relative-imports.ts
|
|
102
|
+
var import_path = __toESM(require("path"), 1);
|
|
92
103
|
var noRelativeImports = create_rule_default({
|
|
93
104
|
name: "",
|
|
94
105
|
meta: {
|
|
@@ -97,6 +108,7 @@ var noRelativeImports = create_rule_default({
|
|
|
97
108
|
message: "Relative import from '{{source}}' is not allowed."
|
|
98
109
|
},
|
|
99
110
|
type: "suggestion",
|
|
111
|
+
fixable: "code",
|
|
100
112
|
schema: []
|
|
101
113
|
},
|
|
102
114
|
defaultOptions: [],
|
|
@@ -109,6 +121,32 @@ var noRelativeImports = create_rule_default({
|
|
|
109
121
|
messageId: "message",
|
|
110
122
|
data: {
|
|
111
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
|
+
);
|
|
112
150
|
}
|
|
113
151
|
});
|
|
114
152
|
}
|
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.8";
|
|
4
4
|
|
|
5
5
|
// create-rule.ts
|
|
6
6
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
@@ -62,6 +62,7 @@ var noNamespaceImports = create_rule_default({
|
|
|
62
62
|
var no_namespace_imports_default = noNamespaceImports;
|
|
63
63
|
|
|
64
64
|
// src/rules/no-relative-imports.ts
|
|
65
|
+
import path from "path";
|
|
65
66
|
var noRelativeImports = create_rule_default({
|
|
66
67
|
name: "",
|
|
67
68
|
meta: {
|
|
@@ -70,6 +71,7 @@ var noRelativeImports = create_rule_default({
|
|
|
70
71
|
message: "Relative import from '{{source}}' is not allowed."
|
|
71
72
|
},
|
|
72
73
|
type: "suggestion",
|
|
74
|
+
fixable: "code",
|
|
73
75
|
schema: []
|
|
74
76
|
},
|
|
75
77
|
defaultOptions: [],
|
|
@@ -82,6 +84,32 @@ var noRelativeImports = create_rule_default({
|
|
|
82
84
|
messageId: "message",
|
|
83
85
|
data: {
|
|
84
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
|
+
);
|
|
85
113
|
}
|
|
86
114
|
});
|
|
87
115
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/eslint-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"eslint-plugin-import": "^2.32.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@alextheman/eslint-config-typescript-base": "^1.0.
|
|
30
|
+
"@alextheman/eslint-config-typescript-base": "^1.0.9",
|
|
31
31
|
"@types/eslint": "^9.6.1",
|
|
32
32
|
"@types/jest": "^30.0.0",
|
|
33
|
-
"@
|
|
34
|
-
"@typescript-eslint/
|
|
33
|
+
"@types/node": "^24.0.13",
|
|
34
|
+
"@typescript-eslint/rule-tester": "^8.37.0",
|
|
35
|
+
"@typescript-eslint/utils": "^8.37.0",
|
|
35
36
|
"eslint": "^9.31.0",
|
|
36
37
|
"eslint-plugin-eslint-plugin": "^6.5.0",
|
|
37
38
|
"husky": "^9.1.7",
|
|
@@ -39,5 +40,8 @@
|
|
|
39
40
|
"ts-jest": "^29.4.0",
|
|
40
41
|
"tsup": "^8.5.0",
|
|
41
42
|
"typescript": "^5.8.3"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@alextheman/utility": "^1.5.2"
|
|
42
46
|
}
|
|
43
47
|
}
|