mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
/**
|
|
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
* See LICENSE file in root directory for full license.
|
|
*/
|
|
"use strict"
|
|
|
|
const DisabledArea = require("../internal/disabled-area")
|
|
const utils = require("../internal/utils")
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: "suggestion",
|
|
docs: {
|
|
description:
|
|
"require a `eslint-enable` comment for every `eslint-disable` comment",
|
|
category: "Best Practices",
|
|
recommended: true,
|
|
url:
|
|
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html",
|
|
},
|
|
fixable: null,
|
|
schema: [
|
|
{
|
|
type: "object",
|
|
properties: {
|
|
allowWholeFile: {
|
|
type: "boolean",
|
|
},
|
|
},
|
|
additionalProperties: false,
|
|
},
|
|
],
|
|
},
|
|
|
|
create(context) {
|
|
const allowWholeFile =
|
|
context.options[0] && context.options[0].allowWholeFile
|
|
const sourceCode = context.getSourceCode()
|
|
const disabledArea = DisabledArea.get(sourceCode)
|
|
|
|
return {
|
|
Program(node) {
|
|
if (allowWholeFile && node.body.length === 0) {
|
|
return
|
|
}
|
|
|
|
for (const area of disabledArea.areas) {
|
|
if (area.end != null) {
|
|
continue
|
|
}
|
|
if (
|
|
allowWholeFile &&
|
|
utils.lte(area.start, node.loc.start)
|
|
) {
|
|
continue
|
|
}
|
|
|
|
context.report({
|
|
loc: utils.toRuleIdLocation(area.comment, area.ruleId),
|
|
message: area.ruleId
|
|
? "Requires 'eslint-enable' directive for '{{ruleId}}'."
|
|
: "Requires 'eslint-enable' directive.",
|
|
data: area,
|
|
})
|
|
}
|
|
},
|
|
}
|
|
},
|
|
}
|