No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

91 líneas
4.3 KiB

hace 3 años
  1. 'use strict';
  2. const commonNodeOverrides = {
  3. rules: {
  4. 'node/no-missing-require': ['error', {
  5. allowModules: [
  6. // Disable the node/no-missing-require rule for `require('ep_etherpad-lite/foo')`. It would
  7. // be nice to warn plugin devs that their plugin is requiring a core Etherpad module that
  8. // doesn't actually exist, but there is a significant cost to enabling this rule for
  9. // ep_etherpad-lite: ep_etherpad-lite is a peer dependency for plugins, so a simple `npm i`
  10. // in the plugin's clone will not install it. Instead, the developer working on the plugin
  11. // ep_example has to do one of these two things:
  12. //
  13. // * Manually clone the etherpad-lite repo, then clone the ep_example repo to
  14. // `/path/to/etherpad-lite/node_modules/ep_example`. Creating a symlink there that
  15. // points to the clone's actual location will not work because npm (or maybe Node.js
  16. // itself?) will resolve the symlink to its physical path before Node.js walks the
  17. // parent directories in search of ep_etherpad-lite.
  18. //
  19. // The biggest flaw with this option: npm loves to quietly nuke anything in
  20. // `node_modules` that isn't a dependency. There's no easy way to prevent npm from
  21. // nuking the plugin's clone. "Installing" the plugin via
  22. // npm install ep_example@file:/path/to/ep_example
  23. // does not help because installation via `file:` works by creating a symlink in
  24. // `node_modules`. (Another annoyance: The dev would have to remember to not commit the
  25. // changes npm makes to `package.json` and `package-lock.json`.)
  26. //
  27. // * Manually clone the etherpad-lite repo, then create an `ep_etherpad-lite` symlink
  28. // inside the plugin's `node_modules` directory that points to
  29. // `/path/to/etherpad-lite/src`. This is a hack: It assumes Node.js searches the
  30. // plugin's own `node_modules` directory even though ep_etherpad-lite is a peer
  31. // dependency. Unfortunately, npm will quietly delete the `ep_etherpad-lite` symlink
  32. // whenever it runs. To prevent npm from deleting the symlink, ep_etherpad-lite could be
  33. // "installed" as a dev dependency via:
  34. // npm install --save-dev ep_etherpad-lite@file:/path/to/etherpad-lite/src
  35. // The dev would have to remember to not commit the changes npm makes to `package.json`
  36. // and `package-lock.json`.
  37. //
  38. // This exemption is made here in this `plugin.js` file and not in `node.js` because
  39. // Etherpad code in `etherpad-lite/bin` and `etherpad-lite/tests` already has
  40. // ep_etherpad-lite available as a dependency (there is no developer burden there).
  41. //
  42. // This exemption does not affect node/no-extraneous-require, so a plugin is still required
  43. // to add `ep_etherpad-lite` to its `peerDependencies` if it requires ep_etherpad-lite.
  44. //
  45. // All peer dependencies are similarly troublesome; this is not just an ep_etherpad-lite
  46. // problem. They should all be listed here to avoid hassle. Unfortunately, this
  47. // `allowModules` option does not take regular expressions, otherwise we could simply permit
  48. // `ep_.*`. (Modules beginning with `ep_` are almost certainly going to be peer
  49. // dependencies.)
  50. 'ep_etherpad-lite',
  51. ],
  52. }],
  53. },
  54. };
  55. module.exports = {
  56. overrides: [
  57. {
  58. files: ['**/.eslintrc.js'],
  59. extends: './node.js',
  60. },
  61. {
  62. files: ['**/*'],
  63. excludedFiles: ['**/.eslintrc.js', 'static/js/**/*', 'static/tests/frontend/**/*'],
  64. extends: './node.js',
  65. ...commonNodeOverrides,
  66. },
  67. {
  68. files: ['static/js/**/*'],
  69. excludedFiles: ['**/.eslintrc.js'],
  70. extends: './browser.js',
  71. },
  72. {
  73. files: ['static/tests/**/*'],
  74. excludedFiles: ['**/.eslintrc.js'],
  75. extends: './tests.js',
  76. },
  77. {
  78. files: ['static/tests/backend/**/*'],
  79. excludedFiles: ['**/.eslintrc.js'],
  80. extends: './tests/backend.js',
  81. ...commonNodeOverrides,
  82. },
  83. {
  84. files: ['static/tests/frontend/**/*'],
  85. excludedFiles: ['**/.eslintrc.js'],
  86. extends: './tests/frontend.js',
  87. },
  88. ],
  89. };