From 1f039f40094c1270228c6221d36fbcda864f3d1d Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Mon, 13 Jan 2020 00:17:23 +1300 Subject: [PATCH] feat: create `jest` config --- jest.js | 35 +++++++++++++++++++++++++++++++++++ package-lock.json | 9 +++++++++ package.json | 4 +++- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 jest.js diff --git a/jest.js b/jest.js new file mode 100644 index 00000000..bf0ebeee --- /dev/null +++ b/jest.js @@ -0,0 +1,35 @@ +module.exports = { + plugins: ['eslint-plugin-jest'], + extends: [ + 'plugin:eslint-plugin-jest/recommended', + 'plugin:eslint-plugin-jest/style' + ], + rules: { + 'jest/consistent-test-it': 'error', + 'jest/expect-expect': [ + 'error', + // todo: TBD - this will need adjusting for react-testing-library + { assertFunctionNames: ['expect'] } + ], + 'jest/lowercase-name': [ + 'error', // todo switch to top flag once merged + { ignore: ['describe'] } + ], + 'jest/no-expect-resolves': 'warn', + 'jest/no-if': 'error', // todo: rename to no-conditional-expect + 'jest/no-large-snapshots': 'warn', + 'jest/no-test-return-statement': 'error', + 'jest/no-truthy-falsy': 'error', + 'jest/prefer-called-with': 'error', + // you can disable this if you use a `beforeEach` setup script, + 'jest/prefer-expect-assertions': 'warn', + 'jest/prefer-hooks-on-top': 'error', + 'jest/prefer-inline-snapshots': 'warn', + 'jest/prefer-spy-on': 'error', + 'jest/prefer-strict-equal': 'error', + 'jest/prefer-todo': 'error', + 'jest/require-to-throw-message': 'error', + 'jest/require-top-level-describe': 'error', + 'jest/valid-title': 'error' + } +}; diff --git a/package-lock.json b/package-lock.json index 19de8f8f..b5467f45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3363,6 +3363,15 @@ } } }, + "eslint-plugin-jest": { + "version": "23.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.4.0.tgz", + "integrity": "sha512-BKZmxpvya0/slJdUr5MJdWvIUNtDySzbAxigr3xMVmyiSUvQLhnLde+8dDM56sFPDSU1pQG9ZqNglMq0jLYVqw==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "^2.5.0" + } + }, "eslint-plugin-local": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-local/-/eslint-plugin-local-1.0.0.tgz", diff --git a/package.json b/package.json index 3b8c8026..700cd6f3 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "license": "ISC", "author": "Gareth Jones", "files": [ - "index.js" + "index.js", + "jest.js" ], "scripts": { "lint": "eslint . --ignore-pattern '!.eslintrc.js' --ext js,ts", @@ -56,6 +57,7 @@ "@typescript-eslint/parser": "^2.16.0", "eslint": "^6.8.0", "eslint-plugin-eslint-comments": "^3.1.2", + "eslint-plugin-jest": "^23.4.0", "eslint-plugin-local": "^1.0.0", "eslint-plugin-prettier": "^3.1.2", "husky": "^3.1.0",