eslint-plugin-header icon indicating copy to clipboard operation
eslint-plugin-header copied to clipboard

Copyright header recognition does not work with CLI scripts

Open bennycode opened this issue 4 years ago • 3 comments

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...

bennycode avatar Apr 22 '21 09:04 bennycode

@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.

bennycode avatar Apr 22 '21 10:04 bennycode

When using the fix option, the plugin also adds my header template multiple times in this case:

image

bennycode avatar Apr 22 '21 10:04 bennycode

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

image

But it fails in 3.1.1:

image

slorber avatar Jun 10 '21 13:06 slorber