codeclimate / codeclimate-eslint

Code Climate Engine for ESLint
MIT License
95 stars 93 forks source link

Add support for testing library plugin #508

Closed sombreroEnPuntas closed 3 years ago

sombreroEnPuntas commented 3 years ago

Add support for testing library plugin

Actual Behavior

Fails with:

error: (CC::CLI::Analyze::EngineFailure) engine eslint failed with status 1 and stderr 
Module not supported: eslint-plugin-testing-library

Expected Behavior

Does not fail :)

Steps to reproduce

.codeclimate.yml:

version: 2
plugins:
  eslint:
    enabled: true
    config: '.eslintrc.js'
exclude_patterns:
  - 'dist'
  - 'node_modules'

.eslintrc.js

module.exports = {
  extends: ['@lego/eslint-config-react', 'plugin:testing-library/react', '../.eslintrc.js'],
  plugins: ['react', 'testing-library'],
  rules: {
    'react/jsx-boolean-value': ['error', 'never'],
    'react/jsx-no-bind': 'off',
    'react/jsx-child-element-spacing': 'off',
    'react/jsx-sort-props': 'off',
    'testing-library/no-manual-cleanup': 'error',
    'testing-library/no-wait-for-empty-callback': 'error',
    'testing-library/prefer-explicit-assert': 'error',
    'testing-library/prefer-presence-queries': 'error',
    'testing-library/prefer-screen-queries': 'error',
    'testing-library/prefer-wait-for': 'error',
  },
};

DEBUG DUMP

Starting analysis
I, [2020-12-10T21:56:37.373994 #1]  INFO -- : starting engine eslint
D, [2020-12-10T21:56:37.392070 #1] DEBUG -- : /config.json content: {"enabled"=>true, "config"=>".eslintrc.js", "channel"=>"stable", "include_paths"=>[".cache/", ".codeclimate.yml", ".env", ".env.local", ".eslintrc.js", ".npmrc", ".prettierrc.js", ".vscode/", "__mocks__/", "babel.config.js", "declarations.d.ts", "jest-setup.ts", "jest.config.js", "package-lock.json", "package.json", "public/", "src/", "tsconfig.json"], "debug"=>"1"}
D, [2020-12-10T21:56:37.407998 #1] DEBUG -- : docker run: ["docker", "run", "--name", "cc-engines-eslint-stable-995a21c8-aaed-49fd-984e-1ba559515de5", "--cap-drop", "all", "--label", "com.codeclimate.label=499eec8c-5894-4e51-ab91-b47e38260aef", "--log-driver", "none", "--memory-swap", "-1", "--net", "none", "--rm", "--volume", "/Users/matias.fornes/Projects/b2b-cpc-trade-activation-monorepo/frontend:/code:ro", "--volume", "/tmp/cc/5efc304b-cd18-4ff8-a6f4-cdab5f1f189b:/config.json:ro", "--user", "9000:9000", "--memory", "1024000000", "codeclimate/codeclimate-eslint"]
D, [2020-12-10T21:56:43.494626 #1] DEBUG -- : engine stderr: Module not supported: eslint-plugin-testing-library
D, [2020-12-10T21:56:43.500406 #1] DEBUG -- : engine stderr: /usr/src/app/lib/validate_config.js:17
D, [2020-12-10T21:56:43.500778 #1] DEBUG -- : engine stderr:         throw e;
D, [2020-12-10T21:56:43.500853 #1] DEBUG -- : engine stderr:         ^
D, [2020-12-10T21:56:43.501015 #1] DEBUG -- : engine stderr: 
D, [2020-12-10T21:56:43.501057 #1] DEBUG -- : engine stderr: Error: Cannot read config file: /.eslintrc.js
D, [2020-12-10T21:56:43.501090 #1] DEBUG -- : engine stderr: Error: Cannot find module '/.eslintrc.js'
D, [2020-12-10T21:56:43.501256 #1] DEBUG -- : engine stderr: Referenced from: /code/.eslintrc.js
D, [2020-12-10T21:56:43.501345 #1] DEBUG -- : engine stderr:     at Function.Module._resolveFilename (module.js:476:15)
D, [2020-12-10T21:56:43.501449 #1] DEBUG -- : engine stderr:     at module.exports (/usr/local/node_modules/resolve-from/index.js:14:16)
D, [2020-12-10T21:56:43.501597 #1] DEBUG -- : engine stderr:     at module.exports (/usr/local/node_modules/require-uncached/index.js:11:17)
D, [2020-12-10T21:56:43.501789 #1] DEBUG -- : engine stderr:     at loadJSConfigFile (/usr/local/node_modules/eslint/lib/config/config-file.js:160:16)
D, [2020-12-10T21:56:43.501877 #1] DEBUG -- : engine stderr:     at loadConfigFile (/usr/local/node_modules/eslint/lib/config/config-file.js:215:22)
D, [2020-12-10T21:56:43.502026 #1] DEBUG -- : engine stderr:     at load (/usr/local/node_modules/eslint/lib/config/config-file.js:535:18)
D, [2020-12-10T21:56:43.502093 #1] DEBUG -- : engine stderr:     at configExtends.reduceRight.e (/usr/local/node_modules/eslint/lib/config/config-file.js:424:36)
D, [2020-12-10T21:56:43.502258 #1] DEBUG -- : engine stderr:     at Array.reduceRight (native)
D, [2020-12-10T21:56:43.502393 #1] DEBUG -- : engine stderr:     at applyExtends (/usr/local/node_modules/eslint/lib/config/config-file.js:408:28)
D, [2020-12-10T21:56:43.502475 #1] DEBUG -- : engine stderr:     at Object.load (/usr/local/node_modules/eslint/lib/config/config-file.js:566:22)
I, [2020-12-10T21:56:43.603255 #1]  INFO -- : finished engine eslint
error: (CC::CLI::Analyze::EngineFailure) engine eslint failed with status 1 and stderr 
Module not supported: eslint-plugin-testing-library
/usr/src/app/lib/validate_config.js:17
        throw e;
        ^

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '/.eslintrc.js'
Referenced from: /code/.eslintrc.js
    at Function.Module._resolveFilename (module.js:476:15)
    at module.exports (/usr/local/node_modules/resolve-from/index.js:14:16)
    at module.exports (/usr/local/node_modules/require-uncached/index.js:11:17)
    at loadJSConfigFile (/usr/local/node_modules/eslint/lib/config/config-file.js:160:16)
    at loadConfigFile (/usr/local/node_modules/eslint/lib/config/config-file.js:215:22)
    at load (/usr/local/node_modules/eslint/lib/config/config-file.js:535:18)
    at configExtends.reduceRight.e (/usr/local/node_modules/eslint/lib/config/config-file.js:424:36)
    at Array.reduceRight (native)
    at applyExtends (/usr/local/node_modules/eslint/lib/config/config-file.js:408:28)
    at Object.load (/usr/local/node_modules/eslint/lib/config/config-file.js:566:22)
D, [2020-12-10T21:56:43.603520 #1] DEBUG -- : backtrace: /usr/src/app/lib/cc/analyzer/raising_container_listener.rb:23:in `finished'
    /usr/src/app/lib/cc/analyzer/composite_container_listener.rb:13:in `block in finished'
    /usr/src/app/lib/cc/analyzer/composite_container_listener.rb:13:in `each'
    /usr/src/app/lib/cc/analyzer/composite_container_listener.rb:13:in `finished'
    /usr/src/app/lib/cc/analyzer/bridge.rb:52:in `block (2 levels) in run'
    /usr/src/app/lib/cc/analyzer/formatters/plain_text_formatter.rb:63:in `with_spinner'
    /usr/src/app/lib/cc/analyzer/formatters/plain_text_formatter.rb:41:in `block in engine_running'
    /usr/src/app/lib/cc/analyzer/formatters/formatter.rb:31:in `engine_running'
    /usr/src/app/lib/cc/analyzer/formatters/plain_text_formatter.rb:40:in `engine_running'
    /usr/src/app/lib/cc/analyzer/bridge.rb:37:in `block in run'
    /usr/src/app/lib/cc/analyzer/bridge.rb:34:in `each'
    /usr/src/app/lib/cc/analyzer/bridge.rb:34:in `run'
    /usr/src/app/lib/cc/cli/analyze.rb:36:in `run'
    /usr/src/app/lib/cc/cli/command.rb:73:in `execute'
    /usr/src/app/lib/cc/cli/runner.rb:25:in `run'
    /usr/src/app/lib/cc/cli/runner.rb:9:in `run'
    /usr/src/app/bin/codeclimate:12:in `<main>'
ArsenMelikyan commented 3 years ago

@sombreroEnPuntas I just opened a PR for this ~but they still use Node 6 and testing-library plugin requires at least v10 so they would have to upgrade Node version first. Let's hope that's going to happen soon enough.~

efueger commented 3 years ago

HI @ArsenMelikyan - thanks for the PR! Closing this issue.