Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"editor.tabSize": 2,
"prettier.printWidth": 100,
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
14 changes: 7 additions & 7 deletions demos/basic-migrations-raw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"lint!": "eslint src --fix"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"typescript": "^4.8.2"
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"eslint": "^8.30.0",
"typescript": "^4.9.4"
},
"dependencies": {
"@ts-safeql-demos/shared": "workspace:*",
"@ts-safeql/eslint-plugin": "workspace:*",
"postgres": "^3.3.0"
"@ts-safeql-demos/shared": "workspace:0.0.0",
"@ts-safeql/eslint-plugin": "workspace:0.0.23",
"postgres": "^3.3.2"
}
}
18 changes: 9 additions & 9 deletions demos/basic-transform-type/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"lint!": "eslint src --fix"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"tsx": "^3.9.0",
"typescript": "^4.8.2"
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"eslint": "^8.30.0",
"tsx": "^3.12.1",
"typescript": "^4.9.4"
},
"dependencies": {
"@ts-safeql-demos/shared": "workspace:*",
"@ts-safeql/eslint-plugin": "workspace:*",
"@types/node": "^18.7.16",
"postgres": "^3.3.0"
"@ts-safeql-demos/shared": "workspace:0.0.0",
"@ts-safeql/eslint-plugin": "workspace:0.0.23",
"@types/node": "^18.11.18",
"postgres": "^3.3.2"
}
}
18 changes: 9 additions & 9 deletions demos/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"lint!": "eslint src --fix"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"tsx": "^3.9.0",
"typescript": "^4.8.2"
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"eslint": "^8.30.0",
"tsx": "^3.12.1",
"typescript": "^4.9.4"
},
"dependencies": {
"@ts-safeql-demos/shared": "workspace:*",
"@ts-safeql/eslint-plugin": "workspace:*",
"@types/node": "^18.7.16",
"postgres": "^3.3.0"
"@ts-safeql-demos/shared": "workspace:0.0.0",
"@ts-safeql/eslint-plugin": "workspace:0.0.23",
"@types/node": "^18.11.18",
"postgres": "^3.3.2"
}
}
16 changes: 8 additions & 8 deletions demos/big-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"lint!": "eslint src --fix"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"tsx": "^3.9.0",
"typescript": "^4.8.2"
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"eslint": "^8.30.0",
"tsx": "^3.12.1",
"typescript": "^4.9.4"
},
"dependencies": {
"@ts-safeql/eslint-plugin": "workspace:*",
"@types/node": "^18.7.16",
"postgres": "^3.3.0"
"@ts-safeql/eslint-plugin": "workspace:0.0.23",
"@types/node": "^18.11.18",
"postgres": "^3.3.2"
}
}
16 changes: 8 additions & 8 deletions demos/from-config-file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"lint!": "eslint src --fix"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"tsx": "^3.9.0",
"typescript": "^4.8.2"
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"eslint": "^8.30.0",
"tsx": "^3.12.1",
"typescript": "^4.9.4"
},
"dependencies": {
"@ts-safeql/eslint-plugin": "workspace:*",
"@types/node": "^18.7.16",
"postgres": "^3.3.0"
"@ts-safeql/eslint-plugin": "workspace:0.0.23",
"@types/node": "^18.11.18",
"postgres": "^3.3.2"
}
}
14 changes: 7 additions & 7 deletions demos/multi-connections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"lint!": "eslint src --fix"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"typescript": "^4.8.2"
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"eslint": "^8.30.0",
"typescript": "^4.9.4"
},
"dependencies": {
"@ts-safeql-demos/shared": "workspace:*",
"@ts-safeql/eslint-plugin": "workspace:*",
"postgres": "^3.3.0"
"@ts-safeql-demos/shared": "workspace:0.0.0",
"@ts-safeql/eslint-plugin": "workspace:0.0.23",
"postgres": "^3.3.2"
}
}
18 changes: 9 additions & 9 deletions demos/postgresjs-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"lint!": "eslint src --fix"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"tsx": "^3.9.0",
"typescript": "^4.8.2"
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"eslint": "^8.30.0",
"tsx": "^3.12.1",
"typescript": "^4.9.4"
},
"dependencies": {
"@ts-safeql-demos/shared": "workspace:*",
"@ts-safeql/eslint-plugin": "workspace:*",
"@types/node": "^18.7.16",
"postgres": "^3.3.0"
"@ts-safeql-demos/shared": "workspace:0.0.0",
"@ts-safeql/eslint-plugin": "workspace:0.0.23",
"@types/node": "^18.11.18",
"postgres": "^3.3.2"
}
}
18 changes: 12 additions & 6 deletions demos/postgresjs-demo/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import postgres from "postgres";

export async function check(id: number) {
const sql = postgres();
const sql = postgres();

sql<{ id: number }[]>`SELECT id FROM person`;
const bt = 5;

type Person = { id: number };
sql<Person[]>`SELECT id FROM person WHERE id = ${id}`;
}
export const personColsFrag = sql`
id, name
`;

const q = sql<{ id: number; name: string; }[]>`
SELECT ${personColsFrag}
FROM
starship
GROUP BY ${personColsFrag}
`;
12 changes: 6 additions & 6 deletions demos/prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"clean": "rm -rf lib"
},
"devDependencies": {
"@ts-safeql/eslint-plugin": "workspace:*",
"@types/node": "^18.7.16",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"@ts-safeql/eslint-plugin": "workspace:0.0.23",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"conditional-type-checks": "1.0.6",
"eslint": "^8.23.0",
"eslint": "^8.30.0",
"tsx": "3.9.0",
"typescript": "^4.8.2"
"typescript": "^4.9.4"
},
"dependencies": {
"@prisma/client": "4.2.0",
Expand Down
6 changes: 3 additions & 3 deletions demos/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "@ts-safeql-demos/shared",
"version": "0.0.0",
"devDependencies": {
"typescript": "^4.8.2"
"typescript": "^4.9.4"
},
"dependencies": {
"@types/node": "^18.7.16",
"postgres": "^3.3.0"
"@types/node": "^18.11.18",
"postgres": "^3.3.2"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"node": "18.x"
},
"devDependencies": {
"@changesets/cli": "^2.24.4",
"prettier": "^2.7.1",
"turbo": "^1.4.6",
"typescript": "^4.8.2"
"@changesets/cli": "^2.26.0",
"prettier": "^2.8.1",
"turbo": "^1.6.3",
"typescript": "^4.9.4"
},
"packageManager": "[email protected]"
}
28 changes: 14 additions & 14 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@
"devDependencies": {
"@esbuild-kit/cjs-loader": "2.3.3",
"@types/mocha": "9.1.1",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"esbuild-register": "^3.3.3",
"eslint": "^8.23.0",
"libpg-query": "^13.2.5",
"mocha": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"esbuild-register": "^3.4.2",
"eslint": "^8.30.0",
"libpg-query": "^13.3.1",
"mocha": "^10.2.0",
"tsx": "3.9.0",
"typescript": "^4.8.2"
"typescript": "^4.9.4"
},
"dependencies": {
"@ts-safeql/generate": "workspace:0.0.9",
"@ts-safeql/shared": "workspace:0.0.6",
"@ts-safeql/test-utils": "workspace:0.0.6",
"@typescript-eslint/utils": "^5.36.2",
"@typescript-eslint/utils": "^5.47.1",
"chokidar": "^3.5.3",
"esbuild": "0.15.7",
"fp-ts": "^2.12.3",
"fp-ts": "^2.13.1",
"pg-connection-string": "2.5.0",
"postgres": "^3.3.0",
"recast": "^0.21.2",
"postgres": "^3.3.2",
"recast": "^0.21.5",
"synckit": "^0.8.4",
"ts-pattern": "^4.0.5",
"zod": "^3.19.0",
"zod-to-json-schema": "^3.17.1"
"ts-pattern": "^4.0.6",
"zod": "^3.20.2",
"zod-to-json-schema": "^3.20.1"
},
"peerDependencies": {
"libpg-query": "^13.2.5"
Expand Down
8 changes: 6 additions & 2 deletions packages/eslint-plugin/src/rules/check-sql.rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { E, flow, J, pipe } from "../utils/fp-ts";
import { getTypeProperties, toInlineLiteralTypeString } from "../utils/get-type-properties";
import { memoize } from "../utils/memoize";
import { locateNearestPackageJsonDir } from "../utils/node.utils";
import { mapTemplateLiteralToQueryText } from "../utils/ts-pg.utils";
import { isSqlFragmentByTemplateExpression, mapTemplateLiteralToQueryText } from "../utils/ts-pg.utils";
import { getConfigFromFileWithContext } from "./check-sql.config";
import {
reportBaseError,
Expand Down Expand Up @@ -262,6 +262,10 @@ function reportCheck(params: {
}) {
const { context, tag, connection, projectDir, typeParameter, baseNode } = params;

if (isSqlFragmentByTemplateExpression(tag)) {
return;
}

return pipe(
E.Do,
E.bind("parser", () => E.of(ESLintUtils.getParserServices(context))),
Expand Down Expand Up @@ -474,7 +478,7 @@ export default createRule({
},
messages: messages,
type: "problem",
schema: zodToJsonSchema(RuleOptions, { target: "openApi3" }),
schema: zodToJsonSchema(RuleOptions, { target: "openApi3" }) as object,
},
defaultOptions: [],
create(context) {
Expand Down
Loading