Registry / testing / eslint-plugin-sql

eslint-plugin-sql

JSON →
library3.4.1jsnpmunverified

ESLint plugin providing SQL linting rules, including formatting via sql-formatter and unsafe query detection. Version 3.4.1 is current, with active development. It supports Postgres and uses template literal tags (default `` sql `` ) to identify SQL. Requires ESLint >=8.1.0 and Node >=18. Differentiated by its focus on safety (no-unsafe-query) and auto-fix formatting. Ships TypeScript types.

npm install eslint-plugin-sql
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-SQL
E
eslint-plugin-sql
testingjavascriptv3.4.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import eslintPluginSql from 'eslint-plugin-sql'
ESM default import; CommonJS users use require('eslint-plugin-sql')
rules
import { rules } from 'eslint-plugin-sql'
import { rules } from 'eslint-plugin-sql/rules'
rules is a named export, not a subpath
configs
import { configs } from 'eslint-plugin-sql'
import { config } from 'eslint-plugin-sql'
configs is the named export, singular 'config' does not exist

Configures ESLint with sql plugin, enabling format and no-unsafe-query rules.

// .eslintrc.cjs module.exports = { plugins: ['sql'], rules: { 'sql/format': [2, { ignoreExpressions: false, ignoreInline: true, ignoreTagless: true }], 'sql/no-unsafe-query': [2, { allowLiteral: false }], }, };
Debug
Known issues
breakingMinimum Node version changed to 18 in v3.0.0
fix
Upgrade Node to >=18
affects: >=3.0.0
breakingPeer dependency eslint changed to >=8.1.0 in v3.0.0
fix
Upgrade ESLint to >=8.1.0
affects: >=3.0.0
deprecatedThe 'sql/format' rule option 'ignoreStartWithNewLine' is deprecated and will be removed in a future version
fix
Remove 'ignoreStartWithNewLine' from rule options
affects: >=3.0.0
gotchaThe plugin only detects SQL in template literals tagged with 'sql' by default; set 'ignoreTagless: false' to detect all template literals
fix
Add { ignoreTagless: false } to rule options
affects: >=1.0.0
gotchaPlaceholders like '?' make the SQL invalid; you must set 'placeholderRule' in settings to match them
fix
Add settings: { sql: { placeholderRule: '\\?' } } to ESLint config
affects: >=1.0.0
breakingRule 'sql/no-unsafe-query' option 'allowLiteral' changed default from true to false in v3.0.0
fix
Set 'allowLiteral: true' explicitly if you want to allow literal strings
affects: >=3.0.0
Errors
Common errors & fixes
Definition for rule 'sql/format' was not found.
Plugin not installed or not added to plugins array.
fix
Run 'npm install eslint-plugin-sql --save-dev' and add 'plugins: ["sql"]' to ESLint config.
Expected a plain object but got 'undefined'.
Rule options passed as second argument but not wrapped in an array.
fix
Use array format: 'sql/format': [2, {}] instead of 'sql/format': {}
Cannot find module 'eslint-plugin-sql'
Plugin not installed or ESLint cannot resolve it.
fix
Ensure 'eslint-plugin-sql' is in node_modules and ESLint dependencies are correct.
Upgrade
Version history
3.4.1latest on npm
Audit
Dependencies
eslintoptionalpeer dependency required to run plugin
Agent activity
7 hits · last 30 days
node
6
Resources
eslint-plugin-sql — npm install eslint-plugin-sql · libregistry