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

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

just-at-uber
Copy link

@just-at-uber just-at-uber commented Nov 21, 2020

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 just-at-uber mentioned this pull request Nov 21, 2020
@Stuk
Copy link
Owner

Stuk commented Nov 22, 2020

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?

@just-at-uber
Copy link
Author

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

@just-at-uber
Copy link
Author

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
Copy link
Author

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

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

Successfully merging this pull request may close these issues.

None yet

2 participants