pve-eslint/eslint/tools/internal-rules/multiline-comment-style.js
Thomas Lamprecht 609c276fc2 import 8.3.0 source
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-12-01 13:39:06 +01:00

26 lines
1.0 KiB
JavaScript

/**
* @fileoverview A modified version of the `multiline-comment-style` rule that ignores banner comments.
* @author Teddy Katz
*/
"use strict";
const ruleComposer = require("eslint-rule-composer");
const multilineCommentStyle = require("../../lib/rules/multiline-comment-style");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
// The `no-invalid-meta` internal rule has a false positive here.
// eslint-disable-next-line internal-rules/no-invalid-meta -- Using rule composer
module.exports = ruleComposer.filterReports(
multilineCommentStyle,
(problem, metadata) => {
const problemIndex = metadata.sourceCode.getIndexFromLoc(problem.loc.start);
const reportedToken = metadata.sourceCode.getTokenByRangeStart(problemIndex, { includeComments: true });
return !(reportedToken && reportedToken.type === "Line" && /^-{2,}$/u.test(reportedToken.value));
}
);