Registry / database / eslint-plugin-kysely

eslint-plugin-kysely

JSON →
library1.0.7jsnpmunverified

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-kysely
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-KYSE
E
eslint-plugin-kysely
databasejavascriptv1.0.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugins
{ "plugins": ["kysely"] }
import * as kyselyPlugin from 'eslint-plugin-kysely';
ESLint plugins are activated by adding their short name (`kysely`) to the `plugins` array in the ESLint configuration, not by direct JavaScript `import` statements.
extends
{ "extends": ["plugin:kysely/recommended"] }
import recommendedConfig from 'eslint-plugin-kysely/recommended';
To apply the default recommended set of rules, extend the configuration using the string `plugin:kysely/recommended` within the `extends` array.
rules
{ "rules": { "kysely/enforce-where-clause": "error" } }
import { enforceWhereClause } from 'eslint-plugin-kysely/rules/enforce-where-clause';
Individual rules are configured by their full identifier (`plugin-name/rule-name`) within the `rules` object, allowing custom severity levels.

Installs the plugin and configures ESLint to use the recommended set of rules for Kysely, then demonstrates how to run ESLint.

npm install --save-dev eslint eslint-plugin-kysely // .eslintrc.json { "root": true, "parserOptions": { "ecmaVersion": 2020, "sourceType": "module" }, "extends": [ "eslint:recommended", "plugin:kysely/recommended" ] } // To lint your project files (e.g., .ts, .js): npx eslint . --ext .js,.ts
Debug
Known issues
gotchaThis 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.
fix
Verify that your `package.json` specifies `eslint-plugin-kysely` and not the older `eslint-plugin-kysely-rules`.
affects: >=1.0.0
gotchaThe 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.
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.
affects: >=1.0.0
gotchaWhen 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.
fix
Install `@typescript-eslint/parser` and update your `.eslintrc.*`:
```json
{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "project": "./tsconfig.json"
  }
}
```
affects: >=1.0.0
Errors
Common errors & fixes
ESLint: Definition for rule 'kysely/enforce-where-clause' was not found.
The ESLint plugin is either not installed or not correctly listed in the `plugins` array of your ESLint configuration.
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.
Parsing error: 'import' and 'export' may appear only with 'sourceType: "module"'
Your ESLint configuration is missing or incorrectly configured `parserOptions.sourceType` for ECMAScript modules.
fix
Add or update your `parserOptions` in `.eslintrc.*`:
`"parserOptions": { "ecmaVersion": 2020, "sourceType": "module" }`.
Parsing error: Unexpected token, expected ";" (or similar TypeScript parsing error)
ESLint is trying to parse TypeScript syntax without a TypeScript parser configured, or without `project` specified for type-aware linting.
fix
Install `@typescript-eslint/parser` and configure it in your `.eslintrc.*`:
`"parser": "@typescript-eslint/parser", "parserOptions": { "project": "./tsconfig.json" }`.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
eslintrequiredPeer dependency for any ESLint plugin to function.
Agent activity
7 hits · last 30 days
node
6
Resources
eslint-plugin-kysely — npm install eslint-plugin-kysely · libregistry