Skip to content

Commit

Permalink
chore: clean
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Apr 28, 2022
1 parent ab0393f commit 8ff4630
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/rules/utils.ts
@@ -1,5 +1,4 @@
import { parse as parsePath } from 'path';
import { inspect } from 'util';
import {
AST_NODE_TYPES,
ESLintUtils,
Expand Down Expand Up @@ -732,8 +731,6 @@ export const isTestCaseCall = (
name = resolveToJestFn(scope, name);
}

// console.log(name);

return !!name && TestCaseName.hasOwnProperty(name);
};

Expand Down Expand Up @@ -899,8 +896,6 @@ const describeVariableDefAsImport = (
imported: getAccessorValue(def.name.parent.key),
local: def.name.name,
};

return null;
};

/**
Expand All @@ -925,7 +920,7 @@ const describePossibleImportDef = (def: TSESLint.Scope.Definition) => {
return null;
};

const collectReferences = (scope: TSESLint.Scope.Scope, log?: boolean) => {
const collectReferences = (scope: TSESLint.Scope.Scope) => {
const locals = new Set();
const imports = new Map<string, ImportDetails>();
const unresolved = new Set();
Expand All @@ -944,11 +939,8 @@ const collectReferences = (scope: TSESLint.Scope.Scope, log?: boolean) => {

const [def] = ref.defs;

// console.log(inspect(def, { depth: Infinity }));
const importDetails = describePossibleImportDef(def);

console.log(importDetails);

if (importDetails) {
imports.set(importDetails.local, importDetails);

Expand Down Expand Up @@ -989,11 +981,7 @@ export const resolveToJestFn = (
scope: TSESLint.Scope.Scope,
identifier: string,
) => {
const references = collectReferences(scope, identifier === 'it');

if (identifier === 'it') {
console.log(identifier, inspect(references, { depth: Infinity }));
}
const references = collectReferences(scope);

const maybeImport = references.imports.get(identifier);

Expand All @@ -1010,16 +998,12 @@ export const resolveToJestFn = (
// the identifier was found as a local variable or function declaration
// meaning it's not a function from jest
if (references.locals.has(identifier)) {
console.log('this is a local!');

return null;
}

// the identifier was not found as an unresolved reference,
// meaning it's unlikely to be an implicit global variable
if (!references.unresolved.has(identifier)) {
console.log('this is not unresolved local!');

return null;
}

Expand Down

0 comments on commit 8ff4630

Please sign in to comment.