@blumintinc/eslint-plugin-blumint 1.19.18 → 1.19.19
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/lib/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.enforceAssertSafeObjectKey = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
9
|
const createRule_1 = require("../utils/createRule");
|
|
6
10
|
const ASTHelpers_1 = require("../utils/ASTHelpers");
|
|
@@ -31,13 +35,47 @@ exports.enforceAssertSafeObjectKey = (0, createRule_1.createRule)({
|
|
|
31
35
|
create(context, [options]) {
|
|
32
36
|
const importPath = options?.assertSafeImportPath || DEFAULT_IMPORT_PATH;
|
|
33
37
|
let hasAssertSafeImport = false;
|
|
38
|
+
/**
|
|
39
|
+
* Computes the module specifier for the injected assertSafe import.
|
|
40
|
+
*
|
|
41
|
+
* `importPath` is anchored at the repo root (relative to process.cwd(),
|
|
42
|
+
* which is the repo root in real eslint runs), matching how
|
|
43
|
+
* avoid-utils-directory and test-file-location-enforcement treat paths.
|
|
44
|
+
* A bare repo-root specifier such as 'functions/src/util/assertSafe' is
|
|
45
|
+
* unresolvable inside the functions/ TS project, whose baseUrl is
|
|
46
|
+
* functions/: it would resolve to functions/functions/src/util/assertSafe,
|
|
47
|
+
* which does not exist. The specifier is therefore derived relative to the
|
|
48
|
+
* file being fixed so the emitted import resolves from that file's location.
|
|
49
|
+
*/
|
|
50
|
+
const computeImportSpecifier = () => {
|
|
51
|
+
const rawFilename = context.getFilename().replace(/\\/g, '/');
|
|
52
|
+
// Virtual/stdin files (RuleTester default 'file.ts', '<input>', '<text>')
|
|
53
|
+
// are not absolute; we cannot anchor a relative path, so emit the
|
|
54
|
+
// configured path verbatim (preserves the option's literal value for
|
|
55
|
+
// non-file lints).
|
|
56
|
+
if (!path_1.default.isAbsolute(rawFilename)) {
|
|
57
|
+
return importPath;
|
|
58
|
+
}
|
|
59
|
+
const target = importPath
|
|
60
|
+
.replace(/\\/g, '/')
|
|
61
|
+
.replace(/\.(tsx?|jsx?|mts|cts)$/i, '');
|
|
62
|
+
const fileRelToCwd = path_1.default
|
|
63
|
+
.relative(process.cwd(), rawFilename)
|
|
64
|
+
.replace(/\\/g, '/');
|
|
65
|
+
const fileDir = path_1.default.posix.dirname(fileRelToCwd);
|
|
66
|
+
let specifier = path_1.default.posix.relative(fileDir, target);
|
|
67
|
+
if (!specifier.startsWith('.')) {
|
|
68
|
+
specifier = `./${specifier}`;
|
|
69
|
+
}
|
|
70
|
+
return specifier;
|
|
71
|
+
};
|
|
34
72
|
/**
|
|
35
73
|
* Helper function to add assertSafe import if needed
|
|
36
74
|
*/
|
|
37
75
|
const addAssertSafeImport = (fixer) => {
|
|
38
76
|
const program = context.sourceCode.ast;
|
|
39
77
|
const firstImport = program.body.find((node) => node.type === utils_1.AST_NODE_TYPES.ImportDeclaration);
|
|
40
|
-
const importStatement = `import { assertSafe } from '${
|
|
78
|
+
const importStatement = `import { assertSafe } from '${computeImportSpecifier()}';\n`;
|
|
41
79
|
if (firstImport) {
|
|
42
80
|
return fixer.insertTextBefore(firstImport, importStatement);
|
|
43
81
|
}
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.19.19",
|
|
4
|
+
"date": "2026-07-18T17:27:38.611Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "enforce-assert-safe-object-key",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1321
|
|
11
|
+
],
|
|
12
|
+
"summary": "compute assertSafe import specifier relative to the fixed file (closes #1321)"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"version": "1.19.18",
|
|
4
18
|
"date": "2026-07-18T13:43:27.635Z",
|