Conversation
| code: "/* Copyright 20\n Author: abc@example.com */", | ||
| options: ["block", {pattern: "^\\s*Copyright \\(c\\) \\d{4} ABC Inc. All rights reserved.\\s*$"}, "Copyright information error. Please add below line to your file.\n\tCopyright (c) " + new Date().getFullYear() + " ABC Inc. All rights reserved"], | ||
| errors: [ | ||
| {message: "Copyright information error. Please add below line to your file.\n\tCopyright (c) " + new Date().getFullYear() + " ABC Inc. All rights reserved"} |
There was a problem hiding this comment.
@Stuk, maybe I am missing something, why would this fail in 2018?
The pattern does not match the code, which would cause it to throw an error. And the supplied error message would match the output since new Date().getFullYear() is used in both places.
There was a problem hiding this comment.
@Stuk do you mean it will fail in 2100 ?
|
Regarding #6, I agree that avoiding duplication would be ideal. But until a more elegant solution is submitted, I think this should be merged. I would love to be able to use this plugin, but I'm not going to confuse our 100+ engineers with an ambiguous error Worst case scenario, if someone has a complicated header, they could link to a wiki page or a gist in the eslint error message that contains the full header. |
|
just chiming in here, but it seems to me like the only reason you might need to duplicate to an In such a case, would it make more sense to convert the regexps into strings (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)? that way, if you're not using a regular expression, it's easy because you can output the correct string. if you're using a regular expression (in the case of an array, atleast one regular expression), you can iterate through the array and concat the lines together, and in the case you get a regexp, make it a string before joining them? You could even surround the regexp strings with something like |
Hi Stuk, we are using this header checker plugin and for some reason we need to define the error message by ourselves.
So I expand another argument to store it.