adding lint rule for console.error
This commit is contained in:
parent
27dec6e390
commit
639b8970f9
|
@ -43,7 +43,8 @@
|
|||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"local-rules/no-budibase-imports": "error"
|
||||
"local-rules/no-budibase-imports": "error",
|
||||
"local-rules/no-console-error": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,4 +1,24 @@
|
|||
module.exports = {
|
||||
"no-console-error": {
|
||||
create: function(context) {
|
||||
return {
|
||||
CallExpression(node) {
|
||||
if (
|
||||
node.callee.type === "MemberExpression" &&
|
||||
node.callee.object.name === "console" &&
|
||||
node.callee.property.name === "error" &&
|
||||
node.arguments.length === 1 &&
|
||||
node.arguments[0].name.startsWith("err")
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
message: 'Using console.error(err) on its own is not allowed. Either provide context to the error (console.error(msg, err)) or throw it.',
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
"no-budibase-imports": {
|
||||
create: function (context) {
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue