web 3d图形渲染器
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.

44 lines
1.1 KiB

  1. # import/max-dependencies
  2. Forbid modules to have too many dependencies (`import` or `require` statements).
  3. This is a useful rule because a module with too many dependencies is a code smell, and usually indicates the module is doing too much and/or should be broken up into smaller modules.
  4. Importing multiple named exports from a single module will only count once (e.g. `import {x, y, z} from './foo'` will only count as a single dependency).
  5. ### Options
  6. This rule takes the following option:
  7. `max`: The maximum number of dependencies allowed. Anything over will trigger the rule. **Default is 10** if the rule is enabled and no `max` is specified.
  8. You can set the option like this:
  9. ```js
  10. "import/max-dependencies": ["error", {"max": 10}]
  11. ```
  12. ## Example
  13. Given a max value of `{"max": 2}`:
  14. ### Fail
  15. ```js
  16. import a from './a'; // 1
  17. const b = require('./b'); // 2
  18. import c from './c'; // 3 - exceeds max!
  19. ```
  20. ### Pass
  21. ```js
  22. import a from './a'; // 1
  23. const anotherA = require('./a'); // still 1
  24. import {x, y, z} from './foo'; // 2
  25. ```
  26. ## When Not To Use It
  27. If you don't care how many dependencies a module has.