Open just-at-uber opened 3 years ago
Another option instead of supporting capture groups is to give simple const primitives to us, such as:
const CURRENT_FULL_YEAR = 2021;
const START_FULL_YEAR = 2017; // can be passed in and configured by user.
then rule becomes:
{
startFullYear: '2017',
pattern: ` Copyright ({START_FULL_YEAR}\\-)?{CURRENT_FULL_YEAR} Uber Technologies Inc\.`,
template: ` Copyright ({START_FULL_YEAR}\\-)?{CURRENT_FULL_YEAR} Uber Technologies Inc.`,
}
then header can support (when year ends):
// Copyright 2017-2021 Uber Technologies Inc.
// Copyright 2021 Uber Technologies Inc.
Hi @just-at-uber ,
I have extended the plugin to support an requeriment of mine, which is similar to yours. If the PR https://github.com/Stuk/eslint-plugin-header/pull/53 gets merged, you can use the newly added option to fulfill your requirment too.
Cheers!
Hi. Just FYI, @just-at-uber has left Uber and isn't responding to emails anymore. This is the OSPO, where things got redirected.
Hi @jonathanbaker7, Noted. Thanks for informing. :)
Right now this library can detect if a given header is in violation of the rules specified in a pattern. If the pattern is partially matched, it would be nice to be able to reference capture groups in the pattern and apply those capture groups into the template (if matched), otherwise leave blank.
For example: Say my header & configuration looked like the following:
Actual behavior
header:
rule:
and time ticked over to 2021
header (fixed):
Desired behavior
header:
rule:
When the year ticks over to 2021, it would be nice if it updated current year only, and left first year as-is.
header (fixed):