webhook-action/node_modules/eslint-plugin-github/lib/rules/no-then.js

23 lines
622 B
JavaScript
Raw Normal View History

module.exports = {
meta: {
2022-11-10 10:43:16 +00:00
type: 'suggestion',
docs: {
description: 'enforce using `async/await` syntax over Promises',
url: require('../url')(module)
},
schema: []
},
create(context) {
return {
MemberExpression(node) {
if (node.property && node.property.name === 'then') {
2022-11-10 10:43:16 +00:00
context.report({node: node.property, message: 'Prefer async/await to Promise.then()'})
} else if (node.property && node.property.name === 'catch') {
2022-11-10 10:43:16 +00:00
context.report({node: node.property, message: 'Prefer async/await to Promise.catch()'})
}
}
}
}
}