.eslintrc.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright 2018-2022 Elyra Authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. const allExtensions = [".ts", ".tsx", ".d.ts", ".js", ".jsx"];
  17. module.exports = {
  18. root: true,
  19. extends: [
  20. "react-app",
  21. "plugin:jest/recommended",
  22. "plugin:jest/style",
  23. "plugin:testing-library/react",
  24. "plugin:jest-dom/recommended",
  25. ],
  26. plugins: ["import", "header"],
  27. rules: {
  28. "testing-library/prefer-screen-queries": ["warn"],
  29. "jest/expect-expect": ["off"],
  30. "jest/valid-title": ["off"],
  31. "header/header": [
  32. "warn",
  33. "block",
  34. [
  35. "",
  36. " * Copyright 2018-2022 Elyra Authors",
  37. " *",
  38. ' * Licensed under the Apache License, Version 2.0 (the "License");',
  39. " * you may not use this file except in compliance with the License.",
  40. " * You may obtain a copy of the License at",
  41. " *",
  42. " * http://www.apache.org/licenses/LICENSE-2.0",
  43. " *",
  44. " * Unless required by applicable law or agreed to in writing, software",
  45. ' * distributed under the License is distributed on an "AS IS" BASIS,',
  46. " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.",
  47. " * See the License for the specific language governing permissions and",
  48. " * limitations under the License.",
  49. " ",
  50. ],
  51. 2,
  52. ],
  53. "import/newline-after-import": ["warn", { count: 1 }],
  54. "import/no-extraneous-dependencies": [
  55. "warn",
  56. {
  57. devDependencies: false,
  58. optionalDependencies: false,
  59. peerDependencies: true,
  60. bundledDependencies: true,
  61. },
  62. ],
  63. "import/order": [
  64. "warn",
  65. {
  66. alphabetize: {
  67. order: "asc",
  68. caseInsensitive: true,
  69. },
  70. "newlines-between": "always",
  71. groups: [
  72. "builtin",
  73. "external",
  74. "internal",
  75. ["parent", "sibling", "index"],
  76. "object",
  77. ],
  78. pathGroups: [
  79. {
  80. pattern: "react?(-dom)",
  81. group: "external",
  82. position: "before",
  83. },
  84. {
  85. pattern: "@iris/**",
  86. group: "external",
  87. position: "after",
  88. },
  89. ],
  90. pathGroupsExcludedImportTypes: ["builtin"],
  91. },
  92. ],
  93. },
  94. overrides: [
  95. {
  96. files: ["cypress/**"],
  97. rules: {
  98. "testing-library/prefer-screen-queries": "off",
  99. },
  100. },
  101. {
  102. files: ["stories/**"],
  103. rules: {
  104. "import/no-anonymous-default-export": ["off"],
  105. "import/no-extraneous-dependencies": "off",
  106. },
  107. },
  108. {
  109. files: [
  110. "webpack.*.js",
  111. "*.test.{ts,tsx}",
  112. "test-utils.{ts,tsx}",
  113. "cypress/**",
  114. ],
  115. rules: {
  116. "import/no-extraneous-dependencies": [
  117. "warn",
  118. {
  119. devDependencies: true,
  120. optionalDependencies: false,
  121. peerDependencies: false,
  122. bundledDependencies: true,
  123. },
  124. ],
  125. },
  126. },
  127. ],
  128. settings: {
  129. "import/extensions": allExtensions,
  130. "import/external-module-folders": ["node_modules", "node_modules/@types"],
  131. "import/parsers": {
  132. "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
  133. },
  134. "import/resolver": {
  135. node: {
  136. extensions: allExtensions,
  137. },
  138. },
  139. },
  140. };