ESLint autofixes

master
Sven Slootweg 4 years ago
parent abba82ad07
commit ccae979451

@ -1,7 +1,7 @@
var gulp = require("gulp");
var presetES2015 = require("@joepie91/gulp-preset-es2015");
var source = ["src/**/*.js"]
var source = ["src/**/*.js"];
gulp.task('babel', function() {
return gulp.src(source)

@ -18,7 +18,7 @@ module.exports = {
return (
// PostgreSQL (via `pg`):
(error.length != null && error.file != null && error.line != null && error.routine != null && error.code === "23514")
)
);
},
convert: function convertError(error) {
let messageMatch = messageRegex.exec(error.message);
@ -36,7 +36,7 @@ module.exports = {
if (columns != null) {
/* This is the naming convention that Knex uses for .enum() in PostgreSQL */
offendingColumn = columns.find(column => {
return error.constraint === `${error.table}_${column}_check`
return error.constraint === `${error.table}_${column}_check`;
});
message = `Value violates the '${error.constraint}' constraint for the '${offendingColumn}' column in the '${error.table}' table`;

@ -17,7 +17,7 @@ module.exports = {
return (
// PostgreSQL (via `pg`):
(error.length != null && error.file != null && error.line != null && error.routine != null && error.code === "22P02" && error.message.includes("invalid input value for enum"))
)
);
},
convert: function convertError(error) {
let messageMatch = messageRegex.exec(error.message);

@ -15,7 +15,7 @@ module.exports = {
return (
// PostgreSQL (via `pg`):
(error.length != null && error.file != null && error.line != null && error.routine != null && error.code === "23503")
)
);
},
convert: function convertError(error) {
let [_, column, value, foreignTable] = detailsRegex.exec(error.detail);

@ -18,7 +18,7 @@ module.exports = {
return (
// PostgreSQL (via `pg`):
(error.length != null && error.file != null && error.line != null && error.routine != null && error.code === "22P02" && error.message.includes("invalid input syntax for"))
)
);
},
convert: function convertError(error) {
let messageMatch = messageRegex.exec(error.message);

@ -17,7 +17,7 @@ module.exports = {
return (
// PostgreSQL (via `pg`):
(error.length != null && error.file != null && error.line != null && error.routine != null && error.code === "23502")
)
);
},
convert: function convertError(error) {
let [_, query, column] = messageRegex.exec(error.message);

@ -17,7 +17,7 @@ module.exports = {
return (
// PostgreSQL (via `pg`):
(error.length != null && error.file != null && error.line != null && error.routine != null && error.code === "42703")
)
);
},
convert: function convertError(error) {
let messageMatch = messageRegex.exec(error.message);

@ -16,7 +16,7 @@ module.exports = {
return (
// PostgreSQL (via `pg`):
(error.length != null && error.file != null && error.line != null && error.routine != null && error.code === "23505")
)
);
},
convert: function convertError(error) {
let [_, columnValue, valueValue] = detailsRegex.exec(error.detail);

@ -9,7 +9,7 @@ module.exports = function getColumns(query) {
if (match = insertRegex.exec(query)) {
return match[1].split(",").map((columnName) => {
return columnName.trim().slice(1, -1)
return columnName.trim().slice(1, -1);
});
} else if (match = updateRegex.exec(query)) {
return match[1].split(",").map((statement) => {

@ -15,13 +15,13 @@ let handlers = [
require("./errors/invalid-type"),
require("./errors/undefined-column"),
require("./errors/not-null-constraint-violation"),
]
];
function convertError(error) {
let handler = handlers.find(handler => handler.check(error));
if (handler != null) {
debug(`Converting error with message: ${error.message}`)
debug(`Converting error with message: ${error.message}`);
return handler.convert(error);
} else {
throw new UnknownError("The specified error is not of a recognized type");
@ -51,4 +51,4 @@ module.exports = Object.assign({
rethrow: rethrowBetterError,
UnknownError: UnknownError,
DatabaseError: DatabaseError
}, errorTypes)
}, errorTypes);

@ -14,11 +14,11 @@ let tables = [
let noop = function noop(err) {
// Do nothing.
}
};
let rethrow = function rethrowError(err) {
throw err;
}
};
module.exports = {
up: function createTables(knex) {
@ -39,4 +39,4 @@ module.exports = {
return table.down(knex, errorHandler);
});
}
}
};

@ -21,6 +21,6 @@ module.exports = function attemptForeignKeyConstraintViolation(knex) {
}, {
user_id: 567213,
body: "Baz"
}])
}]);
});
};

Loading…
Cancel
Save