chore(eslint): ensure proper error handling

This commit is contained in:
Tony 2025-09-30 11:06:17 +08:00
parent 96a97077f7
commit 016ea35ac1
1 changed files with 8 additions and 4 deletions

View File

@ -110,16 +110,20 @@ export default [
message: 'Please use .toArray() before .map().',
},
{
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[params.length<=1][body.value=null]',
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[params.length=0][body.value=null]',
message: 'Usage of .catch(() => null) is not allowed. Please handle the error appropriately.',
},
{
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[params.length<=1][body.type="Identifier"][body.name="undefined"]',
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[params.length=0][body.type="Identifier"][body.name="undefined"]',
message: 'Usage of .catch(() => undefined) is not allowed. Please handle the error appropriately.',
},
{
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[params.length<=1] > ArrayExpression[elements.length<=1]',
message: "Usage of .catch(() => []]) is not allowed. Please handle the error appropriately."
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[params.length=0] > ArrayExpression[elements.length=0]',
message: "Usage of .catch(() => []) is not allowed. Please handle the error appropriately."
},
{
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[params.length=0] > BlockStatement[body.length=0]',
message: "Usage of .catch(() => {}) is not allowed. Please handle the error appropriately."
}
],