question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document how to integrate in pre-commit with plugins

See original GitHub issue

Environments:

  • Prettier Version: 1.19.1
  • Running Prettier via: pre-commit
  • Runtime: node v12.13.1
  • Operating System: Linux

Steps to reproduce:

All I want to do is to integrate the prettier-xml plugin into pre-commit.

I tried with this, but it doesn’t work:

  - repo: https://github.com/prettier/prettier
    rev: "1.19.1"
    hooks:
      - id: prettier
        name: prettier xml plugin
        additional_dependencies:
          - "@prettier/plugin-xml@0.5.0"
        args:
          - --with-node-modules
        files: \.xml$

Expected behavior: Reformat xml files

Actual behavior:

Running pre-commit run -a:

prettier xml plugin......................................................Failed
hookid: prettier

[error] No parser could be inferred for file: web_responsive/views/web.xml
[error] No parser could be inferred for file: web_responsive/static/src/xml/apps.xml
[error] No parser could be inferred for file: web_notify/views/res_users_demo.xml
[error] No parser could be inferred for file: web_responsive/static/src/xml/form_view.xml
[error] No parser could be inferred for file: web_notify/views/web_notify.xml
[error] No parser could be inferred for file: web_tree_many2one_clickable/views/assets.xml
[error] No parser could be inferred for file: web_dialog_size/static/src/xml/web_dialog_size.xml
[error] No parser could be inferred for file: web_environment_ribbon/view/base_view.xml
[error] No parser could be inferred for file: web_dialog_size/templates/assets.xml
[error] No parser could be inferred for file: web_ir_actions_act_view_reload/views/web_ir_actions_act_view_reload.xml
[error] No parser could be inferred for file: web_responsive/views/assets.xml
[error] No parser could be inferred for file: web_responsive/views/res_users.xml
[error] No parser could be inferred for file: web_responsive/static/src/xml/navbar.xml
[error] No parser could be inferred for file: web_environment_ribbon/data/ribbon_data.xml
[error] No parser could be inferred for file: web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml
[error] No parser could be inferred for file: web_widget_bokeh_chart/views/web_widget_bokeh_chart.xml

Workaround:

Configuration from https://github.com/prettier/plugin-xml/issues/17#issuecomment-555445966 works, but I guess that’s not what you want to recommend to use.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
thorn0commented, Mar 23, 2020

fixed by https://github.com/prettier/prettier/pull/7508

This works for me:

- repo: https://github.com/prettier/prettier
  rev: "2.0.2"
  hooks:
    - id: prettier
      additional_dependencies:
        - "@prettier/plugin-xml@0.7.2"
      args:
        - --plugin=@prettier/plugin-xml
      files: \.xml$
0reactions
asottilecommented, Mar 23, 2020

awesome! thanks a ton @fisker and @thorn0 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

pre-commit
Once you have pre-commit installed, adding pre-commit plugins to your project is done with the .pre-commit-config.yaml configuration file.
Read more >
4 pre-commit Plugins to Automate Code Reviewing and ...
You can add different plugins to your pre-commit pipeline. Once your files are committed, they will be checked by these plugins. Unless all ......
Read more >
Pre-commit integration — Pylint 2.12.2 documentation
Pre-commit integration ¶ ; pylint needs to import modules and dependencies to work correctly, the hook only works with a local installation of ......
Read more >
Automatically format and lint code with pre-commit - Interrupt
The best way to document a project's style is to have a tool automate it. If a pull request has any style violations,...
Read more >
Pre-commit Hook - Prettier
You can use Prettier with a pre-commit tool. This can re-format your files that are marked as “staged” via `git add` before you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found