UNPKG

497 BJavaScriptView Raw
1/**
2 * Rule: avoid-new
3 * Avoid creating new promises outside of utility libraries.
4 */
5
6'use strict'
7
8const getDocsUrl = require('./lib/get-docs-url')
9
10module.exports = {
11 meta: {
12 type: 'suggestion',
13 docs: {
14 url: getDocsUrl('avoid-new'),
15 },
16 schema: [],
17 },
18 create(context) {
19 return {
20 NewExpression(node) {
21 if (node.callee.name === 'Promise') {
22 context.report({ node, message: 'Avoid creating new promises.' })
23 }
24 },
25 }
26 },
27}