avoid-new.js 473 B

12345678910111213141516171819202122232425
  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. docs: {
  10. url: getDocsUrl('avoid-new')
  11. }
  12. },
  13. create: function(context) {
  14. return {
  15. NewExpression: function(node) {
  16. if (node.callee.name === 'Promise') {
  17. context.report({ node, message: 'Avoid creating new promises.' })
  18. }
  19. }
  20. }
  21. }
  22. }