eslint-plugin-header icon indicating copy to clipboard operation
eslint-plugin-header copied to clipboard

Fix for .vue files to inject header comment in script tag.

Open just-at-uber opened this issue 4 years ago • 4 comments

This change essentially scans for a <script> tag as the first element in a .vue file and checks for any comments within the script block. If it doesn't find a comment, it will inject as expected on auto-fix.

There are caveats to be aware of:

  • <script> tag must be defined within a .vue file, otherwise the linter will crash.
  • <script> tag must be defined at the top of a .vue file, otherwise the linter won't realize the comment is in the file and will inject it multiple times.
  • <script> tag must contain at least export default { name: 'component-name' } otherwise the linter won't realize the comment is in the file and will inject it multiple times.

Thanks for maintaining this project as this suits exactly my projects needs (apart from no .vue support). Hopefully other developers in the community are able to fix the above caveats for their needs.

Thanks!

Screenshots

Before lint Screen Shot 2020-11-20 at 5 30 56 PM

After lint Screen Shot 2020-11-20 at 5 31 08 PM

just-at-uber avatar Nov 21 '20 01:11 just-at-uber

Thanks for the PR!

Would you be able to add some tests please? And also, would you update the Readme with an example for a .vue file and the caveats you mention above?

Stuk avatar Nov 22 '20 07:11 Stuk

No problem at all. Will try to update today. Thanks!

just-at-uber avatar Nov 23 '20 17:11 just-at-uber

Hi @Stuk ,

I have done the following:

  • Added new tests to test out Vue integration.
  • Updated README with instructions on getting Vue to work with eslint & eslint-plugin-header.
  • Updated README with Vue specific examples.
  • Updated README examples to be more user friendly and reduce copy / paste errors.

Please let me know if you need anything else from me.

Thanks!

just-at-uber avatar Nov 23 '20 21:11 just-at-uber

Any idea when this will get merged in? Is there anything I'm missing from getting this merged?

just-at-uber avatar Sep 10 '21 22:09 just-at-uber