jest.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. 'use strict';
  8. // We use eslint-loader so even warnings are very visible.
  9. // This is why we prefer to use "WARNING" level for potential errors,
  10. // and we try not to use "ERROR" level at all.
  11. module.exports = {
  12. plugins: ['jest', 'testing-library'],
  13. overrides: [
  14. {
  15. files: ['**/__tests__/**/*', '**/*.{spec,test}.*'],
  16. env: {
  17. 'jest/globals': true,
  18. },
  19. // A subset of the recommended rules:
  20. rules: {
  21. // https://github.com/jest-community/eslint-plugin-jest
  22. 'jest/no-conditional-expect': 'error',
  23. 'jest/no-identical-title': 'error',
  24. 'jest/no-interpolation-in-snapshots': 'error',
  25. 'jest/no-jasmine-globals': 'error',
  26. 'jest/no-jest-import': 'error',
  27. 'jest/no-mocks-import': 'error',
  28. 'jest/valid-describe': 'error',
  29. 'jest/valid-expect': 'error',
  30. 'jest/valid-expect-in-promise': 'error',
  31. 'jest/valid-title': 'warn',
  32. // https://github.com/testing-library/eslint-plugin-testing-library
  33. 'testing-library/await-async-query': 'error',
  34. 'testing-library/await-async-utils': 'error',
  35. 'testing-library/no-await-sync-query': 'warn',
  36. 'testing-library/no-dom-import': ['error', 'react'],
  37. 'testing-library/no-wait-for-empty-callback': 'error',
  38. 'testing-library/no-wait-for-snapshot': 'error',
  39. },
  40. },
  41. ],
  42. };