Blame view

node_modules/eslint-plugin-promise/rules/avoid-new.js 473 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  /**
   * Rule: avoid-new
   * Avoid creating new promises outside of utility libraries.
   */
  
  'use strict'
  
  const getDocsUrl = require('./lib/get-docs-url')
  
  module.exports = {
    meta: {
      docs: {
        url: getDocsUrl('avoid-new')
      }
    },
    create: function(context) {
      return {
        NewExpression: function(node) {
          if (node.callee.name === 'Promise') {
            context.report({ node, message: 'Avoid creating new promises.' })
          }
        }
      }
    }
  }