Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cannot specify a custom renderer #567

Closed
onigoetz opened this issue Jan 17, 2019 · 2 comments
Closed

Cannot specify a custom renderer #567

onigoetz opened this issue Jan 17, 2019 · 2 comments

Comments

@onigoetz
Copy link
Contributor

Description

It's impossible to set a custom renderer for listr, you can only use the default renderers because of the configuration validator.

I'd be happy to make a pull request for this if that's something you want to support.

Steps to reproduce

When I set this in the configuration

module.exports = {
    linters: {
        // ...
    },
    renderer: require("./my-custom-renderer")
}

It fails with

Could not parse lint-staged config.

● Validation Error:

  Option "renderer" must be of type:
    string
  but instead received:
    function

  Example:
  {
    "renderer": "update"
  }

Please refer to https://github.com/okonet/lint-staged#configuration for more information...

Debug Logs

expand to view
  lint-staged:bin Running `lint-staged@8.1.0` +0ms
  lint-staged:find-bin Could not load package.json using `process.cwd()` +0ms
  lint-staged Loading config using `cosmiconfig` +0ms
  lint-staged Successfully loaded config from `/home/sgoetz/workspace/experiments/git-hooks/configuration/lint-staged.config.js`:
  lint-staged { linters:
  lint-staged    { '*.{java}': '/home/sgoetz/workspace/experiments/git-hooks/scripts/run-hook.sh DGL-1',
  lint-staged      '*.{js,jsx}': '/home/sgoetz/workspace/experiments/git-hooks/scripts/run-hook.sh DGL-3',
  lint-staged      '*.{ts,tsx}': '/home/sgoetz/workspace/experiments/git-hooks/scripts/run-hook.sh DGL-3_1',
  lint-staged      '*.{css,scss}': '/home/sgoetz/workspace/experiments/git-hooks/scripts/run-hook.sh DGL-5' },
  lint-staged   ignore:
  lint-staged    [ '*.min.{js,jsx,css,scss}',
  lint-staged      '**/vendor/**/*.{js,jsx,css,scss,ts,tsx}' ],
  lint-staged   renderer: [Function: CustomRenderer] } +14ms
  lint-staged:cfg Normalizing config +0ms
  lint-staged:cfg Validating config +1ms
Could not parse lint-staged config.

● Validation Error:

  Option "renderer" must be of type:
    string
  but instead received:
    function

  Example:
  {
    "renderer": "update"
  }

Please refer to https://github.com/okonet/lint-staged#configuration for more information...

Please make sure you have created it correctly.
See https://github.com/okonet/lint-staged#configuration.

Environment

  • OS: Ubuntu 18.0.4
  • Node.js: 8.11.4
  • lint-staged: 8.1.0
@okonet
Copy link
Collaborator

okonet commented Jan 17, 2019

Yes, please create a PR that fixes this. It's not intentional and is an issue on our side.

@okonet okonet added the bug label Jan 17, 2019
okonet pushed a commit that referenced this issue Jan 28, 2019
…rs (#572)

- Improve configuration validation
- use `yup` to validate
- add more tests

Fixes #567
@okonet
Copy link
Collaborator

okonet commented Jan 28, 2019

🎉 This issue has been resolved in version 8.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants