avoid-new.js 481 B

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