{"id":19948,"library":"eslint-plugin-sql","title":"eslint-plugin-sql","description":"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.","status":"active","version":"3.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/gajus/eslint-plugin-sql","tags":["javascript","eslint","plugin","sql","typescript"],"install":[{"cmd":"npm install eslint-plugin-sql","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-sql","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-sql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to run plugin","package":"eslint","optional":true}],"imports":[{"note":"ESM default import; CommonJS users use require('eslint-plugin-sql')","symbol":"default","correct":"import eslintPluginSql from 'eslint-plugin-sql'"},{"note":"rules is a named export, not a subpath","wrong":"import { rules } from 'eslint-plugin-sql/rules'","symbol":"rules","correct":"import { rules } from 'eslint-plugin-sql'"},{"note":"configs is the named export, singular 'config' does not exist","wrong":"import { config } from 'eslint-plugin-sql'","symbol":"configs","correct":"import { configs } from 'eslint-plugin-sql'"}],"quickstart":{"code":"// .eslintrc.cjs\nmodule.exports = {\n  plugins: ['sql'],\n  rules: {\n    'sql/format': [2, { ignoreExpressions: false, ignoreInline: true, ignoreTagless: true }],\n    'sql/no-unsafe-query': [2, { allowLiteral: false }],\n  },\n};","lang":"javascript","description":"Configures ESLint with sql plugin, enabling format and no-unsafe-query rules."},"warnings":[{"fix":"Upgrade Node to >=18","message":"Minimum Node version changed to 18 in v3.0.0","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade ESLint to >=8.1.0","message":"Peer dependency eslint changed to >=8.1.0 in v3.0.0","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Remove 'ignoreStartWithNewLine' from rule options","message":"The 'sql/format' rule option 'ignoreStartWithNewLine' is deprecated and will be removed in a future version","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Add { ignoreTagless: false } to rule options","message":"The plugin only detects SQL in template literals tagged with 'sql' by default; set 'ignoreTagless: false' to detect all template literals","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add settings: { sql: { placeholderRule: '\\\\?' } } to ESLint config","message":"Placeholders like '?' make the SQL invalid; you must set 'placeholderRule' in settings to match them","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set 'allowLiteral: true' explicitly if you want to allow literal strings","message":"Rule 'sql/no-unsafe-query' option 'allowLiteral' changed default from true to false in v3.0.0","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install eslint-plugin-sql --save-dev' and add 'plugins: [\"sql\"]' to ESLint config.","cause":"Plugin not installed or not added to plugins array.","error":"Definition for rule 'sql/format' was not found."},{"fix":"Use array format: 'sql/format': [2, {}] instead of 'sql/format': {}","cause":"Rule options passed as second argument but not wrapped in an array.","error":"Expected a plain object but got 'undefined'."},{"fix":"Ensure 'eslint-plugin-sql' is in node_modules and ESLint dependencies are correct.","cause":"Plugin not installed or ESLint cannot resolve it.","error":"Cannot find module 'eslint-plugin-sql'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}