eslint-plugin-complete 1.0.3 → 1.0.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-mutable-return.d.ts","sourceRoot":"","sources":["../../src/rules/no-mutable-return.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-mutable-return.d.ts","sourceRoot":"","sources":["../../src/rules/no-mutable-return.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMvD,KAAK,UAAU,GAAG,cAAc,GAAG,YAAY,GAAG,YAAY,CAAC;AAE/D,eAAO,MAAM,eAAe,wHA6C1B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isTypeReferenceType } from "@typescript-eslint/type-utils";
|
|
1
2
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
3
|
import { getTypeName, unionTypeParts } from "../typeUtils.js";
|
|
3
4
|
import { createRule } from "../utils.js";
|
|
@@ -47,6 +48,15 @@ function getErrorMessageId(type) {
|
|
|
47
48
|
if (typeName === undefined) {
|
|
48
49
|
return undefined;
|
|
49
50
|
}
|
|
51
|
+
// Handle unwrapping promises.
|
|
52
|
+
if (typeName === "Promise" &&
|
|
53
|
+
isTypeReferenceType(type) &&
|
|
54
|
+
type.typeArguments !== undefined) {
|
|
55
|
+
const typeArgument = type.typeArguments[0];
|
|
56
|
+
if (typeArgument !== undefined) {
|
|
57
|
+
return getErrorMessageId(typeArgument);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
50
60
|
// This would be "ReadonlyMap" if it was the read-only version.
|
|
51
61
|
if (typeName === "Map") {
|
|
52
62
|
return "mutableMap";
|
|
@@ -57,11 +57,15 @@ export const requireVariadicFunctionArgument = createRule({
|
|
|
57
57
|
});
|
|
58
58
|
function isHardCodedException(node) {
|
|
59
59
|
const { callee } = node;
|
|
60
|
-
return (
|
|
61
|
-
isTimeoutFunction(callee) ||
|
|
62
|
-
isLoggerMethod(callee));
|
|
60
|
+
return isConsoleOrWindowOrLoggerFunction(callee) || isTimeoutFunction(callee);
|
|
63
61
|
}
|
|
64
|
-
|
|
62
|
+
/**
|
|
63
|
+
* This rule has a false positive with any logger function. (Both `console.log` and logger functions
|
|
64
|
+
* from logging libraries like Pino and Winston are affected.)
|
|
65
|
+
*
|
|
66
|
+
* e.g. `logger.info("hello world");`
|
|
67
|
+
*/
|
|
68
|
+
function isConsoleOrWindowOrLoggerFunction(callee) {
|
|
65
69
|
if (callee.type !== AST_NODE_TYPES.MemberExpression) {
|
|
66
70
|
return false;
|
|
67
71
|
}
|
|
@@ -69,7 +73,9 @@ function isConsoleOrWindowFunction(callee) {
|
|
|
69
73
|
if (object.type !== AST_NODE_TYPES.Identifier) {
|
|
70
74
|
return false;
|
|
71
75
|
}
|
|
72
|
-
return object.name === "console" ||
|
|
76
|
+
return (object.name === "console" ||
|
|
77
|
+
object.name === "window" ||
|
|
78
|
+
object.name === "logger");
|
|
73
79
|
}
|
|
74
80
|
function isTimeoutFunction(callee) {
|
|
75
81
|
if (callee.type !== AST_NODE_TYPES.Identifier) {
|
|
@@ -77,28 +83,6 @@ function isTimeoutFunction(callee) {
|
|
|
77
83
|
}
|
|
78
84
|
return callee.name === "setTimeout" || callee.name === "setInterval";
|
|
79
85
|
}
|
|
80
|
-
/**
|
|
81
|
-
* This rule has a false positive with any Pino logger function.
|
|
82
|
-
*
|
|
83
|
-
* e.g. `logger.info("hello world");`
|
|
84
|
-
*
|
|
85
|
-
* @see https://github.com/pinojs/pino
|
|
86
|
-
*/
|
|
87
|
-
function isLoggerMethod(callee) {
|
|
88
|
-
if (callee.type !== AST_NODE_TYPES.MemberExpression) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
const { object } = callee;
|
|
92
|
-
if (object.type !== AST_NODE_TYPES.Identifier) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
return (object.name === "trace" ||
|
|
96
|
-
object.name === "debug" ||
|
|
97
|
-
object.name === "info" ||
|
|
98
|
-
object.name === "warn" ||
|
|
99
|
-
object.name === "error" ||
|
|
100
|
-
object.name === "fatal");
|
|
101
|
-
}
|
|
102
86
|
function hasJSDocExceptionTag(checker, declaration) {
|
|
103
87
|
const type = checker.getTypeAtLocation(declaration);
|
|
104
88
|
const symbol = type.getSymbol();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-complete",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "An ESLint plugin that contains useful rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"test": "jest"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@typescript-eslint/type-utils": "^8.
|
|
48
|
-
"@typescript-eslint/utils": "^8.
|
|
49
|
-
"typescript-eslint": "^8.
|
|
47
|
+
"@typescript-eslint/type-utils": "^8.8.0",
|
|
48
|
+
"@typescript-eslint/utils": "^8.8.0",
|
|
49
|
+
"typescript-eslint": "^8.8.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/core": "^7.25.2",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@babel/preset-typescript": "^7.24.7",
|
|
55
55
|
"@types/jest": "^29.5.13",
|
|
56
56
|
"@types/node": "^22.7.4",
|
|
57
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
58
|
-
"@typescript-eslint/types": "^8.
|
|
57
|
+
"@typescript-eslint/rule-tester": "^8.8.0",
|
|
58
|
+
"@typescript-eslint/types": "^8.8.0",
|
|
59
59
|
"complete-common": "^1.0.0",
|
|
60
60
|
"complete-node": "^1.5.1",
|
|
61
61
|
"jest": "^29.7.0",
|