ESLint plugin that enforces safe SQL query practices when using Knex.js, particularly preventing SQL injection by disallowing plain string arguments in raw queries. The current stable version is 0.2.2, released with no recent active development (last update years ago). It offers a single rule, `avoid-injections`, and allows configuration of expected Knex builder variable names. Unlike generic SQL injection linting, this plugin is tailored specifically to Knex's `knex.raw()` method, filling a niche for projects heavily relying on raw queries.
npm install eslint-plugin-knexVerified import paths — ran on the pinned version, not inferred.
Configures ESLint to use the knex plugin and enforce the avoid-injections rule with custom builder name pattern.
Supplement with additional ESLint rules or custom linting as needed.
Consider alternatives or test compatibility with your ESLint/Knex versions.
Ensure all raw queries use template literals or parameterized syntax, or suppress the rule with inline comments where appropriate.
npm install -D eslint-plugin-knex
Use 'knex/avoid-injections' instead of 'avoid-injections'.
Set rule value to 'error', 'warn', or 'off'.