eslint.config.mjs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import eslintPluginJest from "eslint-plugin-jest";
  2. import eslintPluginJs from "@eslint/js";
  3. import eslintPluginStylistic from "@stylistic/eslint-plugin";
  4. import globals from "globals";
  5. const config = [
  6. eslintPluginJs.configs.recommended,
  7. {
  8. files: ["**/*.js"],
  9. languageOptions: {
  10. ecmaVersion: "latest",
  11. globals: {
  12. ...globals.browser,
  13. ...globals.node,
  14. ...globals.jest,
  15. Log: "readonly",
  16. MM: "readonly",
  17. Module: "readonly",
  18. config: "readonly",
  19. moment: "readonly"
  20. }
  21. },
  22. plugins: {
  23. ...eslintPluginStylistic.configs["all-flat"].plugins,
  24. ...eslintPluginJest.configs["flat/recommended"].plugins
  25. },
  26. rules: {
  27. ...eslintPluginStylistic.configs["all-flat"].rules,
  28. ...eslintPluginJest.configs["flat/recommended"].rules,
  29. "@stylistic/array-element-newline": ["error", "consistent"],
  30. "@stylistic/arrow-parens": ["error", "always"],
  31. "@stylistic/brace-style": "off",
  32. "@stylistic/comma-dangle": ["error", "never"],
  33. "@stylistic/dot-location": ["error", "property"],
  34. "@stylistic/function-call-argument-newline": ["error", "consistent"],
  35. "@stylistic/function-paren-newline": ["error", "consistent"],
  36. "@stylistic/implicit-arrow-linebreak": ["error", "beside"],
  37. "@stylistic/indent": ["error", "tab"],
  38. "@stylistic/max-statements-per-line": ["error", {max: 2}],
  39. "@stylistic/multiline-comment-style": "off",
  40. "@stylistic/multiline-ternary": ["error", "always-multiline"],
  41. "@stylistic/newline-per-chained-call": ["error", {ignoreChainWithDepth: 4}],
  42. "@stylistic/no-extra-parens": "off",
  43. "@stylistic/no-tabs": "off",
  44. "@stylistic/object-curly-spacing": ["error", "always"],
  45. "@stylistic/object-property-newline": ["error", {allowAllPropertiesOnSameLine: true}],
  46. "@stylistic/operator-linebreak": ["error", "before"],
  47. "@stylistic/padded-blocks": "off",
  48. "@stylistic/quote-props": ["error", "as-needed"],
  49. "@stylistic/quotes": ["error", "double"],
  50. "@stylistic/semi": ["error", "always"],
  51. "@stylistic/space-before-function-paren": ["error", "always"],
  52. "@stylistic/spaced-comment": "off",
  53. eqeqeq: "error",
  54. "id-length": "off",
  55. "init-declarations": "off",
  56. "jest/consistent-test-it": "warn",
  57. "jest/no-done-callback": "warn",
  58. "jest/prefer-expect-resolves": "warn",
  59. "jest/prefer-mock-promise-shorthand": "warn",
  60. "jest/prefer-to-be": "warn",
  61. "jest/prefer-to-have-length": "warn",
  62. "max-lines-per-function": ["warn", 350],
  63. "max-statements": "off",
  64. "no-global-assign": "off",
  65. "no-inline-comments": "off",
  66. "no-magic-numbers": "off",
  67. "no-param-reassign": "error",
  68. "no-plusplus": "off",
  69. "no-prototype-builtins": "off",
  70. "no-ternary": "off",
  71. "no-throw-literal": "error",
  72. "no-undefined": "off",
  73. "no-unused-vars": "off",
  74. "no-useless-return": "error",
  75. "no-warning-comments": "off",
  76. "object-shorthand": ["error", "methods"],
  77. "one-var": "off",
  78. "prefer-destructuring": "off",
  79. "prefer-template": "error",
  80. "sort-keys": "off"
  81. }
  82. },
  83. {
  84. files: ["**/*.mjs"],
  85. languageOptions: {
  86. ecmaVersion: "latest",
  87. globals: {
  88. ...globals.node
  89. },
  90. sourceType: "module"
  91. },
  92. plugins: {
  93. ...eslintPluginStylistic.configs["all-flat"].plugins
  94. },
  95. rules: {
  96. ...eslintPluginStylistic.configs["all-flat"].rules,
  97. "@stylistic/array-element-newline": "off",
  98. "@stylistic/indent": ["error", "tab"],
  99. "@stylistic/padded-blocks": ["error", "never"],
  100. "@stylistic/quote-props": ["error", "as-needed"],
  101. "func-style": "off",
  102. "import/namespace": "off",
  103. "max-lines-per-function": ["error", 100],
  104. "no-magic-numbers": "off",
  105. "one-var": "off",
  106. "prefer-destructuring": "off"
  107. }
  108. },
  109. {
  110. files: ["tests/configs/modules/weather/*.js"],
  111. rules: {
  112. "@stylistic/quotes": "off"
  113. }
  114. },
  115. {
  116. ignores: ["config/**", "modules/**", "!modules/default/**", "js/positions.js"]
  117. }
  118. ];
  119. export default config;