TanStackT
TanStack6mo ago
4 replies
colossal-harlequin

Configuring arrow-function style for route file auto generated code

In a monorepo I'm working in, we have the following react eslint rule set to enforce arrow-function style for react function components (https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md). When Tanstack router's auto code generation generates route file content, there's many things that can be configured looking at the configuration and the source code for the config: https://tanstack.com/router/latest/docs/framework/react/routing/installation-with-vite#configuration
Is there an existing configuration to set for this? I couldn't find any. There is a customScaffolding configuration which I assume could be used for this, but I'd prefer not to muck around with the default template for a small thing as such. Would it be possible to include this as a config option for the generated code?

declare const tanstackRouter: (options?: Partial<{
    target: "react" | "solid";
    routeFileIgnorePrefix: string;
    routesDirectory: string;
    quoteStyle: "single" | "double";
    semicolons: boolean;
    disableLogging: boolean;
    routeTreeFileHeader: string[];
    indexToken: string;
    routeToken: string;
    generatedRouteTree: string;
    disableTypes: boolean;
    addExtensions: boolean;
    enableRouteTreeFormatting: boolean;
    routeTreeFileFooter: string[];
    tmpDir: string;
    enableRouteGeneration?: boolean | undefined;
    codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
    virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
    routeFilePrefix?: string | undefined;
    routeFileIgnorePattern?: string | undefined;
    pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
    verboseFileRoutes?: boolean | undefined;
    autoCodeSplitting?: boolean | undefined;
    customScaffolding?: {
        routeTemplate?: string | undefined;
        lazyRouteTemplate?: string | undefined;
    } | undefined;
    experimental?: {
        enableCodeSplitting?: boolean | undefined;
    } | undefined;
    plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
}> | undefined) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
Was this page helpful?