UNPKG

eslint-plugin-sonarjs

Version:
24 lines (23 loc) 1.4 kB
import type { Rule, Scope } from 'eslint'; import type estree from 'estree'; import type { AssertionPredicate, AssertionStyle } from '../helpers/assertions.js'; export type ConstantPrimitive = boolean | string | number | bigint | null | undefined; /** * Whether a resolved constant `value` satisfies the given assertion `predicate`. */ export declare function predicateHolds(predicate: AssertionPredicate, value: ConstantPrimitive): boolean; /** * Same as `predicateHolds`, specialized for freshly-created references: they're always truthy, * always defined, always "existing", and never null, `=== true`, or `=== false` (a fresh * reference is an object, never the boolean primitive itself). */ export declare function freshReferencePredicateHolds(predicate: AssertionPredicate): boolean; export declare function strictEqualityHolds(style: AssertionStyle, actual: ConstantPrimitive, expected: ConstantPrimitive): boolean; /** * Resolves `node` to its constant primitive value when it's statically known (including through * a resolved `const` binding), or `undefined` when it isn't resolvable. `visited` guards against * mutually-recursive const references like `const a = b; const b = a;` (TDZ at runtime). */ export declare function resolveConstantPrimitiveValue(context: Rule.RuleContext, node: estree.Node, visited?: Set<Scope.Variable>): { value: ConstantPrimitive; } | undefined;