Skip to content

Commit

Permalink
Merge pull request #25 from Automattic/add/jest-lint-rules
Browse files Browse the repository at this point in the history
Add rules for Jest tests
  • Loading branch information
nickdaugherty committed Jan 24, 2019
2 parents 84eabbf + d401ff1 commit c0051d2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 61 deletions.
31 changes: 23 additions & 8 deletions index.js
Expand Up @@ -3,6 +3,7 @@ module.exports = {
env: {
es6: true,
node: true,
'jest/globals': true,
},
extends: [
'plugin:flowtype/recommended',
Expand All @@ -20,16 +21,9 @@ module.exports = {
'flowtype',
'json',
'no-async-foreach',
'jest',
],
globals: {
describe: true,
it: true,
expect: true,
beforeEach: true,
afterEach: true,
beforeAll: true,
afterAll: true,
jest: true,
window: true,
},
rules: {
Expand Down Expand Up @@ -75,6 +69,27 @@ module.exports = {
'no-async-foreach/no-async-foreach': [
'error',
],

// Jest rules, from https://github.com/jest-community/eslint-plugin-jest
'jest/consistent-test-it': 'error',
'jest/lowercase-name': 'error',
'jest/expect-expect': 'warn',
'jest/no-disabled-tests': 'warn',
'jest/no-alias-methods': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/no-jest-import': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-truthy-falsy': 'warn',
'jest/prefer-spy-on': 'warn',
'jest/prefer-to-be-null': 'warn',
'jest/prefer-to-be-undefined': 'warn',
'jest/prefer-to-contain': 'warn',
'jest/prefer-to-have-length': 'warn',
'jest/require-tothrow-message': 'warn',
'jest/valid-describe': 'error',
'jest/valid-expect': 'error',
'jest/valid-expect-in-promise': 'error',
},
settings: {
react: {
Expand Down
80 changes: 29 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -34,7 +34,8 @@
"eslint-plugin-no-async-foreach": "^0.1.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-wpcalypso": "^4.0.1",
"eslint-plugin-json": "^1.2.1"
"eslint-plugin-json": "^1.2.1",
"eslint-plugin-jest": "22.1.3"
},
"devDependencies": {
"babel-eslint": "10.0.1",
Expand All @@ -45,6 +46,7 @@
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-no-async-foreach": "0.1.1",
"eslint-plugin-react": "7.11.1",
"eslint-plugin-wpcalypso": "4.0.2"
"eslint-plugin-wpcalypso": "4.0.2",
"eslint-plugin-jest": "22.1.3"
}
}

0 comments on commit c0051d2

Please sign in to comment.