Skip to content

Getting Started

Prerequisites

Make sure you have ESLint installed in your project and that it's configured to work with TypeScript.

Installation

bash
npm install --save-dev @ts-safeql/eslint-plugin libpg-query

Integrate with ESLint

In order for SafeQL to be able to lint your queries, you need to specify either a databaseUrl or a migrationsDir in your ESLint configuration:

js
// eslint.config.js

import safeql from "@ts-safeql/eslint-plugin/config";
import tseslint from "typescript-eslint";

export default tseslint.config(
  // ...
  safeql.configs.connections({
    // read more about configuration in the next section
    databaseUrl: "postgres://postgres:postgres@localhost:5432/my_database",
    targets: [{ tag: "sql" }],
  })
);

In the next section, you'll learn how to configure your connection(s).