@ts-safeql/eslint-plugin
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -188,2 +188,5 @@ "use strict"; | ||
if (isMissingTypeAnnotations) { | ||
if (resultWithTransformed.result === null) { | ||
return; | ||
} | ||
return (0, check_sql_utils_1.reportMissingTypeAnnotations)({ | ||
@@ -193,3 +196,7 @@ tag: tag, | ||
baseNode: baseNode, | ||
result: resultWithTransformed, | ||
result: { | ||
query: resultWithTransformed.query, | ||
result: resultWithTransformed.result, | ||
stmt: resultWithTransformed.stmt, | ||
}, | ||
}); | ||
@@ -196,0 +203,0 @@ } |
@@ -209,2 +209,22 @@ "use strict"; | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "empty select statement should not have type annotation", | ||
code: `conn.query(sql\`select\`);`, | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "insert statement without returning should not have type annotation", | ||
code: `conn.query(sql\`insert into agency (name) values ('test')\`);`, | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "insert statement with returning should have type annotation", | ||
code: `conn.query<{ id: number }>( | ||
sql\`insert into agency (name) values ('test') returning id\`); | ||
`, | ||
}, | ||
], | ||
@@ -323,2 +343,22 @@ invalid: [ | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "select statement that should not have a type annotation", | ||
code: `conn.query<{}>(sql\`select\`);`, | ||
output: `conn.query(sql\`select\`);`, | ||
errors: [ | ||
{ | ||
messageId: "incorrectTypeAnnotations", | ||
data: { | ||
expected: "{ }", | ||
actual: "No type annotation", | ||
}, | ||
line: 1, | ||
column: 12, | ||
endLine: 1, | ||
endColumn: 14, | ||
}, | ||
], | ||
}, | ||
], | ||
@@ -325,0 +365,0 @@ }); |
@@ -42,3 +42,5 @@ import { GenerateResult } from "@ts-safeql/generate"; | ||
baseNode: TSESTree.BaseNode; | ||
result: GenerateResult; | ||
result: GenerateResult & { | ||
result: string; | ||
}; | ||
}): void; | ||
@@ -45,0 +47,0 @@ export declare function reportIncorrectTypeAnnotations(params: { |
@@ -109,10 +109,12 @@ "use strict"; | ||
function reportIncorrectTypeAnnotations(params) { | ||
var _a; | ||
const { context, result, typeParameter } = params; | ||
const newValue = result.result === null ? "" : `<${result.result}>`; | ||
return context.report({ | ||
node: typeParameter.params[0], | ||
messageId: "incorrectTypeAnnotations", | ||
fix: (fixer) => fixer.replaceText(typeParameter, `<${result.result}>`), | ||
fix: (fixer) => fixer.replaceText(typeParameter, newValue), | ||
data: { | ||
expected: params.expected, | ||
actual: params.actual, | ||
actual: (_a = params.actual) !== null && _a !== void 0 ? _a : "No type annotation", | ||
}, | ||
@@ -119,0 +121,0 @@ }); |
{ | ||
"name": "@ts-safeql/eslint-plugin", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
356665
5096