TypeScript · security
no-dynamic-sql
eslint:no-dynamic-sql Disallow runtime interpolation or concatenation in SQL passed to statement-execution methods.
- Default
- error
- Fix
- none
- Languages
- typescript
Why
Embedding runtime values in SQL bypasses driver parameterization and can introduce injection defects or unstable query plans.
Fix
Use SQL placeholders and pass runtime values through the driver's binding API.
Before / after
Executed by this rule’s unit tests.
Before
A runtime value is interpolated into SQL
db.prepare(`select * from users where id = '${userId}'`); After
A runtime value is bound separately
db.prepare('select * from users where id = ?').bind(userId); Limits
- The rule recognizes SQL by syntax and configured method names; static fragments and parameterizing tagged templates are exempt.
Message IDs
dynamicSql