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.

87 lines
1.4 KiB

  1. # import/newline-after-import
  2. Enforces having one or more empty lines after the last top-level import statement or require call.
  3. +(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule.
  4. ## Rule Details
  5. This rule has one option, `count` which sets the number of newlines that are enforced after the last top-level import statement or require call. This option defaults to `1`.
  6. Valid:
  7. ```js
  8. import defaultExport from './foo'
  9. const FOO = 'BAR'
  10. ```
  11. ```js
  12. import defaultExport from './foo'
  13. import { bar } from 'bar-lib'
  14. const FOO = 'BAR'
  15. ```
  16. ```js
  17. const FOO = require('./foo')
  18. const BAR = require('./bar')
  19. const BAZ = 1
  20. ```
  21. Invalid:
  22. ```js
  23. import * as foo from 'foo'
  24. const FOO = 'BAR'
  25. ```
  26. ```js
  27. import * as foo from 'foo'
  28. const FOO = 'BAR'
  29. import { bar } from 'bar-lib'
  30. ```
  31. ```js
  32. const FOO = require('./foo')
  33. const BAZ = 1
  34. const BAR = require('./bar')
  35. ```
  36. With `count` set to `2` this will be considered valid:
  37. ```js
  38. import defaultExport from './foo'
  39. const FOO = 'BAR'
  40. ```
  41. With `count` set to `2` these will be considered invalid:
  42. ```js
  43. import defaultExport from './foo'
  44. const FOO = 'BAR'
  45. ```
  46. ```js
  47. import defaultExport from './foo'
  48. const FOO = 'BAR'
  49. ```
  50. ## Example options usage
  51. ```json
  52. {
  53. "rules": {
  54. "import/newline-after-import": ["error", { "count": 2 }]
  55. }
  56. }
  57. ```
  58. ## When Not To Use It
  59. If you like to visually group module imports with its usage, you don't want to use this rule.