eslint-plugin-header
eslint-plugin-header copied to clipboard
Better error message
Hey Stewart!
It'd be nice to have clearer error messages. Right now "header error" is a bit generic and might be confusing.
We're ready to provide a PR, but I wanted to discuss solutions. Would it make sense to make an expectedHeader
option to provide an exact expected message value?
Expected file to start with:
// Copyright 2017 Cie Name Ltd.
This would allow to pass filled copyright message that is easy to copy/paste.
I feel an auto-fixer (eg eslint --fix
) would also require such an option.
Hey Simon!
Yeah, I agree they're a bit generic, mainly because I didn't put in the effort to make them better!
One thing that seems ideal would be to use the existing configuration header in the error message, however I'm guessing you're using the regex configuration, which isn't copy and paste-able?
The concern I have is that the copyright headers I've seen span many lines, and having a duplicate matcher and ideal copyright header seems redundant, and also including a multi-line header in the ESLint output could be a bit verbose.
The examples I've seen so far mainly need a regex to match the year, so I'm now wondering if it would be worth having a "templated" header that allows you to embed {year}
(or something) in the expected header. This could act as \d{4}
in the matcher, then be replaced with the current year in the error message/--fix
functionality. This would reduce the duplication within the configuration.
What do you think?
year would be good. Actually, you could have {year}
(match any year, default to current year), {initialYear}
(file create year from git/etc), {currentYear}
(file update year from git/etc, falling back to the current year)