Check if your transactions are closed at every path
npm install --saved-dev eslint-plugin-sequelize-transaction
Most of the code here is from rules of hooks source code
async function simple() {
const transaction = await sequelize.transaction();
if (false) {
await transaction.rollback()
return
}
await transaction.rollback()
}`,
async function withTryAndFinally() {
const transaction = await sequelize.transaction();
try {
return 1
} catch (err) {
console.error()
} finally {
await transaction.rollback()
}
}
async function nested() {
const transaction = await sequelize.transaction();
{
{
{
await transaction.rollback()
}
}
}
}
async function ifElse() {
const transaction = await sequelize.transaction();
if (123) {
await transaction.rollback()
return bla
} else {
await transaction.rollback()
}
}
const obj = {
property: async () => {
const transaction = await sequelize.transaction();
if (123) {
await transaction.rollback()
return bla
} else {
await transaction.rollback()
}
}
}
async function nestedStatements() {
let transaction = await sequelize.transaction();
if (3 > 2) {
if (4 > 2) {
return 1
}
await transaction.rollback()
}
await transaction.rollback()
}
async function noNesting() {
const transaction = await sequelize.transaction();
return await 1
}
const obj = {
func: async function () {
const transaction = await sequelize.transaction();
return await 1
}
}
const obj = {
arrow: async () => {
const transaction = await sequelize.transaction();
return await 1
}
}