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"
            | "index"
            | "skip"
            | "first"
            | "last"
            | "tail"
            | "take"
            | "merge"
            | "select"
        )[],
        FlowrSearchElements<Info, Elements>,
    >;
    defaultConfig: NoInfer<Config>;
    prettyPrint: (result: Result, metadata: Metadata) => string;
    processSearchResult: (
        elements: FlowrSearchElements<Info, Elements>,
        config: Config,
        data: { 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"
        | "index"
        | "skip"
        | "first"
        | "last"
        | "tail"
        | "take"
        | "merge"
        | "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.

defaultConfig: NoInfer<Config>

The default config for this linting rule. The default config is combined with the user config when executing the rule.

prettyPrint: (result: Result, metadata: Metadata) => string

A function used to pretty-print the given linting result. By default, the LintingResult#certainty is automatically printed alongside this information.

processSearchResult: (
    elements: FlowrSearchElements<Info, Elements>,
    config: Config,
    data: { 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.