KitQL Documentation

repository·main·Indexed 19 days ago

https://github.com/jycouet/kitql

A collection of standalone libraries and Vite plugins designed to accelerate WebApp development. KitQL includes specialized packages such as @kitql/sveltekit, @kitql/helpers, @kitql/handles, and @kitql/eslint-config, as well as Vite plugins like vite-plugin-kit-routes, vite-plugin-watch-and-run, and vite-plugin-stripper. It features a modular architecture allowing developers to install only the specific tools they need, including a kitql-lint tool that orchestrates eslint, prettier, oxlint, and oxfmt.

Tokens
23.9K
Snippets
104
Records
128
Agent score
60%

What's inside KitQL

  1. What is KitQL?

    main
    KitQL is not a single monolithic library, but rather a collection of standalone libraries and tools designed to speed up WebApp development. Developers can pick and choose specific packages based on their needs rather than installing the entire suite.
  2. Overview of @kitql/handles

    main
    The @kitql/handles package is part of the KitQL ecosystem. KitQL is not a single monolithic library, but rather a collection of standalone libraries designed to work together. @kitql/handles provides specific functionality related to 'Handles' within this ecosystem.
  3. Compatibility with non-GraphQL projects

    main
    KitQL is not strictly tied to GraphQL. While the name might suggest a connection, most KitQL packages are independent of GraphQL and can be used in other types of projects. The 'QL' in KitQL is flexible and can stand for 'Quick Libraries', 'Quick Layer', or 'Quality of Life'.
  4. Configure kitql-lint tools and orchestration

    main

    The kitql-lint tool orchestrates four optional tools. By default, it runs eslint and prettier. You can customize the toolset using the -t flag.

    Available Tools:

    • eslint: Linter (handles Svelte rules, pnpm catalog rules, and custom rules).
    • prettier: Formatter (supports all file types, including .svelte).
    • oxlint: A faster Rust-based linter that covers most JS/TS rules.
    • oxfmt: A faster Rust-based formatter (Note: does not support .svelte files yet).

    Tool Selection Patterns:

    • Default: eslint + prettier.
    • Pure oxc (No Svelte support): Use oxlint and oxfmt.
    • Recommended (Svelte + Full oxc): Use oxlint, tsgolint, oxfmt, eslint, and prettier. When using this combo, enable oxlint integration in your ESLint config to prevent duplicate work on .ts/.js files.
    • Automatic Prettier Restriction: If oxfmt is included in your toolset, prettier automatically restricts its scope to **/*.svelte files, leaving all other file types to oxfmt.
    # Default (eslint + prettier)
    kitql-lint
    
    # Recommended for Svelte (full oxc + svelte support)
    kitql-lint -t oxlint,tsgolint,oxfmt,eslint,prettier
    
    # Pure oxc (no .svelte support)
    kitql-lint -t oxlint,tsgolint,oxfmt
  5. Configure watch patterns with absolute paths and globs

    main

    The watch property can be configured in several ways to target specific files or directories:

    • Glob patterns: Use globs to watch files under the root directory. Always use path.resolve to ensure the pattern matches against the absolute path.
    • Specific files: Use path.resolve with a relative path to watch files outside the current project root (e.g., in a monorepo).
    • Dynamic matching: Provide a function as watch that is called with the filepath, allowing for custom logic to determine if a file should trigger the command.
    // Watch all TypeScript files in the project
    {
      watch: path.resolve('**/*.ts')
    }
    
    // Watch a specific file outside the project root
    {
      watch: path.resolve('../../README.md')
    }
  6. Understanding the KitQL multi-package architecture

    main
    KitQL is distributed as a monorepo containing multiple specialized packages rather than a single monolithic library. This design allows you to install only the specific tools you need without pulling in unnecessary dependencies. Despite being split, all packages are designed to work together seamlessly using common principles.
  7. Configure vite-plugin-kit-routes in Vite

    main

    To enable the plugin, import kitRoutes from vite-plugin-kit-routes and add it to the plugins array in your vite.config.js (or equivalent configuration file).

    import { sveltekit } from '@sveltejs/kit/vite'
    import { kitRoutes } from 'vite-plugin-kit-routes'
    
    /** @type {import('vite').UserConfig} */
    export default config = {
      plugins: [
        sveltekit(),
        // ✅ Add the plugin
        kitRoutes(),
      ],
    }