eslint-plugin-safe-kysely is an ESLint plugin designed to improve data safety in applications utilizing the Kysely query builder. Currently at version 1.0.1, this plugin enforces the inclusion of a `where` clause in all `updateTable` and `deleteFrom` Kysely call chains. Its primary goal is to prevent accidental mass data modification or deletion of entire tables by requiring explicit targeting of rows for such operations. Unlike runtime checks, this plugin performs static analysis during development, providing immediate feedback through ESLint warnings or errors before code is deployed. This ensures that potentially destructive database queries are identified and corrected early in the development lifecycle, significantly reducing the risk of data loss. While a specific release cadence is not yet established for this relatively new plugin, its initial stable release indicates a commitment to Kysely ecosystem safety. It differentiates itself by offering Kysely-specific static analysis for a critical aspect of database interaction.
npm install eslint-plugin-safe-kyselyVerified import paths — ran on the pinned version, not inferred.
Demonstrates the installation of the plugin, ESLint configuration to enable the rule, and a Kysely update operation that correctly includes a `where` clause, satisfying the `enforce-where-clause` rule.
Ensure `"safe-kysely"` is included in the `plugins` array in your `.eslintrc.json` or `.eslintrc.js` file.
Always use the full rule identifier, such as `"safe-kysely/enforce-where-clause": "error"`.
Supplement this plugin with manual code reviews or additional static analysis tools for comprehensive database query safety beyond `updateTable` and `deleteFrom`.
Run `npm install eslint-plugin-safe-kysely --save-dev` and ensure `"safe-kysely"` is added to the `plugins` array in your `.eslintrc.json` or `.eslintrc.js` file.
Add a `.where()` method call to your Kysely query chain to specify the rows to be affected, e.g., `.where('id', '=', 1)` or `.where({ foo: 'bar' })`.