Socket
Socket
Sign inDemoInstall

@ts-safeql/eslint-plugin

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-safeql/eslint-plugin - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

24

lib/index.d.ts

@@ -10,3 +10,3 @@ import { defineConfig } from "./rules/check-sql.config";

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -16,4 +16,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
name: string;
migrationsDir: string;
operators: string[];

@@ -25,3 +25,3 @@ } | {

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -31,4 +31,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
tagName: string;
migrationsDir: string;
} | {

@@ -39,3 +39,3 @@ transform?: string | (string | [string, string])[] | undefined;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -50,3 +50,3 @@ name: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -60,3 +60,3 @@ tagName: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -66,4 +66,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
name: string;
migrationsDir: string;
operators: string[];

@@ -75,3 +75,3 @@ } | {

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -81,4 +81,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
tagName: string;
migrationsDir: string;
} | {

@@ -89,3 +89,3 @@ transform?: string | (string | [string, string])[] | undefined;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -100,3 +100,3 @@ name: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -103,0 +103,0 @@ tagName: string;

@@ -13,3 +13,3 @@ import z from "zod";

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -19,4 +19,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
name: string;
migrationsDir: string;
operators: string[];

@@ -28,3 +28,3 @@ } | {

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -34,4 +34,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
tagName: string;
migrationsDir: string;
} | {

@@ -42,3 +42,3 @@ transform?: string | (string | [string, string])[] | undefined;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -53,3 +53,3 @@ name: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -63,3 +63,3 @@ tagName: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -69,4 +69,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
name: string;
migrationsDir: string;
operators: string[];

@@ -78,3 +78,3 @@ } | {

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -84,4 +84,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
tagName: string;
migrationsDir: string;
} | {

@@ -92,3 +92,3 @@ transform?: string | (string | [string, string])[] | undefined;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -103,3 +103,3 @@ name: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -106,0 +106,0 @@ tagName: string;

@@ -173,3 +173,3 @@ "use strict";

const { context, tag, connection, projectDir, typeParameter, baseNode } = params;
return (0, fp_ts_1.pipe)(fp_ts_1.E.Do, fp_ts_1.E.bind("parser", () => fp_ts_1.E.of(utils_1.ESLintUtils.getParserServices(context))), fp_ts_1.E.bind("checker", ({ parser }) => fp_ts_1.E.of(parser.program.getTypeChecker())), fp_ts_1.E.bind("query", ({ parser, checker }) => (0, ts_pg_utils_1.mapTemplateLiteralToQueryText)(tag.quasi, parser, checker)), fp_ts_1.E.bindW("pgParsed", ({ query }) => pgParseQueryE(query)), fp_ts_1.E.bindW("result", ({ query, pgParsed }) => generateSyncE({ query, pgParsed, connection, projectDir })), fp_ts_1.E.fold((error) => {
return (0, fp_ts_1.pipe)(fp_ts_1.E.Do, fp_ts_1.E.bind("parser", () => fp_ts_1.E.of(utils_1.ESLintUtils.getParserServices(context))), fp_ts_1.E.bind("checker", ({ parser }) => fp_ts_1.E.of(parser.program.getTypeChecker())), fp_ts_1.E.bind("query", ({ parser, checker }) => (0, ts_pg_utils_1.mapTemplateLiteralToQueryText)(tag.quasi, parser, checker, params.connection)), fp_ts_1.E.bindW("pgParsed", ({ query }) => pgParseQueryE(query)), fp_ts_1.E.bindW("result", ({ query, pgParsed }) => generateSyncE({ query, pgParsed, connection, projectDir })), fp_ts_1.E.fold((error) => {
return (0, ts_pattern_1.match)(error)

@@ -176,0 +176,0 @@ .with({ _tag: "DuplicateColumnsError" }, (error) => {

@@ -38,2 +38,7 @@ "use strict";

);
CREATE TABLE table_with_date_col (
id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
date_col DATE NOT NULL
);
`);

@@ -283,2 +288,13 @@ ts_eslint_1.RuleTester.describe = mocha_1.describe;

},
{
filename,
options: withConnection(connections.base),
name: "union string literal from function arg",
code: `
type UnionStringLiteral = "a" | "b";
function run(union: UnionStringLiteral) {
conn.query<{ name: string }>(sql\`select name from agency WHERE name = \${union}\`);
}
`,
},
],

@@ -417,2 +433,21 @@ invalid: [

},
{
filename,
options: withConnection(connections.base),
name: "mixed union literals from function arg",
code: `
type UnionStringLiteral = "a" | 1;
function run(union: UnionStringLiteral) {
conn.query<{ name: string }>(sql\`select name from agency WHERE name = \${union}\`);
}
`,
errors: [
{
messageId: "invalidQuery",
data: {
error: "Union types must be of the same type (found string, number)",
},
},
],
},
],

@@ -507,2 +542,13 @@ });

},
{
name: 'with { date: "Date" }',
filename,
options: withConnection(connections.withTagName, {
overrides: { types: { date: "Date" } },
}),
code: `
const date = new Date();
sql<{ id: number }>\`select id from table_with_date_col WHERE date_col = \${date}\`
`,
},
],

@@ -522,2 +568,14 @@ invalid: [

},
{
name: 'comparing a col with `Date` without { date: "Date" }',
filename,
options: withConnection(connections.withTagName, {
overrides: {},
}),
code: `
const date = new Date();
sql<{ id: number }>\`select id from table_with_date_col WHERE date_col = \${date}\`
`,
errors: [{ messageId: "invalidQuery", line: 3, column: 85, endLine: 3, endColumn: 89 }],
},
],

@@ -524,0 +582,0 @@ });

@@ -8,3 +8,3 @@ declare const _default: {

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -14,4 +14,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
name: string;
migrationsDir: string;
operators: string[];

@@ -23,3 +23,3 @@ } | {

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -29,4 +29,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
tagName: string;
migrationsDir: string;
} | {

@@ -37,3 +37,3 @@ transform?: string | (string | [string, string])[] | undefined;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -48,3 +48,3 @@ name: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -58,3 +58,3 @@ tagName: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -64,4 +64,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
name: string;
migrationsDir: string;
operators: string[];

@@ -73,3 +73,3 @@ } | {

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -79,4 +79,4 @@ connectionUrl?: string | undefined;

watchMode?: boolean | undefined;
migrationsDir: string;
tagName: string;
migrationsDir: string;
} | {

@@ -87,3 +87,3 @@ transform?: string | (string | [string, string])[] | undefined;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -98,3 +98,3 @@ name: string;

overrides?: {
types?: Partial<Record<"bigint" | "boolean" | "void" | "text" | "int" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
types?: Partial<Record<"bigint" | "boolean" | "void" | "float" | "date" | "int2" | "int4" | "int8" | "smallint" | "int" | "real" | "float4" | "float8" | "numeric" | "decimal" | "smallserial" | "serial" | "bigserial" | "uuid" | "text" | "varchar" | "char" | "bpchar" | "citext" | "bit" | "bool" | "timestamp" | "timestamptz" | "time" | "timetz" | "interval" | "inet" | "cidr" | "macaddr" | "macaddr8" | "money" | "json" | "jsonb" | "bytea", string>> | undefined;
} | undefined;

@@ -101,0 +101,0 @@ tagName: string;

import { InvalidQueryError } from "@ts-safeql/shared";
import { ParserServices, TSESTree } from "@typescript-eslint/utils";
import ts from "typescript";
import { RuleOptionConnection } from "../rules/check-sql.rule";
import { E } from "./fp-ts";
export declare function mapTemplateLiteralToQueryText(quasi: TSESTree.TemplateLiteral, parser: ParserServices, checker: ts.TypeChecker): E.Right<string> | E.Left<InvalidQueryError>;
export declare function mapTemplateLiteralToQueryText(quasi: TSESTree.TemplateLiteral, parser: ParserServices, checker: ts.TypeChecker, options: RuleOptionConnection): E.Right<string> | E.Left<InvalidQueryError>;

@@ -10,3 +10,3 @@ "use strict";

const fp_ts_1 = require("./fp-ts");
function mapTemplateLiteralToQueryText(quasi, parser, checker) {
function mapTemplateLiteralToQueryText(quasi, parser, checker, options) {
let $idx = 0;

@@ -20,3 +20,3 @@ let $queryText = "";

const expression = quasi.expressions[$idx];
const pgType = (0, fp_ts_1.pipe)(mapExpressionToTsTypeString({ expression, parser, checker }), mapTsTypeStringToPgType);
const pgType = (0, fp_ts_1.pipe)(mapExpressionToTsTypeString({ expression, parser, checker }), (params) => mapTsTypeStringToPgType(Object.assign(Object.assign({}, params), { checker, options })));
if (fp_ts_1.E.isLeft(pgType)) {

@@ -37,3 +37,2 @@ return fp_ts_1.E.left(shared_1.InvalidQueryError.of(pgType.left, expression));

type: tsType,
checker: params.checker,
};

@@ -56,2 +55,12 @@ }

};
const tsFlagToTsTypeStringMap = {
[typescript_1.default.TypeFlags.String]: "string",
[typescript_1.default.TypeFlags.Number]: "number",
[typescript_1.default.TypeFlags.Boolean]: "boolean",
[typescript_1.default.TypeFlags.BigInt]: "bigint",
[typescript_1.default.TypeFlags.NumberLiteral]: "number",
[typescript_1.default.TypeFlags.StringLiteral]: "string",
[typescript_1.default.TypeFlags.BooleanLiteral]: "boolean",
[typescript_1.default.TypeFlags.BigIntLiteral]: "bigint",
};
const tsFlagToPgTypeMap = {

@@ -68,2 +77,3 @@ [typescript_1.default.TypeFlags.String]: "text",

function mapTsTypeStringToPgType(params) {
var _a;
if (params.node.kind === typescript_1.default.SyntaxKind.ConditionalExpression) {

@@ -82,2 +92,14 @@ const whenTrue = params.checker.getTypeAtLocation(params.node.whenTrue);

}
if (params.node.kind === typescript_1.default.SyntaxKind.Identifier) {
const symbol = params.checker.getSymbolAtLocation(params.node);
const type = params.checker.getTypeOfSymbolAtLocation(symbol, params.node);
if (isTsUnionType(type)) {
const isUnionOfTheSameType = type.types.every((t) => t.flags === type.types[0].flags);
const pgType = tsFlagToPgTypeMap[type.types[0].flags];
if (!isUnionOfTheSameType || pgType === undefined) {
return fp_ts_1.E.left(createMixedTypesInUnionErrorMessage(type.types.map((t) => t.flags)));
}
return fp_ts_1.E.right(pgType);
}
}
if (params.node.kind in tsKindToPgTypeMap) {

@@ -98,4 +120,21 @@ return fp_ts_1.E.right(tsKindToPgTypeMap[params.node.kind]);

}
if (((_a = params.options.overrides) === null || _a === void 0 ? void 0 : _a.types) !== undefined) {
const override = Object.entries(params.options.overrides.types)
.map(([key, value]) => ({ pgType: key, tsType: value }))
.find((entry) => entry.tsType === singularType);
if (override !== undefined) {
return isArray ? fp_ts_1.E.right(`${override.pgType}[]`) : fp_ts_1.E.right(override.pgType);
}
}
return fp_ts_1.E.left(`the type "${typeStr}" is not supported`);
}
function isTsUnionType(type) {
return type.flags === typescript_1.default.TypeFlags.Union;
}
function createMixedTypesInUnionErrorMessage(flags) {
const flagsAsText = flags
.map((flag) => { var _a; return (_a = tsFlagToTsTypeStringMap[flag]) !== null && _a !== void 0 ? _a : `unknown (${flag})`; })
.join(", ");
return `Union types must be of the same type (found ${flagsAsText})`;
}
//# sourceMappingURL=ts-pg.utils.js.map
{
"name": "@ts-safeql/eslint-plugin",
"version": "0.0.22",
"version": "0.0.23",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc