eslint-plugin-complete 1.0.3 → 1.0.4

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.
@@ -57,11 +57,15 @@ export const requireVariadicFunctionArgument = createRule({
57
57
  });
58
58
  function isHardCodedException(node) {
59
59
  const { callee } = node;
60
- return (isConsoleOrWindowFunction(callee) ||
61
- isTimeoutFunction(callee) ||
62
- isLoggerMethod(callee));
60
+ return isConsoleOrWindowOrLoggerFunction(callee) || isTimeoutFunction(callee);
63
61
  }
64
- function isConsoleOrWindowFunction(callee) {
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" || object.name === "window";
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",
3
+ "version": "1.0.4",
4
4
  "description": "An ESLint plugin that contains useful rules.",
5
5
  "keywords": [
6
6
  "eslint",