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.17 to 0.0.18

9

lib/rules/check-sql.rule.js

@@ -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 @@ });

4

lib/rules/check-sql.utils.d.ts

@@ -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

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