Skip to content

Code Quality eslint jest plugin reports rule definitions not found

Summary

When specifying eslint-plugin-jest rules in .eslintrc.json, code_quality job reports definition not found for most rules, e.g.

Definition for rule 'jest/prefer-todo' was not found in index.js:1

Steps to reproduce

Run code quality in a project with Jest tests and the following .eslintrc.json file:

{
    "env": {
        "es6": true,
        "jest": true,
        "node": true
    },
    "extends": [ "eslint:recommended",
        "plugin:jest/recommended" ],
    "parserOptions": {
        "ecmaVersion": 8,
        "sourceType": "script"
    },
    "plugins": ["jest"],
    "rules": {
        "array-bracket-spacing": "warn",
        "block-scoped-var": 1,
        "block-spacing": "warn",
        "brace-style": ["warn", "stroustrup"],
        "camelcase": ["warn", { "properties": "never" }],
        "complexity": ["warn", 20],
        "computed-property-spacing": ["warn", "never"],
        "eqeqeq": ["error", "always"],
        "func-call-spacing": ["warn", "never"],
        "indent": ["error", 4, { "SwitchCase": 1 }],
        "keyword-spacing": ["warn", { "before": true, "after": true }],
        "max-depth": ["error", { "max": 5 }],
        "max-nested-callbacks": ["error", { "max": 10 }],
        "no-console": "off",
        "no-eval": "error",
        "no-implicit-globals": "off",
        "no-lonely-if": "error",
        "no-loop-func": "error",
        "no-magic-numbers": [ "error", { "ignore": [ -1, 0, 1 ] } ],
        "no-mixed-spaces-and-tabs": "warn",
        "no-multi-str": "error",
        "no-new": "error",
        "no-param-reassign": ["error", { "props": false }],
        "no-script-url": "error",
        "no-sequences": "error",
        "no-use-before-define": ["error", { "functions": false }],
        "no-useless-concat": "error",
        "quotes": ["error", "single"],
        "semi": ["error", "always"],
        "space-before-blocks": ["warn", "always"],
        "space-before-function-paren": ["warn", "never"],
        "space-in-parens": ["warn", "never"],
        "strict": "error",
        "jest/consistent-test-it": ["error", {"fn": "it", "withinDescribe": "it"}],
        "jest/lowercase-name": "error",
        "jest/no-alias-methods": "error",
        "jest/no-disabled-tests": "error",
        "jest/no-commented-out-tests": "warn",
        "jest/no-empty-title": "warn",
        "jest/no-focused-tests": "error",
        "jest/no-identical-title": "error",
        "jest/no-jasmine-globals": "error",
        "jest/no-jest-import": "error",
        "jest/no-mocks-import": "error",
        "jest/no-test-callback": "error",
        "jest/no-test-prefixes": "error",
        "jest/no-truthy-falsy": "warn",
        "jest/prefer-strict-equal": "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": "error",
        "jest/valid-describe": "error",
        "jest/valid-expect-in-promise": "error",	
        "jest/valid-expect": "error",
        "jest/prefer-todo": "warn",
        "jest/prefer-called-with": "warn"
    },
    "root": true
}

Example Project

The problem can be seen in the following projects:

What is the current bug behavior?

The code_quality job reports degraded code quality for 21 of the rules above (all jest rules except jest/no-disabled-tests, jest/no-focused-tests, jest/no-identical-title, jest/valid-expect) for every analyzed source code file (excluding test files), which can be seen in the merge requests linked above. This may just be an issue with an out of date codeclimate.

What is the expected correct behavior?

No code quality issues should be reported as these are valid rules per https://github.com/jest-community/eslint-plugin-jest#rules, and per https://docs.codeclimate.com/docs/eslint codeclimate supports eslint-plugin-jest. When run from the projects' eslint, no errors are reported. These jobs can also be seen the projects noted above.

Output of checks

This bug occurs on GitLab.com (at this moment running 12.0.0-pre 8104b83f).