mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 11:42:59 +00:00
feat: eslint license header plugin
This commit is contained in:
41
patches/eslint-plugin-header@3.1.1.patch
Normal file
41
patches/eslint-plugin-header@3.1.1.patch
Normal file
@@ -0,0 +1,41 @@
|
||||
diff --git a/lib/rules/header.js b/lib/rules/header.js
|
||||
index 3504b6fc59b780674e652ad1ca944cb3577b8fed..d86dc0b490845c22f54ae83dbc52efcf448e628b 100644
|
||||
--- a/lib/rules/header.js
|
||||
+++ b/lib/rules/header.js
|
||||
@@ -27,6 +27,9 @@ function excludeShebangs(comments) {
|
||||
// check if they are at the start of the file since that is already checked by
|
||||
// hasHeader().
|
||||
function getLeadingComments(context, node) {
|
||||
+ if (!node.body) {
|
||||
+ return context.getSourceCode().ast.comments;
|
||||
+ }
|
||||
var all = excludeShebangs(context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node));
|
||||
if (all[0].type.toLowerCase() === "block") {
|
||||
return [all[0]];
|
||||
@@ -44,6 +47,8 @@ function genCommentBody(commentType, textArray, eol, numNewlines) {
|
||||
var eols = eol.repeat(numNewlines);
|
||||
if (commentType === "block") {
|
||||
return "/*" + textArray.join(eol) + "*/" + eols;
|
||||
+ } else if (commentType === "block-html") {
|
||||
+ return "<!--\n " + textArray.join(eol) + "\n -->" + eols;
|
||||
} else {
|
||||
return "//" + textArray.join(eol + "//") + eols;
|
||||
}
|
||||
@@ -103,7 +108,7 @@ function hasHeader(src) {
|
||||
src = src.slice(m.index + m[0].length);
|
||||
}
|
||||
}
|
||||
- return src.substr(0, 2) === "/*" || src.substr(0, 2) === "//";
|
||||
+ return src.substr(0, 2) === "/*" || src.substr(0, 2) === "//" || src.substr(0, 4) === "<!--";
|
||||
}
|
||||
|
||||
function matchesLineEndings(src, num) {
|
||||
@@ -180,7 +185,7 @@ module.exports = {
|
||||
message: "missing header",
|
||||
fix: canFix ? genPrependFixer(commentType, node, fixLines, eol, numNewlines) : null
|
||||
});
|
||||
- } else if (leadingComments[0].type.toLowerCase() !== commentType) {
|
||||
+ } else if (leadingComments[0].type.toLowerCase() !== commentType.replace(/-html$/, '')) {
|
||||
context.report({
|
||||
loc: node.loc,
|
||||
message: "header should be a {{commentType}} comment",
|
||||
Reference in New Issue
Block a user