Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unknown option "cliOptions" + cache #27

Closed
fdubost opened this issue Jan 18, 2018 · 7 comments · Fixed by #39
Closed

Unknown option "cliOptions" + cache #27

fdubost opened this issue Jan 18, 2018 · 7 comments · Fixed by #39

Comments

@fdubost
Copy link

fdubost commented Jan 18, 2018

Hi !

When I use the cliOptions params, I get this error :

Unknown option "cliOptions"  with value {"cacheLocation": ".eslintcache"} was found.

jest@22.1.2
jest-runner-eslint@0.4.0-0

On the other hand, cache doesn't seems to work :

  • no .eslintcache file is created,
  • when I run the command a second time, it take the same time.

Thanks for your help !

@ljharb
Copy link
Collaborator

ljharb commented Jan 18, 2018

What’s your full jest config?

@fdubost
Copy link
Author

fdubost commented Jan 18, 2018

An example here :

const path = require('path');
const rootDir = path.join(__dirname, '../../');

module.exports = {
  runner: 'jest-runner-eslint',
  rootDir: `${rootDir}`,
  displayName: 'lint',
  testMatch: ['<rootDir>/src/**/*.js'],
  cliOptions: {
    cacheLocation: '.eslintcache',
  },
};

@rogeliog
Copy link
Member

Try putting this in your package.json

"jest-runner-eslint": {
  "cliOptions": {
    "cacheLocation": ".eslintcache"
  }
}

@fdubost
Copy link
Author

fdubost commented Jan 30, 2018

@rogeliog I have no error but no .eslintcache file is created... 😥

@dferber90
Copy link

It's not pointed out clearly in the docs that there are two configuration files.
If I read them correctly, it seems like you're mixing the config files up.

The two config files:

  • jest.config.js
  • jest-runner-eslint.config.js

The second one would take the cliOptions part.

However I couldn't get it to work with custom ESLint rules either :/

@tdeekens
Copy link

This is the current setup in a jest-runner-eslint.config.js file.

module.exports = {
  cliOptions: {
    format: 'node_modules/eslint-formatter-pretty',
    rule: [
      'import/no-unresolved: 2',
      'prettier/prettier: ["error", {"trailingComma": "es5", "singleQuote": true}]',
    ],
  },
};

The config seems to end up in ESLint correctly and is parsed nicely.

{ cacheLocation: '.eslintcache',
     configFile: null,
     envs: [],
     extensions: [ '.js' ],
     fix: false,
     format: 'node_modules/eslint-formatter-pretty',
     globals: [],
     ignorePath: null,
     useEslintrc: true,
     ignore: true,
     allowInlineConfig: true,
     parser: null,
     parserOptions: null,
     plugins: [],
     rules:
      [ 'import/no-unresolved: 2',
        'prettier/prettier: ["error", {"trailingComma": "es5", "singleQuote": true}]' ],
     rulePaths: [] } }

However, the runner does not report a failing lint run whenever any of the rules does not match. Any ideas where things go wrong?

@tdeekens
Copy link

This seems to be something with the normalization of CLI options maybe. I checked what the node_modules/.bin/eslint receives as arguments. In case without the runner it gets

  rule:
   { 'import/no-unresolved': 2,
     'prettier/prettier': [ 'error', [Object] ] },

when running it with jest-runner-eslint the config above makes ESLint receive

  rules:
   [ 'import/no-unresolved: 2',
     'prettier/prettier: ["error", {"trailingComma": "es5", "singleQuote": true}]' 
  ],

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
5 participants