@capriza/eslint-plugin-safe-sql

1.2.0 • Public • Published

eslint-plugin-safe-sql

ESLint plugin to enforce the use of the SQL template tag from the library https://github.com/capriza/safe-sql. The SQL template tag from safe-sql transforms the sql query in a template to a safe sql query with bound parameters for use with Sequelize.

Installation

$ npm install --save-dev @capriza/eslint-plugin-safe-sql

Usage

Add the following to your .eslint.json file:

"plugins": ["@capriza/safe-sql"],
"rules": {"@capriza/safe-sql/no-unsafe-sql": "error"}

no-unsafe-sql rule

Forbids the use of raw SQL in string literals or untagged templates, requiring the use of the SQL template tag.

Examples

const SQL = require("safe-sql");

const table = "users";
var query = "SELECT * FROM " + table; // this will generate eslint error
sequelize.query(`SELECT * FROM ${table}`); // this will generate eslint error
sequelize.query(SQL`SELECT * FROM ${table}`); // this will NOT generate eslint error

Readme

Keywords

none

Package Sidebar

Install

npm i @capriza/eslint-plugin-safe-sql

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

4.17 kB

Total Files

4

Last publish

Collaborators

  • raz.yahkovnia
  • adirafael
  • hadar.ple
  • matan.rozen
  • reuvens
  • maayannoyhalevi
  • orevron
  • connector-dev
  • capriza-devops
  • idoish
  • nof558
  • blankg
  • sagimonza
  • doron.oded
  • fujifish