Blame view

node_modules/eslint-plugin-promise/rules/no-new-statics.js 668 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
26
27
28
29
  'use strict'
  
  const PROMISE_STATICS = require('./lib/promise-statics')
  const getDocsUrl = require('./lib/get-docs-url')
  
  module.exports = {
    meta: {
      docs: {
        url: getDocsUrl('no-new-statics')
      }
    },
    create(context) {
      return {
        NewExpression(node) {
          if (
            node.callee.type === 'MemberExpression' &&
            node.callee.object.name === 'Promise' &&
            PROMISE_STATICS[node.callee.property.name]
          ) {
            context.report({
              node,
              message: "Avoid calling 'new' on 'Promise.{{ name }}()'",
              data: { name: node.callee.property.name }
            })
          }
        }
      }
    }
  }