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.
npm install eslint-plugin-kyselyVerified import paths — ran on the pinned version, not inferred.
Installs the plugin and configures ESLint to use the recommended set of rules for Kysely, then demonstrates how to run ESLint.
Verify that your `package.json` specifies `eslint-plugin-kysely` and not the older `eslint-plugin-kysely-rules`.
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.
Install `@typescript-eslint/parser` and update your `.eslintrc.*`:
```json
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json"
}
}
```Ensure `eslint-plugin-kysely` is installed (`npm install --save-dev eslint-plugin-kysely`) and add `"kysely"` to the `plugins` array in your `.eslintrc.*` file.
Add or update your `parserOptions` in `.eslintrc.*`:
`"parserOptions": { "ecmaVersion": 2020, "sourceType": "module" }`.Install `@typescript-eslint/parser` and configure it in your `.eslintrc.*`:
`"parser": "@typescript-eslint/parser", "parserOptions": { "project": "./tsconfig.json" }`.