项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

12345678910111213141516171819202122232425262728
  1. /**
  2. * Rule: no-nesting
  3. * Avoid nesting your promises.
  4. */
  5. 'use strict'
  6. const getDocsUrl = require('./lib/get-docs-url')
  7. const hasPromiseCallback = require('./lib/has-promise-callback')
  8. const isInsidePromise = require('./lib/is-inside-promise')
  9. module.exports = {
  10. meta: {
  11. docs: {
  12. url: getDocsUrl('no-nesting')
  13. }
  14. },
  15. create: function(context) {
  16. return {
  17. CallExpression: function(node) {
  18. if (!hasPromiseCallback(node)) return
  19. if (context.getAncestors().some(isInsidePromise)) {
  20. context.report({ node, message: 'Avoid nesting promises.' })
  21. }
  22. }
  23. }
  24. }
  25. }