eslint-plugin-header
eslint-plugin-header copied to clipboard
Copyright header recognition does not work with CLI scripts
I have a CLI tool written in TypeScript which needs to have a Shebang in the top of the file. Thus the copyright header has to follow afterwards and this is not recognized with my config:
"header/header": [
"error",
"block",
[
{
"pattern": "Copyright",
"template": "Copyright Test"
}
],
2
],
cli.ts
#!/usr/bin/env node
/*
* Copyright (C) 2021
*/
// Some code here...
@Stuk I've seen in your code that you are skipping comments of type "Shebang":
https://github.com/Stuk/eslint-plugin-header/blob/d1e2575f6e6d12b2fdc167c07885242082cc944f/lib/rules/header.js#L19-L23
But in your commentParser.js there is no return with that type. Only "line" and "block" are returned:
https://github.com/Stuk/eslint-plugin-header/blob/d1e2575f6e6d12b2fdc167c07885242082cc944f/lib/comment-parser.js#L6-L24
I am using Node v16 and Windows 10 and version 3.1.1 of "eslint-plugin-header". I also saw that you recently added a test case (https://github.com/Stuk/eslint-plugin-header/commit/46db23ac73b0668dfeecf4040dde13c22ce5aab3) for it but it doesn't work for me.
When using the fix option, the plugin also adds my header template multiple times in this case:

Can confirm had the same issue.
It used to work fine in 3.0.0, but it is broken in 3.1.1
This works with 3.0.0: https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-init/bin/index.js

But it fails in 3.1.1:
