UNPKG

eslint-plugin-sonarjs

Version:
54 lines (53 loc) • 2.76 kB
/** * Low-level assertion detector primitives used by the framework catalog. * * This is intentionally distinct from `assertions.ts`, which extracts the * *structure* of an assertion (subject, predicate, comparison) for rules that * reason about assertion arguments. Framework selection and rule-specific * interpretation live in `assertion-frameworks.ts`. */ import type { Rule } from 'eslint'; import type estree from 'estree'; import type { ParserServicesWithTypeInformation } from '@typescript-eslint/utils'; import ts from 'typescript'; export declare function hasSupportedTestFramework(context: Rule.RuleContext): boolean; /** * Whether `node` is a compile-time-only type check that must not be flagged for * placement outside a test case. */ export declare function isTypeLevelAssertion(context: Rule.RuleContext, node: estree.Node): boolean; /** * Incomplete Chai `foo.should` property chains are not assertions on their own. * We exclude them so S2699 does not treat an unfinished `should` chain as an assertion * and miss the "Add at least one assertion to this test case." issue. */ export declare function isIncompleteShouldAccess(context: Rule.RuleContext, node: estree.Node): boolean; /** * Whether a typed Chai `should` property access ends in a complete assertion. */ export declare function isChaiShouldTSAssertion(node: ts.Node): boolean; /** * Checks if the node matches the pattern expectX(...).method() where: * - expectX is one of the known global expect entry points ({@link GLOBAL_EXPECT_NAMES}) * or a Playwright `expect(...)` entry point * - method is a chained property access with a method call (e.g., .toBe(), .toEqual(), .not.toBe()) * * This mirrors the TypeScript isGlobalExpectExpression function logic. */ export declare function isGlobalExpectAssertion(context: Rule.RuleContext, node: estree.CallExpression): boolean; /** * Whether `node` is a call rooted at the node `assert` module — `assert(...)` itself or any of its * methods. Pure-AST counterpart of {@link isNodeAssertTSAssertion}. */ export declare function isNodeAssertAssertion(context: Rule.RuleContext, node: estree.Node): boolean; /** * Type-checker-aware counterpart of {@link isGlobalExpectAssertion}: a resolved global * `expect*(...)` chain. Node `assert` is deliberately not covered here — it is its own catalog * entry, {@link isNodeAssertTSAssertion}. */ export declare function isGlobalTSExpectAssertion(services: ParserServicesWithTypeInformation, node: ts.Node): boolean; /** * Type-checker-aware counterpart of {@link isNodeAssertAssertion}, also accepting the * `assert/strict` entry point. */ export declare function isNodeAssertTSAssertion(services: ParserServicesWithTypeInformation, node: ts.Node): boolean;