postgresql-eslint-parser provides a specialized parser for PostgreSQL SQL syntax, enabling ESLint to perform static analysis on `.sql` files or SQL embedded within other codebases. It leverages the `libpg-query` library to convert PostgreSQL SQL into an ESTree-compatible Abstract Syntax Tree (AST), which is the standard format for ESLint. The current stable version is 0.1.8, indicating it's still in its early development stages with minor patch releases for bug fixes and improvements. Its primary differentiation lies in its tight integration with the ESLint ecosystem, offering functions like `parseForESLint` that provide not only the AST but also visitor keys essential for traversing the tree and a scope manager (currently `null`). This allows developers to write custom ESLint rules specifically for PostgreSQL, ensuring SQL code adheres to project-specific style guides and best practices, enhancing code quality and maintainability in projects that utilize PostgreSQL.
npm install postgresql-eslint-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates configuring the parser in an ESLint flat config file to lint SQL files and basic programmatic usage of the parse function.
Upgrade your Node.js environment to version 22.0.0 or newer. Check the `engines` field in `package.json` for precise requirements.
No fix required, but be aware of the change in behavior if upgrading from earlier versions. Ensure your SQL comment directives are correctly formatted if you relied on them being ignored previously.
Monitor release notes (`CHANGELOG.md` or GitHub releases) for each update. Pin exact versions for production use or use a dependency manager like Dependabot to alert you to updates.
In your `eslint.config.js` (flat config), import the parser object and assign it directly: `import postgresqlParser from 'postgresql-eslint-parser'; languageOptions: { parser: postgresqlParser, }`.Ensure the package is installed: `npm install postgresql-eslint-parser` or `yarn add postgresql-eslint-parser`. Verify that the module resolution paths are correct if using a monorepo or custom setup.
Review the SQL statement for correctness against PostgreSQL syntax. The error message usually indicates the approximate location of the syntax issue. This parser is strict about PostgreSQL SQL.
No dependency data recorded yet.