eslint-plugin-no-mistakes 0.69.0 → 0.71.1
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/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { quasiText, sqlText, unwrapTs } = require("./postgres-query-text");
|
|
4
4
|
|
|
5
|
-
const DEFAULT_IMPORT_SPECIFIER = "
|
|
5
|
+
const DEFAULT_IMPORT_SPECIFIER = "";
|
|
6
6
|
const DEFAULT_EXECUTOR_NAMES = ["query", "read", "write"];
|
|
7
7
|
const DEFAULT_CHUNK_FUNCTION_NAMES = ["chunkArray"];
|
|
8
8
|
const TRANSACTION_IMPORTS = new Set(["withTransaction", "withTransactionOptions"]);
|
|
@@ -12,7 +12,7 @@ const TRANSACTION_COMMAND = /^\s*(?:BEGIN|COMMIT|ROLLBACK)\b/i;
|
|
|
12
12
|
function executorOptionDefaults(options = {}) {
|
|
13
13
|
return {
|
|
14
14
|
importSpecifier: options.importSpecifier ?? DEFAULT_IMPORT_SPECIFIER,
|
|
15
|
-
executorNames: options.executorNames ?? DEFAULT_EXECUTOR_NAMES,
|
|
15
|
+
executorNames: options.executorNames ?? (options.importSpecifier ? DEFAULT_EXECUTOR_NAMES : []),
|
|
16
16
|
owners: options.owners ?? [],
|
|
17
17
|
chunkFunctionNames: options.chunkFunctionNames ?? DEFAULT_CHUNK_FUNCTION_NAMES,
|
|
18
18
|
};
|
|
@@ -39,15 +39,16 @@ function importedName(specifier) {
|
|
|
39
39
|
function executorBindings(program, options = {}) {
|
|
40
40
|
const bindings = new Set();
|
|
41
41
|
const { importSpecifier, executorNames } = executorOptionDefaults(options);
|
|
42
|
+
bindings.queryMembers = Boolean(importSpecifier) || executorNames.includes(QUERY_PROPERTY);
|
|
42
43
|
for (const statement of program?.body ?? []) {
|
|
43
44
|
if (statement.type !== "ImportDeclaration") continue;
|
|
44
45
|
if (statement.importKind === "type") continue;
|
|
45
|
-
if (statement.source?.value !== importSpecifier) continue;
|
|
46
|
+
if (importSpecifier && statement.source?.value !== importSpecifier) continue;
|
|
46
47
|
for (const specifier of statement.specifiers ?? []) {
|
|
47
48
|
if (specifier.type !== "ImportSpecifier") continue;
|
|
48
49
|
if (specifier.importKind === "type") continue;
|
|
49
50
|
const imported = importedName(specifier);
|
|
50
|
-
if (TRANSACTION_IMPORTS.has(imported)) bindings.add(QUERY_PROPERTY);
|
|
51
|
+
if (importSpecifier && TRANSACTION_IMPORTS.has(imported)) bindings.add(QUERY_PROPERTY);
|
|
51
52
|
if (imported && executorNames.includes(imported)) bindings.add(specifier.local.name);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -75,7 +76,11 @@ function calleeName(call, bindings) {
|
|
|
75
76
|
const callee = unwrapTs(call?.callee);
|
|
76
77
|
if (!callee) return null;
|
|
77
78
|
if (callee.type === "Identifier" && bindings?.has(callee.name)) return callee.name;
|
|
78
|
-
if (
|
|
79
|
+
if (
|
|
80
|
+
bindings?.queryMembers !== false &&
|
|
81
|
+
callee.type === "MemberExpression" &&
|
|
82
|
+
memberPropertyName(callee) === QUERY_PROPERTY
|
|
83
|
+
) {
|
|
79
84
|
return QUERY_PROPERTY;
|
|
80
85
|
}
|
|
81
86
|
return null;
|