initial commit of actions

This commit is contained in:
Dominik Polakovics Polakovics 2026-01-31 18:56:04 +01:00
commit 949ece5785
44660 changed files with 12034344 additions and 0 deletions

View file

@ -0,0 +1,69 @@
/**
* @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: {
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,
},
],
type: "suggestion",
},
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,
})
}
},
}
},
}

View file

@ -0,0 +1,47 @@
/**
* @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: {
docs: {
description:
"disallow a `eslint-enable` comment for multiple `eslint-disable` comments",
category: "Best Practices",
recommended: true,
url:
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html",
},
fixable: null,
schema: [],
type: "suggestion",
},
create(context) {
const sourceCode = context.getSourceCode()
const disabledArea = DisabledArea.get(sourceCode)
return {
Program() {
for (const entry of disabledArea.numberOfRelatedDisableDirectives) {
const comment = entry[0]
const count = entry[1]
if (count >= 2) {
context.report({
loc: utils.toForceLocation(comment.loc),
message:
"This `eslint-enable` comment affects {{count}} `eslint-disable` comments. An `eslint-enable` comment should be for an `eslint-disable` comment.",
data: { count },
})
}
}
},
}
},
}

View file

@ -0,0 +1,42 @@
/**
* @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: {
docs: {
description: "disallow duplicate `eslint-disable` comments",
category: "Best Practices",
recommended: true,
url:
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html",
},
fixable: null,
schema: [],
type: "problem",
},
create(context) {
const sourceCode = context.getSourceCode()
const disabledArea = DisabledArea.get(sourceCode)
return {
Program() {
for (const item of disabledArea.duplicateDisableDirectives) {
context.report({
loc: utils.toRuleIdLocation(item.comment, item.ruleId),
message: item.ruleId
? "'{{ruleId}}' rule has been disabled already."
: "ESLint rules have been disabled already.",
data: item,
})
}
},
}
},
}

View file

@ -0,0 +1,62 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const ignore = require("ignore")
const DisabledArea = require("../internal/disabled-area")
const utils = require("../internal/utils")
module.exports = {
meta: {
docs: {
description:
"disallow `eslint-disable` comments about specific rules",
category: "Stylistic Issues",
recommended: false,
url:
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html",
},
fixable: null,
schema: {
type: "array",
items: { type: "string" },
uniqueItems: true,
},
type: "suggestion",
},
create(context) {
const sourceCode = context.getSourceCode()
const disabledArea = DisabledArea.get(sourceCode)
if (context.options.length === 0) {
return {}
}
const ig = ignore()
for (const pattern of context.options) {
ig.add(pattern)
}
return {
Program() {
for (const area of disabledArea.areas) {
if (area.ruleId == null || ig.ignores(area.ruleId)) {
context.report({
loc: utils.toRuleIdLocation(
area.comment,
area.ruleId
),
message: "Disabling '{{ruleId}}' is not allowed.",
data: {
ruleId: area.ruleId || String(context.options),
},
})
}
}
},
}
},
}

View file

@ -0,0 +1,57 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const utils = require("../internal/utils")
module.exports = {
meta: {
docs: {
description:
"disallow `eslint-disable` comments without rule names",
category: "Best Practices",
recommended: true,
url:
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable.html",
},
fixable: null,
schema: [],
type: "suggestion",
},
create(context) {
const sourceCode = context.getSourceCode()
return {
Program() {
for (const comment of sourceCode.getAllComments()) {
const directiveComment = utils.parseDirectiveComment(
comment
)
if (directiveComment == null) {
continue
}
const kind = directiveComment.kind
if (
kind !== "eslint-disable" &&
kind !== "eslint-disable-line" &&
kind !== "eslint-disable-next-line"
) {
continue
}
if (!directiveComment.value) {
context.report({
loc: utils.toForceLocation(comment.loc),
message:
"Unexpected unlimited '{{kind}}' comment. Specify some rule names to disable.",
data: { kind: directiveComment.kind },
})
}
}
},
}
},
}

View file

@ -0,0 +1,34 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
// Patch `Linter#verify` to work.
require("../utils/patch")()
module.exports = {
meta: {
docs: {
description: "disallow unused `eslint-disable` comments",
category: "Best Practices",
recommended: false,
url:
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html",
},
fixable: null,
schema: [],
type: "problem",
},
create() {
// This rule patches `Linter#verify` method and:
//
// 1. enables `reportUnusedDisableDirectives` option.
// 2. verifies the code.
// 3. converts `reportUnusedDisableDirectives` errors to `no-unused-disable` errors.
//
// So this rule itself does nothing.
return {}
},
}

View file

@ -0,0 +1,42 @@
/**
* @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: {
docs: {
description: "disallow unused `eslint-enable` comments",
category: "Best Practices",
recommended: true,
url:
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-enable.html",
},
fixable: null,
schema: [],
type: "problem",
},
create(context) {
const sourceCode = context.getSourceCode()
const disabledArea = DisabledArea.get(sourceCode)
return {
Program() {
for (const item of disabledArea.unusedEnableDirectives) {
context.report({
loc: utils.toRuleIdLocation(item.comment, item.ruleId),
message: item.ruleId
? "'{{ruleId}}' rule is re-enabled but it has not been disabled."
: "ESLint rules are re-enabled but those have not been disabled.",
data: item,
})
}
},
}
},
}

View file

@ -0,0 +1,74 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const utils = require("../internal/utils")
module.exports = {
meta: {
docs: {
description: "disallow ESLint directive-comments",
category: "Stylistic Issues",
recommended: false,
url:
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-use.html",
},
fixable: null,
schema: [
{
type: "object",
properties: {
allow: {
type: "array",
items: {
enum: [
"eslint",
"eslint-disable",
"eslint-disable-line",
"eslint-disable-next-line",
"eslint-enable",
"eslint-env",
"exported",
"global",
"globals",
],
},
additionalItems: false,
uniqueItems: true,
},
},
additionalProperties: false,
},
],
type: "suggestion",
},
create(context) {
const sourceCode = context.getSourceCode()
const allowed = new Set(
(context.options[0] && context.options[0].allow) || []
)
return {
Program() {
for (const comment of sourceCode.getAllComments()) {
const directiveComment = utils.parseDirectiveComment(
comment
)
if (directiveComment == null) {
continue
}
if (!allowed.has(directiveComment.kind)) {
context.report({
loc: utils.toForceLocation(comment.loc),
message: "Unexpected ESLint directive comment.",
})
}
}
},
}
},
}

View file

@ -0,0 +1,78 @@
/**
* @author Yosuke Ota <https://github.com/ota-meshi>
* See LICENSE file in root directory for full license.
*/
"use strict"
const utils = require("../internal/utils")
module.exports = {
meta: {
docs: {
description:
"require include descriptions in ESLint directive-comments",
category: "Stylistic Issues",
recommended: false,
url:
"https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/require-description.html",
},
fixable: null,
schema: [
{
type: "object",
properties: {
ignore: {
type: "array",
items: {
enum: [
"eslint",
"eslint-disable",
"eslint-disable-line",
"eslint-disable-next-line",
"eslint-enable",
"eslint-env",
"exported",
"global",
"globals",
],
},
additionalItems: false,
uniqueItems: true,
},
},
additionalProperties: false,
},
],
type: "suggestion",
},
create(context) {
const sourceCode = context.getSourceCode()
const ignores = new Set(
(context.options[0] && context.options[0].ignore) || []
)
return {
Program() {
for (const comment of sourceCode.getAllComments()) {
const directiveComment = utils.parseDirectiveComment(
comment
)
if (directiveComment == null) {
continue
}
if (ignores.has(directiveComment.kind)) {
continue
}
if (!directiveComment.description) {
context.report({
loc: utils.toForceLocation(comment.loc),
message:
"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary.",
})
}
}
},
}
},
}