Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Not possible to use plugins? #16

Open
OJFord opened this issue Sep 28, 2020 · 4 comments
Open

Not possible to use plugins? #16

OJFord opened this issue Sep 28, 2020 · 4 comments

Comments

@OJFord
Copy link

OJFord commented Sep 28, 2020

I'm trying to use prettier-plugin-svelte, but I think it's detected from being installed rather than in package.json(?) and so since there's no (good) way to put it in the pre-commit environment, it isn't picked up?

@fisker
Copy link
Member

fisker commented Oct 21, 2020

Will this work use additional_dependencies ?

- repo: https://github.com/prettier/pre-commit
  rev: main
  hooks:
    - id: prettier
      additional_dependencies:
        - prettier-plugin-svelte:1.4.1

@joao-p-marques
Copy link

joao-p-marques commented Oct 21, 2020

Hi. I am having the same issue. When I try to install @prettier/plugin-xml, I get:

Executable `prettier` not found

My pre-commit config:

  - repo: https://github.com/prettier/pre-commit
    rev: v2.1.2
    hooks:
      - id: prettier
        name: prettier + plugin-xml
        additional_dependencies:
          - "@prettier/plugin-xml@0.12.0"
        args:
          - --plugin=@prettier/plugin-xm

It works fine without the plugin.

I am trying to migrate from https://github.com/prettier/prettier to https://github.com/prettier/pre-commit

joao-p-marques added a commit to Tecnativa/pre-commit that referenced this issue Oct 21, 2020
As in prettier#16

This frees args keywork, so that it can be used downstream in pre-commit
hooks

Fixes prettier#16
joao-p-marques added a commit to Tecnativa/pre-commit that referenced this issue Oct 21, 2020
As in https://github.com/prettier/prettier/blob/master/.pre-commit-hooks.yaml#L3

This frees args keywork, so that it can be used downstream in pre-commit
hooks

Fixes prettier#16
joao-p-marques added a commit to Tecnativa/pre-commit that referenced this issue Oct 21, 2020
This frees additional_dependencies keyword, so that it can be used downstream in pre-commit
hooks

Fixes prettier#16
joao-p-marques added a commit to Tecnativa/pre-commit that referenced this issue Oct 21, 2020
As in https://github.com/prettier/prettier/blob/master/.pre-commit-hooks.yaml#L3

This frees args keyword, so that it can be used downstream in pre-commit
hooks

Fixes prettier#16
@joao-p-marques
Copy link

This should be fixed with the PRs mentioned above.

Seems like the problem was that, in https://github.com/prettier/pre-commit/blob/main/.pre-commit-hooks.yaml, hook is defining additional_dependencies and args, that are needed for prettier to work. However, if we need to define more in our hook, the will be rewritten.

Moving them to separate definitions should work.

In the meantime, another workaround is to copy the needed values:

  - repo: https://github.com/prettier/pre-commit
    rev: v2.1.2
    hooks:
      - id: prettier
        name: prettier + plugin-xml
        additional_dependencies:
          - prettier@2.1.2
          - "@prettier/plugin-xml@0.12.0"
        args:
          - --write
          - --list-different
          - --ignore-unknown
          - --plugin=@prettier/plugin-xml

@fisker
Copy link
Member

fisker commented Oct 21, 2020

It's also possible to use plugins in config file

{
  "plugins": [
    "@prettier/plugin-xml",
    "path/to/your/plugin"
  ]
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants