Interface LintingRule<Result, Metadata, Config, Info, Elements>

The base interface for a linting rule, which contains all of its relevant settings. The registry of valid linting rules is stored in LintingRules.

interface LintingRule<
    Result extends LintingResult,
    Metadata extends MergeableRecord,
    Config extends MergeableRecord = never,
    Info = ParentInformation,
    Elements extends FlowrSearchElement<Info>[] = FlowrSearchElement<Info>[],
> {
    createSearch: (
        config: Config,
        data: { dataflow: DataflowInformation; normalize: NormalizedAst },
    ) => FlowrSearchLike<
        Info,
        "get"
        | "from"
        | "all"
        | "criterion"
        | "from-query",
        (
            | "map"
            | "filter"
            | "with"
            | "last"
            | "index"
            | "skip"
            | "first"
            | "tail"
            | "take"
            | "merge"
            | "unique"
            | "select"
        )[],
        FlowrSearchElements<Info, Elements>,
    >;
    info: LinterRuleInformation<NoInfer<Config>>;
    prettyPrint: {
        full: (result: Result, metadata: Metadata) => string;
        query: (result: Result, metadata: Metadata) => string;
    };
    processSearchResult: (
        elements: FlowrSearchElements<Info, Elements>,
        config: Config,
        data: {
            config: FlowrConfigOptions;
            dataflow: DataflowInformation;
            normalize: NormalizedAst;
        },
    ) => { ".meta": Metadata; results: Result[] };
}

Type Parameters

Properties

createSearch: (
    config: Config,
    data: { dataflow: DataflowInformation; normalize: NormalizedAst },
) => FlowrSearchLike<
    Info,
    "get"
    | "from"
    | "all"
    | "criterion"
    | "from-query",
    (
        | "map"
        | "filter"
        | "with"
        | "last"
        | "index"
        | "skip"
        | "first"
        | "tail"
        | "take"
        | "merge"
        | "unique"
        | "select"
    )[],
    FlowrSearchElements<Info, Elements>,
>

Creates a flowR search that will then be executed and whose results will be passed to processSearchResult. In the future, additional optimizations and transformations may be applied to the search between this function and processSearchResult.

prettyPrint: {
    full: (result: Result, metadata: Metadata) => string;
    query: (result: Result, metadata: Metadata) => string;
}

A set of functions used to pretty-print the given linting result. By default, the LintingResult#certainty and whether any LintingResult#quickFix values are available is automatically printed alongside this information.

processSearchResult: (
    elements: FlowrSearchElements<Info, Elements>,
    config: Config,
    data: {
        config: FlowrConfigOptions;
        dataflow: DataflowInformation;
        normalize: NormalizedAst;
    },
) => { ".meta": Metadata; results: Result[] }

Processes the search results of the search created through createSearch. This function is expected to return the linting results from this rule for the given search, ie usually the given script file.