eslint-plugin-unslop 0.7.1 → 0.7.3

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 CHANGED
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(index_exports);
37
37
  // package.json
38
38
  var package_default = {
39
39
  name: "eslint-plugin-unslop",
40
- version: "0.7.1",
40
+ version: "0.7.3",
41
41
  description: "ESLint plugin with rules for reducing AI-generated code smells",
42
42
  repository: {
43
43
  type: "git",
@@ -1186,10 +1186,30 @@ function isLocalPublicExport(node) {
1186
1186
  }
1187
1187
  function isEagerInit(node) {
1188
1188
  const t = node.type;
1189
- if (t === "ExpressionStatement" || t === "IfStatement") return true;
1189
+ if (t === "IfStatement") return true;
1190
+ if (t === "ExpressionStatement") return !isTestFrameworkCall(node);
1190
1191
  if (t === "ExportDefaultDeclaration") return isEagerDefaultExport(node);
1191
1192
  return isEagerVarDecl(t === "ExportNamedDeclaration" ? prop(node, "declaration") : node);
1192
1193
  }
1194
+ function isTestFrameworkCall(node) {
1195
+ const expr = prop(node, "expression");
1196
+ if (!expr || typeof expr !== "object") return false;
1197
+ if (strProp(expr, "type") !== "CallExpression") return false;
1198
+ const callee = prop(expr, "callee");
1199
+ if (!callee || typeof callee !== "object") return false;
1200
+ if (strProp(callee, "type") !== "Identifier") return false;
1201
+ const name = strProp(callee, "name");
1202
+ return typeof name === "string" && TEST_FRAMEWORK_CALLS.has(name);
1203
+ }
1204
+ var TEST_FRAMEWORK_CALLS = /* @__PURE__ */ new Set([
1205
+ "describe",
1206
+ "it",
1207
+ "test",
1208
+ "beforeAll",
1209
+ "beforeEach",
1210
+ "afterAll",
1211
+ "afterEach"
1212
+ ]);
1193
1213
  function isEagerDefaultExport(node) {
1194
1214
  const declType = strProp(prop(node, "declaration"), "type");
1195
1215
  return declType === "CallExpression" || declType === "NewExpression";
@@ -1268,6 +1288,7 @@ function walkIds(node, ids, skip) {
1268
1288
  if (!t) return;
1269
1289
  if (t === "Identifier") {
1270
1290
  addIdentifier(node, ids, skip);
1291
+ walkIds(prop(node, "typeAnnotation"), ids, skip);
1271
1292
  return;
1272
1293
  }
1273
1294
  if (t === "Literal" || t === "TemplateLiteral") return;