eslint-plugin-header
eslint-plugin-header copied to clipboard
Fix for .vue files to inject header comment in script tag.
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 leastexport 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
After lint
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?
No problem at all. Will try to update today. Thanks!
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!
Any idea when this will get merged in? Is there anything I'm missing from getting this merged?