diff --git a/.eslintrc.json b/.eslintrc.json index 4a5ed74a..d4a3b1ff 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,5 @@ { - "ignorePatterns": ["src/parser.ts"], + "ignorePatterns": ["src/parser.js", "src/parser.d.ts", "peggy-config.*"], "env": { "es2021": true }, diff --git a/.gitignore b/.gitignore index 08bd1c76..c9e297a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules lib -src/parser.ts +src/parser.js +src/parser.d.ts .claude +build diff --git a/package-lock.json b/package-lock.json index 1561654f..d2913384 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,11 +20,10 @@ "eslint-config-prettier": "^9.1.0", "jest": "^30.3.0", "npm-watch": "^0.11.0", - "peggy": "^3.0.2", + "peggy": "^4.2.0", "prettier": "^2.7.1", "ts-jest": "^29.0.3", "ts-node": "^10.9.1", - "ts-pegjs": "4.2.1", "typescript": "^5.9.3" } }, @@ -1670,6 +1669,32 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@peggyjs/from-mem": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@peggyjs/from-mem/-/from-mem-1.3.5.tgz", + "integrity": "sha512-oRyzXE7nirAn+5yYjCdWQHg3EG2XXcYRoYNOK8Quqnmm+9FyK/2YWVunwudlYl++M3xY+gIAdf0vAYS+p0nKfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "7.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@peggyjs/from-mem/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -1721,35 +1746,6 @@ "@sinonjs/commons": "^3.0.1" } }, - "node_modules/@ts-morph/common": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.19.0.tgz", - "integrity": "sha512-Unz/WHmd4pGax91rdIKWi51wnVUW11QttMEPpBiBgIewnc9UQIX7UDLxr5vRlqeByXCwhkF6VabSsI0raWcyAQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-glob": "^3.2.12", - "minimatch": "^7.4.3", - "mkdirp": "^2.1.6", - "path-browserify": "^1.0.1" - } - }, - "node_modules/@ts-morph/common/node_modules/minimatch": { - "version": "7.4.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.9.tgz", - "integrity": "sha512-Brg/fp/iAVDOQoHxkuN5bEYhyQlZhxddI78yWsCbeEwTHXQjlNLtiJDUsp1GIptVqMI7/gkJMz4vVAc01mpoBw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@tsconfig/node10": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.13.tgz", @@ -2972,13 +2968,6 @@ "node": ">= 0.12.0" } }, - "node_modules/code-block-writer": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-12.0.0.tgz", - "integrity": "sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==", - "dev": true, - "license": "MIT" - }, "node_modules/collect-v8-coverage": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.3.tgz", @@ -5061,22 +5050,6 @@ "node": ">=16 || 14 >=14.17" } }, - "node_modules/mkdirp": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-2.1.6.tgz", - "integrity": "sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==", - "dev": true, - "license": "MIT", - "bin": { - "mkdirp": "dist/cjs/src/bin.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -5410,13 +5383,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/path-browserify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", - "dev": true, - "license": "MIT" - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -5485,30 +5451,31 @@ } }, "node_modules/peggy": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/peggy/-/peggy-3.0.2.tgz", - "integrity": "sha512-n7chtCbEoGYRwZZ0i/O3t1cPr6o+d9Xx4Zwy2LYfzv0vjchMBU0tO+qYYyvZloBPcgRgzYvALzGWHe609JjEpg==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/peggy/-/peggy-4.2.0.tgz", + "integrity": "sha512-ZjzyJYY8NqW8JOZr2PbS/J0UH/hnfGALxSDsBUVQg5Y/I+ZaPuGeBJ7EclUX2RvWjhlsi4pnuL1C/K/3u+cDeg==", "dev": true, "license": "MIT", "dependencies": { - "commander": "^10.0.0", + "@peggyjs/from-mem": "1.3.5", + "commander": "^12.1.0", "source-map-generator": "0.8.0" }, "bin": { "peggy": "bin/peggy.js" }, "engines": { - "node": ">=14" + "node": ">=18" } }, "node_modules/peggy/node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", + "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", "dev": true, "license": "MIT", "engines": { - "node": ">=14" + "node": ">=18" } }, "node_modules/picocolors": { @@ -6435,17 +6402,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/ts-morph": { - "version": "18.0.0", - "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-18.0.0.tgz", - "integrity": "sha512-Kg5u0mk19PIIe4islUI/HWRvm9bC1lHejK4S0oh1zaZ77TMZAEmQC0sHQYiu2RgCQFZKXz1fMVi/7nOOeirznA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@ts-morph/common": "~0.19.0", - "code-block-writer": "^12.0.0" - } - }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", @@ -6490,23 +6446,6 @@ } } }, - "node_modules/ts-pegjs": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ts-pegjs/-/ts-pegjs-4.2.1.tgz", - "integrity": "sha512-mK/O2pu6lzWUeKpEMA/wsa0GdYblfjJI1y0s0GqH6xCTvugQDOWPJbm5rY6AHivpZICuXIriCb+a7Cflbdtc2w==", - "dev": true, - "license": "MIT", - "dependencies": { - "prettier": "^2.8.8", - "ts-morph": "^18.0.0" - }, - "bin": { - "tspegjs": "dist/cli.mjs" - }, - "peerDependencies": { - "peggy": "^3.0.2" - } - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index a6715eed..bc337976 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,12 @@ "pretty": "prettier --write .", "add:keyword": "ts-node ./scripts/add-keyword.ts", "add:template": "ts-node ./scripts/add-template.ts", - "generate": "ts-node ./scripts/generate.ts", - "generate:fast": "ts-node ./scripts/generate.ts --fast", + "generate": "npm run build:plugins && peggy -c peggy-config.mjs", + "generate:fast": "peggy -c peggy-config.fast.mjs", "watch:generate": "npm-watch", - "clean": "rm -rf lib; rm -rf src/generated_parser.ts", - "build": "npm run clean && npm run generate && tsc -p tsconfig.build.json", + "clean": "rm -rf lib; rm -f src/parser.js src/parser.d.ts", + "build": "npm run clean && npm run generate && tsc -p tsconfig.build.json && cp src/parser.d.ts lib/parser.d.ts", + "build:plugins": "tsc -p tsconfig.plugins.json", "test:bigquery": "jest --config test/config/bigquery.json", "test:mysql": "jest --config test/config/mysql.json", "test:mariadb": "jest --config test/config/mariadb.json", @@ -57,11 +58,10 @@ "eslint-config-prettier": "^9.1.0", "jest": "^30.3.0", "npm-watch": "^0.11.0", - "peggy": "^3.0.2", + "peggy": "^4.2.0", "prettier": "^2.7.1", "ts-jest": "^29.0.3", "ts-node": "^10.9.1", - "ts-pegjs": "4.2.1", "typescript": "^5.9.3" }, "watch": { diff --git a/peggy-config.fast.mjs b/peggy-config.fast.mjs new file mode 100644 index 00000000..0a6785f8 --- /dev/null +++ b/peggy-config.fast.mjs @@ -0,0 +1,10 @@ +import { moveImports } from "./build/plugins/move-imports.js"; +import { ruleTemplates } from "./build/plugins/rule-templates.js"; +import { disableRecursionCheck } from "./build/plugins/disable-recusion-check.js"; + +export default { + dts: true, + format: "es", + input: "src/parser.pegjs", + plugins: [moveImports, ruleTemplates, disableRecursionCheck], +}; diff --git a/peggy-config.mjs b/peggy-config.mjs new file mode 100644 index 00000000..a827d97a --- /dev/null +++ b/peggy-config.mjs @@ -0,0 +1,9 @@ +import { moveImports } from "./build/plugins/move-imports.js"; +import { ruleTemplates } from "./build/plugins/rule-templates.js"; + +export default { + dts: true, + format: "es", + input: "src/parser.pegjs", + plugins: [moveImports, ruleTemplates], +}; diff --git a/scripts/disable-recusion-check.ts b/scripts/disable-recusion-check.ts index dfe08ccf..fd85ef0a 100644 --- a/scripts/disable-recusion-check.ts +++ b/scripts/disable-recusion-check.ts @@ -7,11 +7,9 @@ import { Plugin } from "peggy"; * See: https://github.com/peggyjs/peggy/issues/457 */ export const disableRecursionCheck: Plugin = { - use(config, options) { - if (options.disableRecursionCheck) { - config.passes.check = config.passes.check.filter( - (pass) => pass.name !== "reportInfiniteRecursion" - ); - } + use(config) { + config.passes.check = config.passes.check.filter( + (pass) => pass.name !== "reportInfiniteRecursion" + ); }, }; diff --git a/scripts/generate.ts b/scripts/generate.ts deleted file mode 100644 index 2d7750ed..00000000 --- a/scripts/generate.ts +++ /dev/null @@ -1,28 +0,0 @@ -import peggy from "peggy"; -import tspegjs from "ts-pegjs"; -import fs from "fs"; -import path from "path"; -import { moveImports } from "./move-imports"; -import { ruleTemplates } from "./rule-templates"; -import { disableRecursionCheck } from "./disable-recusion-check"; - -const source = fs.readFileSync( - path.resolve(__dirname, "../src/parser.pegjs"), - "utf-8" -); - -console.log(`Generating parser...`); - -const parser = peggy.generate(source, { - plugins: [tspegjs, moveImports, ruleTemplates, disableRecursionCheck], - output: "source", - format: "commonjs", - tspegjs: { - // The type inference is pretty slow and we don't really rely on this feature. - // At the time of writing, it adds about 30 seconds to the build time. - skipTypeComputation: true, - }, - disableRecursionCheck: process.argv.includes("--fast"), -} as peggy.SourceBuildOptions<"source">); - -fs.writeFileSync(path.resolve(__dirname, `../src/parser.ts`), parser); diff --git a/scripts/move-imports.ts b/scripts/move-imports.ts index 8a20c167..bef7b8f0 100644 --- a/scripts/move-imports.ts +++ b/scripts/move-imports.ts @@ -18,11 +18,20 @@ const removeImportsPass: Pass = (ast) => { if (!ast.initializer) { return; } - const code = ast.initializer.code; + + const code = + ast.initializer instanceof Array + ? ast.initializer[0].code + : ast.initializer.code; imports = code.match(IMPORT_REGEX) || []; const withoutImports = code.replace(IMPORT_REGEX, ""); - ast.initializer.code = withoutImports; + + if (ast.initializer instanceof Array) { + ast.initializer[0].code = withoutImports; + } else { + ast.initializer.code = withoutImports; + } }; const addImportsPass: Pass = (ast) => { diff --git a/src/FormattedSyntaxError.ts b/src/FormattedSyntaxError.ts index 720c5f9c..3e1cb970 100644 --- a/src/FormattedSyntaxError.ts +++ b/src/FormattedSyntaxError.ts @@ -1,4 +1,4 @@ -import { Expectation, PeggySyntaxError } from "./parser"; +import { Expectation, SyntaxError as PeggySyntaxError } from "./parser"; export class FormattedSyntaxError extends Error { constructor(e: PeggySyntaxError, sql: string, filename?: string) { @@ -29,11 +29,11 @@ ${indent} | ${"^".padStart(colNr)}`; // When we stopped at a single letter, display the whole word instead function expandFound( - found: string | null, + found: string | null | undefined, colNr: number, line: string -): string | null { - if (found !== null && /^\w$/.test(found)) { +): string | null | undefined { + if (found !== null && found !== undefined && /^\w$/.test(found)) { const [word] = line.slice(colNr - 1).match(/\w+/) || []; return word || null; } @@ -48,7 +48,7 @@ function expandFound( /* eslint-disable no-control-regex */ /* eslint-disable no-case-declarations */ -function describeFound(found1: string | null) { +function describeFound(found1: string | null | undefined) { return found1 ? '"' + literalEscape(found1) + '"' : "end of input"; } @@ -92,9 +92,7 @@ function describeExpectation(expectation: Expectation) { case "class": const escapedParts = expectation.parts.map((part) => { return Array.isArray(part) - ? classEscape(part[0] as string) + - "-" + - classEscape(part[1] as string) + ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part); }); diff --git a/src/main.ts b/src/main.ts index 706d4d0f..814a35c8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ export { type DialectName, type ParserOptions } from "./ParserOptions"; export { FormattedSyntaxError } from "./FormattedSyntaxError"; import { Node, Program } from "./cst/Node"; -import { parse as parseSql, PeggySyntaxError } from "./parser"; +import { parse as parseSql, SyntaxError as PeggySyntaxError } from "./parser"; import { show as showSql } from "./show"; import { ParserOptions, validDialectNames } from "./ParserOptions"; import { FormattedSyntaxError } from "./FormattedSyntaxError"; diff --git a/src/parser.pegjs b/src/parser.pegjs index 95bcc14a..24f0254b 100644 --- a/src/parser.pegjs +++ b/src/parser.pegjs @@ -691,7 +691,7 @@ join_expr join_expr_right = c1:__ op:"," right:(__ alias$table_factor) { - return (left: any) => ({ + return (left) => ({ type: "join_expr", left: trailing(left, c1), operator: op, @@ -700,7 +700,7 @@ join_expr_right } // SQLite has its own extra-permissive JOIN syntax. / &sqlite c1:__ op:sqlite_join right:(__ alias$table_factor) spec:(__ join_specification)? { - return (left: any) => ({ + return (left) => ({ type: "join_expr", left: trailing(left, c1), operator: op, @@ -709,7 +709,7 @@ join_expr_right }); } / !sqlite c1:__ op:cross_join right:(__ alias$table_factor) { - return (left: any) => ({ + return (left) => ({ type: "join_expr", left: trailing(left, c1), operator: op, @@ -717,7 +717,7 @@ join_expr_right }); } / (&mysql / &postgres) c1:__ op:natural_join right:(__ alias$table_factor) { - return (left: any) => ({ + return (left) => ({ type: "join_expr", left: trailing(left, c1), operator: op, @@ -725,7 +725,7 @@ join_expr_right }); } / !sqlite c1:__ op:join_op right:(__ alias$table_factor) spec:(__ join_specification)? { - return (left: any) => ({ + return (left) => ({ type: "join_expr", left: trailing(left, c1), operator: op, @@ -945,7 +945,7 @@ unnest_expr // PIVOT ........................................................ pivot_expr_right = &bigquery c1:__ kw:(PIVOT __) args:paren$pivot_for_in { - return (left: any) => ({ + return (left) => ({ type: "pivot_expr", left: trailing(left, c1), pivotKw: read(kw), @@ -970,7 +970,7 @@ unpivot_expr_right = &bigquery c1:__ kw:(UNPIVOT __) nulls:((INCLUDE / EXCLUDE) __ NULLS __)? args:paren$unpivot_for_in { - return (left: any) => ({ + return (left) => ({ type: "unpivot_expr", left: trailing(left, c1), unpivotKw: read(kw), @@ -998,7 +998,7 @@ tablesample_expr_right = (&bigquery / &postgres) c1:__ kw:(TABLESAMPLE __) method:((tablesample_method / ident) __) args:paren$list$tablesample_arg repeatable:(__ tablesample_repeatable)? { - return (left: any) => ({ + return (left) => ({ type: "tablesample_expr", left: trailing(left, c1), tablesampleKw: read(kw), @@ -1036,7 +1036,7 @@ tablesample_repeatable // FOR SYSTEM_TIME AS OF ........................................................ for_system_time_as_of_expr_right = &bigquery c1:__ kw:(FOR __ SYSTEM_TIME __ AS __ OF __) expr:expr { - return (left: any) => ({ + return (left) => ({ type: "for_system_time_as_of_expr", left: trailing(left, c1), forSystemTimeAsOfKw: read(kw), @@ -7651,7 +7651,7 @@ mysql_assign_expr _mysql_assign_expr_right = c1:__ op:":=" c2:__ right:mysql_assign_expr { - return (left: any) => createBinaryExpr(left, c1, op, c2, right); + return (left) => createBinaryExpr(left, c1, op, c2, right); } mysql_or_expr = head:mysql_xor_expr tail:(__ (OR / "||") __ mysql_xor_expr)* { @@ -7706,10 +7706,10 @@ pg_is_expr _pg_is_expr_right = ops:(__ unary_comparison_op)+ { - return (head: any) => createPostfixOpExprChain(head, ops.map(read)); + return (head) => createPostfixOpExprChain(head, ops.map(read)); } / tail:(__ is_op __ pg_comparison_expr)+ { - return (head: any) => createBinaryExprChain(head, tail); + return (head) => createBinaryExprChain(head, tail); } pg_comparison_expr @@ -7733,13 +7733,13 @@ pg_in_expr _pg_in_expr_right = tail:(__ in_op __ (paren$list$expr / sub_comparison_expr))+ { - return (head: any) => createBinaryExprChain(head, tail); + return (head) => createBinaryExprChain(head, tail); } / c1:__ op:pg_like_op c2:__ right:escape_expr { - return (left: any) => createBinaryExpr(left, c1, op, c2, right); + return (left) => createBinaryExpr(left, c1, op, c2, right); } / betweenKw:(__ pg_between_op) begin:(__ sub_comparison_expr) andKw:(__ AND) end:(__ sub_comparison_expr) { - return (left: any) => ({ + return (left) => ({ type: "between_expr", left: left, betweenKw: read(betweenKw), @@ -7769,25 +7769,25 @@ comparison_expr _comparison_expr_right = ops:(__ unary_comparison_op)+ { - return (expr: any) => createPostfixOpExprChain(expr, ops.map(read)); + return (expr) => createPostfixOpExprChain(expr, ops.map(read)); } / tail:(__ comparison_op __ (x:quantifier_expr &mysql { return x; } / sub_comparison_expr))+ { - return (head: any) => createBinaryExprChain(head, tail); + return (head) => createBinaryExprChain(head, tail); } / tail:(__ in_op __ (paren$list$expr / paren$empty_list / sub_comparison_expr / &bigquery e:unnest_expr { return e; }))+ { - return (head: any) => createBinaryExprChain(head, tail); + return (head) => createBinaryExprChain(head, tail); } / tail:(__ like_op __ (&bigquery x:quantifier_expr { return x; } / escape_expr))+ { - return (head: any) => createBinaryExprChain(head, tail); + return (head) => createBinaryExprChain(head, tail); } / &only_mysql c1:__ op:(MEMBER __ OF) c2:__ right:paren$string_literal { - return (left: any) => createBinaryExpr(left, c1, read(op), c2, right); + return (left) => createBinaryExpr(left, c1, read(op), c2, right); } / &mysql tail:(__ sounds_like_op __ sub_comparison_expr)+ { - return (head: any) => createBinaryExprChain(head, tail); + return (head) => createBinaryExprChain(head, tail); } / betweenKw:(__ between_op) begin:(__ sub_comparison_expr) andKw:(__ AND) end:(__ sub_comparison_expr) { - return (left: any) => ({ + return (left) => ({ type: "between_expr", left: left, betweenKw: read(betweenKw), diff --git a/test/config/bigquery.json b/test/config/bigquery.json index 73299764..b54b1fc9 100644 --- a/test/config/bigquery.json +++ b/test/config/bigquery.json @@ -1,5 +1,5 @@ { - "preset": "ts-jest", + "preset": "ts-jest/presets/js-with-ts", "roots": ["../../test", "../../src"], "globals": { "__SQL_DIALECT__": "bigquery" diff --git a/test/config/mariadb.json b/test/config/mariadb.json index 6f644e66..5a0ac205 100644 --- a/test/config/mariadb.json +++ b/test/config/mariadb.json @@ -1,5 +1,5 @@ { - "preset": "ts-jest", + "preset": "ts-jest/presets/js-with-ts", "roots": ["../../test", "../../src"], "globals": { "__SQL_DIALECT__": "mariadb" diff --git a/test/config/mysql.json b/test/config/mysql.json index 446891ac..065daba2 100644 --- a/test/config/mysql.json +++ b/test/config/mysql.json @@ -1,5 +1,5 @@ { - "preset": "ts-jest", + "preset": "ts-jest/presets/js-with-ts", "roots": ["../../test", "../../src"], "globals": { "__SQL_DIALECT__": "mysql" diff --git a/test/config/plpgsql.json b/test/config/plpgsql.json index 4fd0e6d0..adff10fe 100644 --- a/test/config/plpgsql.json +++ b/test/config/plpgsql.json @@ -1,5 +1,5 @@ { - "preset": "ts-jest", + "preset": "ts-jest/presets/js-with-ts", "roots": ["../../test", "../../src"], "globals": { "__SQL_DIALECT__": "plpgsql" diff --git a/test/config/postgresql.json b/test/config/postgresql.json index 51b73124..b2119d63 100644 --- a/test/config/postgresql.json +++ b/test/config/postgresql.json @@ -1,5 +1,5 @@ { - "preset": "ts-jest", + "preset": "ts-jest/presets/js-with-ts", "roots": ["../../test", "../../src"], "globals": { "__SQL_DIALECT__": "postgresql" diff --git a/test/config/sqlite.json b/test/config/sqlite.json index 6c6f2376..6c745bac 100644 --- a/test/config/sqlite.json +++ b/test/config/sqlite.json @@ -1,5 +1,5 @@ { - "preset": "ts-jest", + "preset": "ts-jest/presets/js-with-ts", "roots": ["../../test", "../../src"], "globals": { "__SQL_DIALECT__": "sqlite" diff --git a/tsconfig.json b/tsconfig.json index f01b226e..24615665 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "strict": true, "noImplicitReturns": true, "isolatedModules": true, + "allowJs": true, "noEmit": true }, "include": ["src", "test", "perf", "scripts"], diff --git a/tsconfig.plugins.json b/tsconfig.plugins.json new file mode 100644 index 00000000..c4f58eb2 --- /dev/null +++ b/tsconfig.plugins.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "declaration": false, + "rootDir": "scripts", + "outDir": "build/plugins" + }, + "include": [], + "files": [ + "scripts/move-imports.ts", + "scripts/rule-templates.ts", + "scripts/disable-recusion-check.ts" + ] +}