UNPKG

eslint-plugin-o1js

Version:

o1js rules for ESLint

57 lines (56 loc) 2.81 kB
import type { TSESTree } from '@typescript-eslint/experimental-utils'; /** * Get a list of all decorators on a node. * @param node Node to get decorators from * @returns A list of decorators. Returns an empty list if none are found. */ export declare function getDecorators(node: TSESTree.Node): TSESTree.Decorator[]; /** * Return an object that contains what kind of o1js decorator was used * (e.g `@state` `@prop`, or `@arrayProp`) * and the decorator node. * @param node The node to get the decorators from * @returns An object indicating what decorator was used and the node */ export declare function getValidDecorator(node: TSESTree.Node): { kind: "prop" | "arrayProp" | "state"; decorator: TSESTree.Decorator; } | undefined; /** * Gets the first value of a decorator expression if it has one, otherwiser returns `undefined`. * For example, if called on `@state(T)`, it will return `T`. * @param decorator The specified decorator * @returns The first value of the decorator or undefined */ export declare function getFirstDecoratorValue(decorator: TSESTree.Decorator): string | undefined; /** * Gets the second value of a decorator expression if it has one, otherwise returns `undefined`. * For example, if called on `@state(T, U)`, it will return `U` * @param decorator The specified decorator * @returns The second value of the decorator or undefined */ export declare function getSecondDecoratorValue(decorator: TSESTree.Decorator): string | number | bigint | boolean | RegExp | null | undefined; /** * Gets the annotated type of a node if it has one. For example, if a node has the statement * `node: T`, it will return `T`. Otherwise return undefined. * @param node The specified node * @returns The type annotation of the node or undefined */ export declare function getPropertyType(node: TSESTree.Node): string | undefined; /** * Gets the function name of a node if it has one, otherwise return undefined. * @param node The specified node * @returns The function name or undefined */ export declare function getFunctionName(node: TSESTree.Node): string | undefined; /** * Checks to see if the specified `CallExpression` node uses a banned import or calls upon * a banned function. * @param node The specified `CallExpression` node * @param bannedImports A set of banned imports * @param bannedFunctions A set of banned functions * @returns True if the `CallExpression` calls on a banned import or function or false */ export declare function isBannedCallExpression(node: TSESTree.CallExpression, bannedImports: Set<string>, bannedFunctions: Set<string>): boolean; export declare function getClassBodyStatements(node: TSESTree.Node): TSESTree.ClassElement[] | undefined; export declare function getClassName(node: TSESTree.Node): string | undefined;