eslint-plugin-sonarjs
Version:
38 lines (37 loc) • 1.77 kB
TypeScript
import type estree from 'estree';
import type { Rule } from 'eslint';
/**
* `(factory as Function)` -> `factory`
* `factory<number>` -> `factory`
*/
export declare function unwrapTypeScriptValue(expression: estree.Node): estree.Node;
/**
* Get a module loader path rooted at `define`, `sap`, `require`, or `System`.
*
* `sap.ui.define` -> ['sap', 'ui', 'define']
* `other.ui.define` -> undefined
* `sap.ui['define']` -> ['sap', 'ui', 'define'] when `allowComputed` is true
* `sap.ui[42]` -> ['sap', 'ui', '42'] when `allowComputed` is true
* sap.ui[`unrelated`] -> ['sap', 'ui', 'unrelated'] when `allowComputed` is true
* `sap.ui[key]` -> ['sap', 'ui', undefined] when `allowComputed` is true
* `sap.ui[key]` -> undefined when `allowComputed` is false
*
* An `undefined` segment can match any property when the rule checks writes.
*/
export declare function getModuleLoaderPath(expression: estree.Node, allowComputed: false): string[] | undefined;
export declare function getModuleLoaderPath(expression: estree.Node, allowComputed: boolean): (string | undefined)[] | undefined;
/**
* Match an unshadowed bare `define` call with an AMD signature.
*
* `define([], function () {})` -> the function node
* `define?.([], function () {})` -> undefined
*/
export declare function getModuleFactory(call: estree.CallExpression, hasRuntimeBinding: (node: estree.Node, name: string) => boolean): estree.FunctionExpression | undefined;
/** Type-only declarations do not shadow a runtime value. */
export declare function hasRuntimeBinding(context: Rule.RuleContext, node: estree.Node, name: string): boolean;
/**
* `'dep'` -> true
* `dep` -> false
* `` `dep` `` -> false
*/
export declare function isStringLiteral(node: estree.Node | null | undefined): boolean;