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

fix(cli-options): rules should be passed as an object instead of array of strings #39

Merged
merged 1 commit into from
May 27, 2018

Conversation

emmenko
Copy link
Contributor

@emmenko emmenko commented Apr 4, 2018

Fixes: #27 (comment)

In the ESLint docs for the CLIEngine clearly states that rules is a JSON object and not an array of strings.

The "string" version (e.g. --rule "quotes: [2, double]") is only used by the CLI. When the args are parsed, the rule is also a JSON object.

In the case of this library, the jest-runner-eslint.config.js is a js file, so we can pass an object directly.

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

Now ESLint properly receives the additional rules.

@tdeekens
Copy link

Thanks a lot for the fix. Any update or release plan on this? Would love to use this fix on a side project of mine too.

@ljharb ljharb requested a review from rogeliog April 11, 2018 06:55
@emmenko
Copy link
Contributor Author

emmenko commented May 22, 2018

@rogeliog any chance we can get this merged? 😇

@rogeliog rogeliog merged commit 3bd91fe into jest-community:master May 27, 2018
@rogeliog
Copy link
Member

I just published it under 0.6.0-0, let me know how it works for you and I'll promote it to 0.6.0

@tdeekens
Copy link

Thanks. Note: I am a colleague of @emmenko.

  1. Tried it out on our project where we until now used @emmenko fork ➡ works as expected
  2. Tried it out on a side project of mine (where I don't use CLI options ➡ works fine as well

@emmenko emmenko deleted the nm-fix-rules-cli-option branch May 27, 2018 20:26
@emmenko
Copy link
Contributor Author

emmenko commented May 27, 2018

Awesome, thanks a lot! 🙌

@rogeliog
Copy link
Member

Awesome, just published 0.6.0 😄

@tdeekens
Copy link

Horray. Thanks all. #teamwork

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

Successfully merging this pull request may close these issues.

Unknown option "cliOptions" + cache
4 participants