{"id":16352,"library":"eslint-plugin-kysely","title":"ESLint Plugin for Kysely","description":"eslint-plugin-kysely is an ESLint plugin designed to enforce safe and best-practice database operations when using the Kysely SQL query builder. It helps developers prevent common SQL-related issues like accidental full table scans by enforcing WHERE clauses, ensures explicit SELECT statements to avoid ambiguity, and prevents ambiguous column references in JOIN queries. The plugin also provides rules for correct Kysely operator usage, such as `is` for null comparisons and `in` for array operations, rather than `=` or `!=`. The current stable version is 1.0.7, indicating an early but stable release. Its release cadence is likely driven by user feedback and Kysely's evolution. A key differentiator is its specific focus on Kysely's API, providing tailored linting for Kysely users rather than generic SQL linting.","status":"active","version":"1.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/sasumaki/eslint-plugin-kysely","tags":["javascript","eslint","eslintplugin","eslint-plugin","kysely"],"install":[{"cmd":"npm install eslint-plugin-kysely","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-kysely","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-kysely","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for any ESLint plugin to function.","package":"eslint","optional":false}],"imports":[{"note":"ESLint plugins are activated by adding their short name (`kysely`) to the `plugins` array in the ESLint configuration, not by direct JavaScript `import` statements.","wrong":"import * as kyselyPlugin from 'eslint-plugin-kysely';","symbol":"plugins","correct":"{\n  \"plugins\": [\"kysely\"]\n}"},{"note":"To apply the default recommended set of rules, extend the configuration using the string `plugin:kysely/recommended` within the `extends` array.","wrong":"import recommendedConfig from 'eslint-plugin-kysely/recommended';","symbol":"extends","correct":"{\n  \"extends\": [\"plugin:kysely/recommended\"]\n}"},{"note":"Individual rules are configured by their full identifier (`plugin-name/rule-name`) within the `rules` object, allowing custom severity levels.","wrong":"import { enforceWhereClause } from 'eslint-plugin-kysely/rules/enforce-where-clause';","symbol":"rules","correct":"{\n  \"rules\": {\n    \"kysely/enforce-where-clause\": \"error\"\n  }\n}"}],"quickstart":{"code":"npm install --save-dev eslint eslint-plugin-kysely\n\n// .eslintrc.json\n{\n  \"root\": true,\n  \"parserOptions\": {\n    \"ecmaVersion\": 2020,\n    \"sourceType\": \"module\"\n  },\n  \"extends\": [\n    \"eslint:recommended\",\n    \"plugin:kysely/recommended\"\n  ]\n}\n\n// To lint your project files (e.g., .ts, .js):\nnpx eslint . --ext .js,.ts","lang":"typescript","description":"Installs the plugin and configures ESLint to use the recommended set of rules for Kysely, then demonstrates how to run ESLint."},"warnings":[{"fix":"Verify that your `package.json` specifies `eslint-plugin-kysely` and not the older `eslint-plugin-kysely-rules`.","message":"This plugin is a fork of `eslint-plugin-kysely-rules`. Users should ensure they are installing `eslint-plugin-kysely` to get the latest features and updates from this specific project. Installing the incorrect package may lead to outdated rules or unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Apply Kysely-specific rules only to codebases that extensively use Kysely. Review rule configurations to disable those that don't fit your specific Kysely usage patterns if necessary.","message":"The plugin's rules are designed for Kysely's specific API. Attempting to use these rules on raw SQL strings or other ORMs/query builders will not yield meaningful results and may produce false positives or negatives. Ensure your codebase primarily uses Kysely for database operations where these rules are applied.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install `@typescript-eslint/parser` and update your `.eslintrc.*`:\n```json\n{\n  \"parser\": \"@typescript-eslint/parser\",\n  \"parserOptions\": {\n    \"ecmaVersion\": 2020,\n    \"sourceType\": \"module\",\n    \"project\": \"./tsconfig.json\"\n  }\n}\n```","message":"When using Kysely in a TypeScript project, ensure your ESLint configuration includes a TypeScript parser (e.g., `@typescript-eslint/parser`) and the relevant `parserOptions` to correctly parse Kysely's type-safe query syntax. Without this, ESLint may fail to parse your files or apply rules correctly.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure `eslint-plugin-kysely` is installed (`npm install --save-dev eslint-plugin-kysely`) and add `\"kysely\"` to the `plugins` array in your `.eslintrc.*` file.","cause":"The ESLint plugin is either not installed or not correctly listed in the `plugins` array of your ESLint configuration.","error":"ESLint: Definition for rule 'kysely/enforce-where-clause' was not found."},{"fix":"Add or update your `parserOptions` in `.eslintrc.*`:\n`\"parserOptions\": { \"ecmaVersion\": 2020, \"sourceType\": \"module\" }`.","cause":"Your ESLint configuration is missing or incorrectly configured `parserOptions.sourceType` for ECMAScript modules.","error":"Parsing error: 'import' and 'export' may appear only with 'sourceType: \"module\"'"},{"fix":"Install `@typescript-eslint/parser` and configure it in your `.eslintrc.*`:\n`\"parser\": \"@typescript-eslint/parser\", \"parserOptions\": { \"project\": \"./tsconfig.json\" }`.","cause":"ESLint is trying to parse TypeScript syntax without a TypeScript parser configured, or without `project` specified for type-aware linting.","error":"Parsing error: Unexpected token, expected \";\" (or similar TypeScript parsing error)"}],"ecosystem":"npm"}