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

prettier-js-mode reformats file even when file is in .prettierignore #62

Open
tamouse opened this issue Nov 29, 2019 · 3 comments
Open

Comments

@tamouse
Copy link

tamouse commented Nov 29, 2019

I have the following in my emacs init.el:

(use-package prettier-js 
  :ensure t
  :config
  (add-hook 'web-mode-hook
	    #'(lambda ()
		(enable-minor-mode
		 '("\\.jsx?\\'" . prettier-js-mode)
		 ))
	    )
  (add-hook 'rjsx-mode-hook 'prettier-js-mode)
  )

In a project, I have this for .prettierignore:

*.spec.js
*.test.js

When I visit a file, src/score_to_grade.spec.js, it shows Prettier in the mode line, but on save, it reformats the file.

I seems that it's ignoring the ignore settings?

Additionally, if I use // prettier-ignore-start ... // prettier-ignore-end these are also not respected and the code between them is formatted in emacs prettier-js-mode.

If I run prettier from my terminal, both of these work as expected.

Versions:

  • Emacs: GNU Emacs 26.2
  • prettier-js: 20180109.726
  • prettier: 1.19.1 (latest)
@rtm
Copy link

rtm commented Jan 16, 2021

Is there any known workaround for this issue, or any update?

@rtm
Copy link

rtm commented Jan 24, 2021

// prettier-ignore-{start,end} don't work for me in JS files at least even from the command line. I don't think this features is defined to work for JavaScript. // prettier-ignore does work, though. Therefore, I think there are two separate problems happening here.

@rtm
Copy link

rtm commented Jan 24, 2021

The problem with .prettierignore is that internally this mode copies the file into a temporary buffer and then applies prettier to that, so of course the filenames do not match. I'm not quite sure why it would be doing that. Wouldn't it be good enough to just execute prettier in place with the --write option?

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

No branches or pull requests

2 participants