no-generated-editor-themes.js 671 B

123456789101112131415161718192021
  1. module.exports = {
  2. meta: {
  3. type: 'error',
  4. docs: {
  5. description:
  6. 'Prohibit CodeMirror themes that are generated in a function',
  7. },
  8. },
  9. create(context) {
  10. return {
  11. ':matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression) CallExpression > MemberExpression[object.name="EditorView"]:matches([property.name="theme"],[property.name="baseTheme"])'(
  12. node
  13. ) {
  14. context.report({
  15. node,
  16. message: `EditorView.theme and EditorView.baseTheme each add CSS to the page for every instance of the theme. Store the theme in a variable and reuse it instead.`,
  17. })
  18. },
  19. }
  20. },
  21. }