Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
33 lines
671 B
Plaintext
33 lines
671 B
Plaintext
/**
|
|
* Rule: avoid-new
|
|
* Avoid creating new promises outside of utility libraries.
|
|
*/
|
|
|
|
'use strict'
|
|
|
|
const getDocsUrl = require('./lib/get-docs-url')
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'suggestion',
|
|
docs: {
|
|
description:
|
|
'Disallow creating `new` promises outside of utility libs (use [util.promisify][] instead).',
|
|
url: getDocsUrl('avoid-new'),
|
|
},
|
|
schema: [],
|
|
messages: {
|
|
avoidNew: 'Avoid creating new promises.',
|
|
},
|
|
},
|
|
create(context) {
|
|
return {
|
|
NewExpression(node) {
|
|
if (node.callee.name === 'Promise') {
|
|
context.report({ node, messageId: 'avoidNew' })
|
|
}
|
|
},
|
|
}
|
|
},
|
|
}
|