sonarjs/sql-queries
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/sql-queries": "error",
},
},
];SQL queries should not be dynamically formatted
The documentation shows no incorrect example for this rule.
// === MySQL ===
const mysql = require('mysql');
const mycon = mysql.createConnection({ host: host, user: user, password: pass, database: db });
mycon.connect(function(err) {
mycon.query('SELECT name FROM users WHERE id = ?', [userinput], (err, res) => {});
});
// === PostgreSQL ===
const pg = require('pg');
const pgcon = new pg.Client({ host: host, user: user, password: pass, database: db });
pgcon.connect();
pgcon.query('SELECT name FROM users WHERE id = $1', [userinput], (err, res) => {});Examples from the ESLint documentation.
sonarjs/sql-queries
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/sql-queries": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Regular expressions should not cause catastrophic backtracking
Single-character alternations in regular expressions should be replaced with character classes
Regular expressions with the global flag should be used with caution
Character classes in regular expressions should not contain only one character
HTTP Strict-Transport-Security policy should not be disabled