Code Monkey home page Code Monkey logo

eslint-plugin-header's Introduction

eslint-plugin-header

ESLint plugin to ensure that files begin with given comment.

Often you will want to have a copyright notice at the top of every file. This ESLint plugin checks that the first comment in every file has the contents defined in the rule settings.

Usage

This rule takes 1, 2 or 3 arguments with an optional settings object.

1 argument

In the 1 argument form the argument is the filename of a file that contains the comment(s) that should appear at the top of every file:

{
    "plugins": [
        "header"
    ],
    "rules": {
        "header/header": [2, "config/header.js"]
    }
}

config/header.js:

// Copyright 2015
// My company

Due to limitations in eslint plugins, the file is read relative to the working directory that eslint is executed in. If you run eslint from elsewhere in your tree then the header file will not be found.

2 arguments

In the 2 argument form the first must be either "block" or "line" to indicate what style of comment should be used. The second is either a string (including newlines) of the comment, or an array of each line of the comment.

{
    "plugins": [
        "header"
    ],
    "rules": {
        "header/header": [2, "block", "Copyright 2015\nMy Company"]
    }
}

3 arguments

The optional third argument which defaults to 1 specifies the number of newlines that are enforced after the header.

Zero newlines:

{
    "plugins": [
        "header"
    ],
    "rules": {
        "header/header": [2, "block", [" Copyright now","My Company "], 0]
    }
}
/* Copyright now
My Company */ console.log(1)

One newline (default)

{
    "plugins": [
        "header"
    ],
    "rules": {
        "header/header": [2, "block", [" Copyright now","My Company "], 1]
    }
}
/* Copyright now
My Company */
console.log(1)

two newlines

{
    "plugins": [
        "header"
    ],
    "rules": {
        "header/header": [2, "block", [" Copyright now","My Company "], 2]
    }
}
/* Copyright now
My Company */

console.log(1)

Regular expressions

Instead of a string to be checked for exact matching you can also supply a regular expression. Be aware that you have to escape backslashes:

{
    "plugins": [
        "header"
    ],
    "rules": {
        "header/header": [2, "block", [
            {"pattern": " Copyright \\d{4}"},
            "My Company"
        ]]
    }
}

This would match:

/* Copyright 2808
My Company*/

When you use a regular expression pattern, you can also provide a template property, to provide the comment value when using eslint --fix:

{
    "plugins": [
        "header"
    ],
    "rules": {
        "header/header": [2, "block", [
            {"pattern": " Copyright \\d{4}", "template": " Copyright 2019"}, 
            "My Company"
        ]]
    }
}

Line Endings

The rule works with both unix and windows line endings. For ESLint --fix, the rule will use the line ending format of the current operating system (via the node os package). This setting can be overwritten as follows:

"rules": {
    "header/header": [2, "block", ["Copyright 2018", "My Company"], {"lineEndings": "windows"}]
}

Possible values are unix for \n and windows for \r\n line endings.

Examples

The following examples are all valid.

"block", "Copyright 2015, My Company":

/*Copyright 2015, My Company*/
console.log(1);

"line", ["Copyright 2015", "My Company"]]:

//Copyright 2015
//My Company
console.log(1)

"line", [{pattern: "^Copyright \\d{4}$"}, {pattern: "^My Company$"}]]:

//Copyright 2017
//My Company
console.log(1)

With more decoration

"header/header": [2, "block", [
    "************************",
    " * Copyright 2015",
    " * My Company",
    " ************************"
]
/*************************
 * Copyright 2015
 * My Company
 *************************/
 console.log(1);

License

MIT

eslint-plugin-header's People

Contributors

bangsadrengur avatar ctavan avatar dependabot[bot] avatar emoller avatar herzog31 avatar mhagmajer avatar pio-mie avatar pranaygp avatar stuk avatar tripodsan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eslint-plugin-header's Issues

different copyrights for different path

I have a repo in which different files should have different copyrights. Such files are separated by different folders. Is there a way to configure different copyrights for different relative paths?

matching fails unless content begins with space

Using rule:
'header/header': [2, 'line', 'my header comment.']
with file:

// my header comment.
console.log(1);

reports incorrect header. Changing rule to:
'header/header': [2, 'line', ' my header comment.']
will not report error and unblocks use.

In both rule cases --fix will produce:

// my header comment.
console.log(1);

if error is detected. (Added line per issue #24 Autofix adds new line has been removed.)

In my setup, I am using eslint 6.8.0.

Add Travis CI

I was looking at #12 and figured having some sort of CI like Travis would catch errors like this faster and speed up the review cycle :)

Using Regex and pattern/template doesn't work

Issue:
When using the regex pattern/template format like:

"header/header": [2, "block", [
        {"pattern": " Copyright \\d{4}", "template": " Copyright 2021"}, 
        "My Company"
    ]]

Each file is reporting as incorrect header. Using the original method of pointing to a .txt file works correctly, so I know plugin is functioning. I've tried every combination of not providing template, or doing "line" instead of block and none of them work when providing a template.

This is with eslint 7.6 and 7.25 (updating eslint did not fix the issue)

After each Autofix a new blank line is added after the file header

If a file has a file header, say for the year 2018, and if I then change the template to 2019 and run autofix, the file header will be correctly replaced, but also adds a blank line after the file header. It does that for every autofix. So over the years, blank lines will pile up.
Is that a known issue?

Example:

/* ***
 * Copyright 2018
*** */
console.log("hello");

When now the template is changed to use 2019, after auto-fix the file will look like this:

/* ***
 * Copyright 2019
*** */

console.log("hello");

Again, when the template is changed again to say 2020, the file will be auto-fixed to:

/* ***
 * Copyright 2020
*** */


console.log("hello");

Support capture groups in template

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:

// Copyright 2017-2020 Uber Technologies Inc.

rule:

const currentYear = (new Date()).getFullYear(); // = '2020'
...
{
    pattern: ` Copyright (20\\d{2}\\-)?${currentYear} Uber Technologies Inc\.`,
    template: ` Copyright ${currentYear} Uber Technologies Inc.`,
}

and time ticked over to 2021

header (fixed):

// Copyright 2021 Uber Technologies Inc.

Desired behavior

header:

// Copyright 2017-2020 Uber Technologies Inc.

rule:

const currentYear = (new Date()).getFullYear(); // = '2020'
...
{
    pattern: ` Copyright (?<firstYear>20\\d{2}\\-)?${currentYear} Uber Technologies Inc\.`,
    template: ` Copyright (\\k<firstYear>)${currentYear} Uber Technologies Inc.`,
}

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):

// Copyright 2017-2021 Uber Technologies Inc.

Empty first line breaks the header plugin

Currently if the first line is emtpy in the source file and the header starts at line 2 the fixer causes the header to be output many(non consistent but 10+ times) times in succession.

support .vue file

It would be nice if this package can support .vue file.
leadingComments[0] is HTML in .vue file.

Allow regexp in multline arrays

In case you have a very long copyright that spans several lines, you want to use the array variant. eg:

    'header/header': [2, 'block', ['',
      ' * Copyright 2018 Company. All rights reserved.',
      ' * This file is licensed to you under the Apache License, Version 2.0 (the "License");',
      ' * you may not use this file except in compliance with the License. You may obtain a copy',
      ' * of the License at http://www.apache.org/licenses/LICENSE-2.0',
      ' *',
      ' * Unless required by applicable law or agreed to in writing, software distributed under',
      ' * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS',
      ' * OF ANY KIND, either express or implied. See the License for the specific language',
      ' * governing permissions and limitations under the License.',
      ' ',
    ]]

but this is a problem when the year changes. so it would be cool to do:

    'header/header': [2, 'block', ['',
      / \* Copyright \d{4} Company\. All rights reserved\./,
      ' * This file is licensed to you under the Apache License, Version 2.0 (the "License");',
      ' * you may not use this file except in compliance with the License. You may obtain a copy',
      ' * of the License at http://www.apache.org/licenses/LICENSE-2.0',
      ' *',
      ' * Unless required by applicable law or agreed to in writing, software distributed under',
      ' * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS',
      ' * OF ANY KIND, either express or implied. See the License for the specific language',
      ' * governing permissions and limitations under the License.',
      ' ',
    ]]

but looking at the code, it currently just concatenates the array and matches with the entire comment.

ESLint: 7.x Compatibility

Updating to ESLint: 7.0.0, it seems like this plug-in stopped working.
In the previously working build-chain, I now get

INFO] Running 'npm ci' in /home/travis/build/opencast/opencast/modules/lti
[INFO] added 143 packages in 2.609s
...
[INFO] Running 'npm run eslint' in /home/travis/build/opencast/opencast/modules/lti
[INFO] 
[INFO] > opencast-lit-tools@ eslint /home/travis/build/opencast/opencast/modules/lti
[INFO] > eslint --config ../../docs/checkstyle/eslintrc.js src/main/resources/
[INFO] 
[ERROR] 
[ERROR] Oops! Something went wrong! :(
[ERROR] 
[ERROR] ESLint: 7.0.0
[ERROR] 
[ERROR] ESLint couldn't find the plugin "eslint-plugin-header".
[ERROR] 
[ERROR] (The package "eslint-plugin-header" was not found when loaded as a Node module from the directory "/home/travis/build/opencast/opencast/docs/checkstyle".)
[ERROR] 
[ERROR] It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
[ERROR] 
[ERROR]     npm install eslint-plugin-header@latest --save-dev
[ERROR] 
[ERROR] The plugin "eslint-plugin-header" was referenced from the config file in "--config".
[ERROR] 
[ERROR] If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

Prevent it from eating existing header comments

Let's say I have a file with an existing comment:

// log 1
console.log(1);

Is there a way I can prevent eslint-plugin-header from removing the existing comment, and prepend the header template instead?

Add full license file

Hi, we are using your module in VS Code and would like to provide proper attribution.
Based on the repository's package.json, Here is how we are currently attributing the module:

MIT License
Copyright (c) 2015 - present, Stuart Knightley

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Can you add a top-level LICENSE.md with the text so that everyone can attribute your work correctly?
Thanks in advance!

Use placeholder in "template" to set current year

First of all: I love your plugin! It saved me from the cumbersome task of adding a license header to all code that I write during business hours. ๐Ÿ™‡

In my config I am using the "template" functionality and I was wondering if it is possible to add placeholders to it so that the current year can be used?

Example:

  "header/header": [
      "error",
      "block",
      [
        {
          "pattern": "Copyright",
          "template": "\r\n * Title\r\n * Copyright ({{ currentYear }}) 2021 Company\r\n"
        }
      ],
      2
    ]

To build this feature a templating engine like "Nunjucks" could be used: https://mozilla.github.io/nunjucks/

Newline markers in the regular expressions or how to match N repeated instances of lines matching the same regex?

Hello ๐Ÿ™‚

Header comments in my project files always contain a few words of description of what the file is and what it does. Now, depending on whether it is a huge file or not, the description may be single- or multiline. I have tried to construct a config that would match my comment in both cases, so I came up with a regex containing a newline and a multiplier symbol, such as: .+(\n.+)*. Unfortunately, the header plugin does not match any comments if the regex contains \n.

How can I make the plugin match newlines or otherwise prepare a proper config for a case when the number of lines of description is not known beforehand?

Kind regards,
Hubert

Autofix replaces leading comments

My file starts with // @flow, but that comment gets erased with autofix.

I'll gladly fix this, I'm just wondering if it's ok that I completely remove the replacing behavior. I think it was meant to replace wrong headers, but in reality it's replacing any first non-shebang comment, which is not always what we want.

Or maybe we could measure how closely the header is matching given pattern using string-similarity and decide if it's a wrong header or an unrelated comment?

Update

tl;dr for anyone who doesn't feel like reading all of these comments, basically the plugin cannot know whether the existing header comment is an old header that should be replaced (e.g. the year changed) or an unrelated comment. This issue was raised before v3 was released, i.e. before the pattern option, so now we're discussing how we can use it, and ESLint suggestions, to our advantage.

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.

Add optional patterns

As far as I can tell there is not a way to have an optional pattern.

This would be nice for matching pragmas that may not be in every file.

Unable to specify a new line after a header using a template file

I am trying to use a template header from file but due to the fact that it trims when loading from file it is removing the trailing new lines which I require due to microsoft/TypeScript#12307 (comment). I am also unable to specify a newline going the route with a single argument.

It would be good to either not trim the comment when loading from a file (though this would be a major breaking change as some users may depend on it) or maybe support adding newlines when using the template file?

Shebang with Windows EOL

We have a file with shebang header (because of Mac users).
We have core.autocrlf=true therefore the line endings on Macs are \n and Win \r\n.

When checking headers on Windows it never finds headers. It has to detect them in a file starting with:
#!/usr/bin/env node\r\n/**\r\n * Copyright\r\n */

There is a little mistake in hasHeader method:
var m = src.match(/(\r\n|\r|\n)/); does not fit to the:
src = src.slice(m.index + 1); - in case of Windows' EOL the are two characters instead of one.

I have a fix proposition in this pull request

Add possibility to automatically add date

It would be really nice, if it would be possible to automatically add e.g. current year instead of using hard coded values.

In VSCode there is the possibility to use e.g. $CURRENT_YEAR in the snippets.

npm install reports vulnerabilities

$ npm audit

                       === npm audit security report ===

# Run  npm install --save-dev [email protected]  to resolve 3 vulnerabilities
SEMVER WARNING: Recommended action is a potentially breaking change
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Low           โ”‚ Regular Expression Denial of Service                         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Package       โ”‚ debug                                                        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Dependency of โ”‚ mocha [dev]                                                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Path          โ”‚ mocha > debug                                                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ More info     โ”‚ https://nodesecurity.io/advisories/534                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ High          โ”‚ Regular Expression Denial of Service                         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Package       โ”‚ minimatch                                                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Dependency of โ”‚ mocha [dev]                                                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Path          โ”‚ mocha > glob > minimatch                                     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ More info     โ”‚ https://nodesecurity.io/advisories/118                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Critical      โ”‚ Command Injection                                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Package       โ”‚ growl                                                        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Dependency of โ”‚ mocha [dev]                                                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Path          โ”‚ mocha > growl                                                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ More info     โ”‚ https://nodesecurity.io/advisories/146                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


# Run  npm install --save-dev [email protected]  to resolve 1 vulnerability
SEMVER WARNING: Recommended action is a potentially breaking change
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Low           โ”‚ Prototype Pollution                                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Package       โ”‚ lodash                                                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Dependency of โ”‚ eslint [dev]                                                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Path          โ”‚ eslint > inquirer > lodash                                   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ More info     โ”‚ https://nodesecurity.io/advisories/577                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


found 4 vulnerabilities (2 low, 1 high, 1 critical) in 395 scanned packages
  4 vulnerabilities require semver-major dependency updates.

Add option to specify templates for pattern lines

if matching is done with a pattern, then the plugin can't fix wrong headers.
if we could specify a template for those lines, fixing would be possible.

for example:

"rules": {
    "header/header": [2, "block", [
        { pattern: "Copyright \\d{4}", template: "Copyright 2019" }, 
        "My Company"
    ]]
}

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

Support copyright patterns, not just exact matches

Given the following .eslintrc:

{
    "plugins": [
        "header"
    ],
    "rules": {
        "header/header": [2, "block", "Copyright 2016"]
    }
}

If a file has exactly the comment:
/*Copyright 2016*/
it will pass linting, but if the first comment is instead:
/* Copyright 2016 */ (not the whitespace) it will fail. I'd like the ability to specify a string pattern or regular expression for headers to be matched against.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.