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