Update Bot (j'ai plus le repo sur GitHub)

Qui c'est la conne qui a delete le repo sur GitHub? C'EST MOIIIII
This commit is contained in:
2026-02-09 14:36:26 +01:00
parent eab4419e12
commit ad2014b7b2
586 changed files with 58986 additions and 25205 deletions

View File

@@ -19,6 +19,86 @@ const OPTIONS = {
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
const CTOR_PREFIX_REGEX = /[^_$0-9]/u;
const JSDOC_COMMENT_REGEX = /^\s*\*/u;
/**
* Determines if the first character of the name is a capital letter.
* @param {string} name The name of the node to evaluate.
* @returns {boolean} True if the first character of the property name is a capital letter, false if not.
* @private
*/
function isConstructor(name) {
const match = CTOR_PREFIX_REGEX.exec(name);
// Not a constructor if name has no characters apart from '_', '$' and digits e.g. '_', '$$', '_8'
if (!match) {
return false;
}
const firstChar = name.charAt(match.index);
return firstChar === firstChar.toUpperCase();
}
/**
* Determines if the property can have a shorthand form.
* @param {ASTNode} property Property AST node
* @returns {boolean} True if the property can have a shorthand form
* @private
*/
function canHaveShorthand(property) {
return (
property.kind !== "set" &&
property.kind !== "get" &&
property.type !== "SpreadElement" &&
property.type !== "SpreadProperty" &&
property.type !== "ExperimentalSpreadProperty"
);
}
/**
* Checks whether a node is a string literal.
* @param {ASTNode} node Any AST node.
* @returns {boolean} `true` if it is a string literal.
*/
function isStringLiteral(node) {
return node.type === "Literal" && typeof node.value === "string";
}
/**
* Determines if the property is a shorthand or not.
* @param {ASTNode} property Property AST node
* @returns {boolean} True if the property is considered shorthand, false if not.
* @private
*/
function isShorthand(property) {
// property.method is true when `{a(){}}`.
return property.shorthand || property.method;
}
/**
* Determines if the property's key and method or value are named equally.
* @param {ASTNode} property Property AST node
* @returns {boolean} True if the key and value are named equally, false if not.
* @private
*/
function isRedundant(property) {
const value = property.value;
if (value.type === "FunctionExpression") {
return !value.id; // Only anonymous should be shorthand method.
}
if (value.type === "Identifier") {
return astUtils.getStaticPropertyName(property) === value.name;
}
return false;
}
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
@@ -139,86 +219,6 @@ module.exports = {
const AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows;
const sourceCode = context.sourceCode;
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
const CTOR_PREFIX_REGEX = /[^_$0-9]/u;
/**
* Determines if the first character of the name is a capital letter.
* @param {string} name The name of the node to evaluate.
* @returns {boolean} True if the first character of the property name is a capital letter, false if not.
* @private
*/
function isConstructor(name) {
const match = CTOR_PREFIX_REGEX.exec(name);
// Not a constructor if name has no characters apart from '_', '$' and digits e.g. '_', '$$', '_8'
if (!match) {
return false;
}
const firstChar = name.charAt(match.index);
return firstChar === firstChar.toUpperCase();
}
/**
* Determines if the property can have a shorthand form.
* @param {ASTNode} property Property AST node
* @returns {boolean} True if the property can have a shorthand form
* @private
*/
function canHaveShorthand(property) {
return (
property.kind !== "set" &&
property.kind !== "get" &&
property.type !== "SpreadElement" &&
property.type !== "SpreadProperty" &&
property.type !== "ExperimentalSpreadProperty"
);
}
/**
* Checks whether a node is a string literal.
* @param {ASTNode} node Any AST node.
* @returns {boolean} `true` if it is a string literal.
*/
function isStringLiteral(node) {
return node.type === "Literal" && typeof node.value === "string";
}
/**
* Determines if the property is a shorthand or not.
* @param {ASTNode} property Property AST node
* @returns {boolean} True if the property is considered shorthand, false if not.
* @private
*/
function isShorthand(property) {
// property.method is true when `{a(){}}`.
return property.shorthand || property.method;
}
/**
* Determines if the property's key and method or value are named equally.
* @param {ASTNode} property Property AST node
* @returns {boolean} True if the key and value are named equally, false if not.
* @private
*/
function isRedundant(property) {
const value = property.value;
if (value.type === "FunctionExpression") {
return !value.id; // Only anonymous should be shorthand method.
}
if (value.type === "Identifier") {
return astUtils.getStaticPropertyName(property) === value.name;
}
return false;
}
/**
* Ensures that an object's properties are consistently shorthand, or not shorthand at all.
* @param {ASTNode} node Property AST node
@@ -582,6 +582,19 @@ module.exports = {
node.key.name === node.value.name &&
APPLY_TO_PROPS
) {
// Skip if there are JSDoc comments inside the property (e.g., JSDoc type annotations)
const comments = sourceCode.getCommentsInside(node);
if (
comments.some(
comment =>
comment.type === "Block" &&
JSDOC_COMMENT_REGEX.test(comment.value) &&
comment.value.includes("@type"),
)
) {
return;
}
// {x: x} should be written as {x}
context.report({
node,
@@ -606,6 +619,18 @@ module.exports = {
return;
}
const comments = sourceCode.getCommentsInside(node);
if (
comments.some(
comment =>
comment.type === "Block" &&
comment.value.startsWith("*") &&
comment.value.includes("@type"),
)
) {
return;
}
// {"x": x} should be written as {x}
context.report({
node,