Tracking de l'application VApp (IHM du jeu)

This commit is contained in:
2025-05-11 18:04:12 +02:00
commit 89e9db9b62
17763 changed files with 3718499 additions and 0 deletions

View File

@ -0,0 +1,81 @@
import type { TSESTree } from '@typescript-eslint/types';
export declare function isArrayExpression(node: TSESTree.Node): node is TSESTree.ArrayExpression;
export declare function isArrowFunctionExpression(node: TSESTree.Node): node is TSESTree.ArrowFunctionExpression;
/** default parameters */
export declare function isAssignmentPattern(node: TSESTree.Node): node is TSESTree.AssignmentPattern;
export declare function isClassDeclaration(node: TSESTree.Node): node is TSESTree.ClassDeclaration;
export declare function isClassExpression(node: TSESTree.Node): node is TSESTree.ClassExpression;
export declare function isExportDefaultDeclaration(node: TSESTree.Node): node is TSESTree.ExportDefaultDeclaration;
export declare function isExpression(node: TSESTree.Node): node is TSESTree.Expression;
export declare function isFunctionDeclaration(node: TSESTree.Node): node is TSESTree.FunctionDeclaration;
export declare function isFunctionExpression(node: TSESTree.Node): node is TSESTree.FunctionExpression;
export declare function isIdentifier(node: TSESTree.Node): node is TSESTree.Identifier;
export declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
export declare function isMethodDefinition(node: TSESTree.Node): node is TSESTree.MethodDefinition;
export declare function isObjectExpression(node: TSESTree.Node): node is TSESTree.ObjectExpression;
export declare function isPrivateIdentifier(node: TSESTree.Node): node is TSESTree.PrivateIdentifier;
export declare function isProperty(node: TSESTree.Node): node is TSESTree.Property;
export declare function isPropertyDefinition(node: TSESTree.Node): node is TSESTree.PropertyDefinition;
export declare function isTSEnumDeclaration(node: TSESTree.Node): node is TSESTree.TSEnumDeclaration;
export declare function isTSInterfaceDeclaration(node: TSESTree.Node): node is TSESTree.TSInterfaceDeclaration;
export declare function isTSModuleDeclaration(node: TSESTree.Node): node is TSESTree.TSModuleDeclaration;
export declare function isTSQualifiedName(node: TSESTree.Node): node is TSESTree.TSQualifiedName;
export declare function isTSTypeAliasDeclaration(node: TSESTree.Node): node is TSESTree.TSTypeAliasDeclaration;
export declare function isVariableDeclarator(node: TSESTree.Node): node is TSESTree.VariableDeclarator;
export declare function isClassDeclarationWithName(node: TSESTree.Node): node is TSESTree.ClassDeclarationWithName;
export declare function isClassPropertyNameNonComputed(node: TSESTree.Node): node is TSESTree.ClassPropertyNameNonComputed;
export declare function isFunctionDeclarationWithName(node: TSESTree.Node): node is TSESTree.FunctionDeclarationWithName;
export declare function isNumberLiteral(node: TSESTree.Node): node is TSESTree.NumberLiteral;
export declare function isPropertyNameNonComputed(node: TSESTree.Node): node is TSESTree.PropertyNameNonComputed;
export declare function isStringLiteral(node: TSESTree.Node): node is TSESTree.StringLiteral;
export interface ClassExpressionWithName extends TSESTree.ClassExpression {
id: TSESTree.Identifier;
}
export declare function isClassExpressionWithName(node: TSESTree.Node): node is ClassExpressionWithName;
export interface FunctionExpressionWithName extends TSESTree.FunctionExpression {
id: TSESTree.Identifier;
}
export declare function isFunctionExpressionWithName(node: TSESTree.Node): node is FunctionExpressionWithName;
export type NormalAnonymousExpression = TSESTree.ArrowFunctionExpression | TSESTree.ClassExpression | TSESTree.FunctionExpression | TSESTree.ObjectExpression;
export declare function isNormalAnonymousExpression(node: TSESTree.Node): node is NormalAnonymousExpression;
export interface NormalAssignmentPattern extends TSESTree.AssignmentPattern {
left: TSESTree.Identifier;
}
export declare function isNormalAssignmentPattern(node: TSESTree.Node): node is NormalAssignmentPattern;
export interface NormalClassPropertyDefinition extends TSESTree.PropertyDefinitionNonComputedName {
key: TSESTree.PrivateIdentifier | TSESTree.Identifier;
value: TSESTree.Expression;
}
export declare function isNormalClassPropertyDefinition(node: TSESTree.Node): node is NormalClassPropertyDefinition;
export interface NormalMethodDefinition extends TSESTree.MethodDefinitionNonComputedName {
key: TSESTree.PrivateIdentifier | TSESTree.Identifier;
}
export declare function isNormalMethodDefinition(node: TSESTree.Node): node is NormalMethodDefinition;
export interface NormalObjectProperty extends TSESTree.PropertyNonComputedName {
key: TSESTree.Identifier;
}
export declare function isNormalObjectProperty(node: TSESTree.Node): node is NormalObjectProperty;
export interface NormalVariableDeclarator extends TSESTree.VariableDeclarator {
id: TSESTree.Identifier;
init: TSESTree.Expression;
}
export declare function isNormalVariableDeclarator(node: TSESTree.Node): node is NormalVariableDeclarator;
export interface NormalAssignmentPatternWithAnonymousExpressionAssigned extends NormalAssignmentPattern {
right: NormalAnonymousExpression;
}
export declare function isNormalAssignmentPatternWithAnonymousExpressionAssigned(node: TSESTree.Node): node is NormalAssignmentPatternWithAnonymousExpressionAssigned;
export interface NormalVariableDeclaratorWithAnonymousExpressionAssigned extends NormalVariableDeclarator {
init: NormalAnonymousExpression;
}
export declare function isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node: TSESTree.Node): node is NormalVariableDeclaratorWithAnonymousExpressionAssigned;
export interface NormalObjectPropertyWithAnonymousExpressionAssigned extends NormalObjectProperty {
value: NormalAnonymousExpression;
}
export declare function isNormalObjectPropertyWithAnonymousExpressionAssigned(node: TSESTree.Node): node is NormalObjectPropertyWithAnonymousExpressionAssigned;
export interface NormalClassPropertyDefinitionWithAnonymousExpressionAssigned extends NormalClassPropertyDefinition {
value: NormalAnonymousExpression;
}
export declare function isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node: TSESTree.Node): node is NormalClassPropertyDefinitionWithAnonymousExpressionAssigned;
export type NodeWithName = TSESTree.ClassDeclarationWithName | TSESTree.FunctionDeclarationWithName | ClassExpressionWithName | FunctionExpressionWithName | NormalVariableDeclaratorWithAnonymousExpressionAssigned | NormalObjectPropertyWithAnonymousExpressionAssigned | NormalClassPropertyDefinitionWithAnonymousExpressionAssigned | NormalAssignmentPatternWithAnonymousExpressionAssigned | NormalMethodDefinition | TSESTree.TSEnumDeclaration | TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
export declare function isNodeWithName(node: TSESTree.Node): node is NodeWithName;
//# sourceMappingURL=ast-guards.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ast-guards.d.ts","sourceRoot":"","sources":["../../src/eslint-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AC,IAAI,GAClB,IAAI,IAAI,sDAAsD,CAEhE;AAED,MAAM,WAAW,uDAAwD,SAAQ,wBAAwB;IACvG,IAAI,EAAE,yBAAyB,CAAC;CACjC;AAED,wBAAgB,yDAAyD,CACvE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,uDAAuD,CAEjE;AAED,MAAM,WAAW,mDAAoD,SAAQ,oBAAoB;IAC/F,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,wBAAgB,qDAAqD,CACnE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,mDAAmD,CAE7D;AAED,MAAM,WAAW,4DACf,SAAQ,6BAA6B;IACrC,KAAK,EAAE,yBAAyB,CAAC;CAClC;AAED,wBAAgB,8DAA8D,CAC5E,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,4DAA4D,CAEtE;AAED,MAAM,MAAM,YAAY,GACpB,QAAQ,CAAC,wBAAwB,GACjC,QAAQ,CAAC,2BAA2B,GACpC,uBAAuB,GACvB,0BAA0B,GAC1B,uDAAuD,GACvD,mDAAmD,GACnD,4DAA4D,GAC5D,sDAAsD,GACtD,sBAAsB,GACtB,QAAQ,CAAC,iBAAiB,GAC1B,QAAQ,CAAC,sBAAsB,GAC/B,QAAQ,CAAC,sBAAsB,CAAC;AAEpC,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,YAAY,CAexE"}

View File

@ -0,0 +1,191 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNodeWithName = exports.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned = exports.isNormalObjectPropertyWithAnonymousExpressionAssigned = exports.isNormalVariableDeclaratorWithAnonymousExpressionAssigned = exports.isNormalAssignmentPatternWithAnonymousExpressionAssigned = exports.isNormalVariableDeclarator = exports.isNormalObjectProperty = exports.isNormalMethodDefinition = exports.isNormalClassPropertyDefinition = exports.isNormalAssignmentPattern = exports.isNormalAnonymousExpression = exports.isFunctionExpressionWithName = exports.isClassExpressionWithName = exports.isStringLiteral = exports.isPropertyNameNonComputed = exports.isNumberLiteral = exports.isFunctionDeclarationWithName = exports.isClassPropertyNameNonComputed = exports.isClassDeclarationWithName = exports.isVariableDeclarator = exports.isTSTypeAliasDeclaration = exports.isTSQualifiedName = exports.isTSModuleDeclaration = exports.isTSInterfaceDeclaration = exports.isTSEnumDeclaration = exports.isPropertyDefinition = exports.isProperty = exports.isPrivateIdentifier = exports.isObjectExpression = exports.isMethodDefinition = exports.isLiteral = exports.isIdentifier = exports.isFunctionExpression = exports.isFunctionDeclaration = exports.isExpression = exports.isExportDefaultDeclaration = exports.isClassExpression = exports.isClassDeclaration = exports.isAssignmentPattern = exports.isArrowFunctionExpression = exports.isArrayExpression = void 0;
function isArrayExpression(node) {
return node.type === 'ArrayExpression';
}
exports.isArrayExpression = isArrayExpression;
function isArrowFunctionExpression(node) {
return node.type === 'ArrowFunctionExpression';
}
exports.isArrowFunctionExpression = isArrowFunctionExpression;
/** default parameters */
function isAssignmentPattern(node) {
return node.type === 'AssignmentPattern';
}
exports.isAssignmentPattern = isAssignmentPattern;
function isClassDeclaration(node) {
return node.type === 'ClassDeclaration';
}
exports.isClassDeclaration = isClassDeclaration;
function isClassExpression(node) {
return node.type === 'ClassExpression';
}
exports.isClassExpression = isClassExpression;
function isExportDefaultDeclaration(node) {
return node.type === 'ExportDefaultDeclaration';
}
exports.isExportDefaultDeclaration = isExportDefaultDeclaration;
function isExpression(node) {
return node.type.includes('Expression');
}
exports.isExpression = isExpression;
function isFunctionDeclaration(node) {
return node.type === 'FunctionDeclaration';
}
exports.isFunctionDeclaration = isFunctionDeclaration;
function isFunctionExpression(node) {
return node.type === 'FunctionExpression';
}
exports.isFunctionExpression = isFunctionExpression;
function isIdentifier(node) {
return node.type === 'Identifier';
}
exports.isIdentifier = isIdentifier;
function isLiteral(node) {
return node.type === 'Literal';
}
exports.isLiteral = isLiteral;
function isMethodDefinition(node) {
return node.type === 'MethodDefinition';
}
exports.isMethodDefinition = isMethodDefinition;
function isObjectExpression(node) {
return node.type === 'ObjectExpression';
}
exports.isObjectExpression = isObjectExpression;
function isPrivateIdentifier(node) {
return node.type === 'PrivateIdentifier';
}
exports.isPrivateIdentifier = isPrivateIdentifier;
function isProperty(node) {
return node.type === 'Property';
}
exports.isProperty = isProperty;
function isPropertyDefinition(node) {
return node.type === 'PropertyDefinition';
}
exports.isPropertyDefinition = isPropertyDefinition;
function isTSEnumDeclaration(node) {
return node.type === 'TSEnumDeclaration';
}
exports.isTSEnumDeclaration = isTSEnumDeclaration;
function isTSInterfaceDeclaration(node) {
return node.type === 'TSInterfaceDeclaration';
}
exports.isTSInterfaceDeclaration = isTSInterfaceDeclaration;
function isTSModuleDeclaration(node) {
return node.type === 'TSModuleDeclaration';
}
exports.isTSModuleDeclaration = isTSModuleDeclaration;
function isTSQualifiedName(node) {
return node.type === 'TSQualifiedName';
}
exports.isTSQualifiedName = isTSQualifiedName;
function isTSTypeAliasDeclaration(node) {
return node.type === 'TSTypeAliasDeclaration';
}
exports.isTSTypeAliasDeclaration = isTSTypeAliasDeclaration;
function isVariableDeclarator(node) {
return node.type === 'VariableDeclarator';
}
exports.isVariableDeclarator = isVariableDeclarator;
// Compound Type Guards for @typescript-eslint/types ast-spec compound types
function isClassDeclarationWithName(node) {
return isClassDeclaration(node) && node.id !== null;
}
exports.isClassDeclarationWithName = isClassDeclarationWithName;
function isClassPropertyNameNonComputed(node) {
return isPrivateIdentifier(node) || isPropertyNameNonComputed(node);
}
exports.isClassPropertyNameNonComputed = isClassPropertyNameNonComputed;
function isFunctionDeclarationWithName(node) {
return isFunctionDeclaration(node) && node.id !== null;
}
exports.isFunctionDeclarationWithName = isFunctionDeclarationWithName;
function isNumberLiteral(node) {
return isLiteral(node) && typeof node.value === 'number';
}
exports.isNumberLiteral = isNumberLiteral;
function isPropertyNameNonComputed(node) {
return isIdentifier(node) || isNumberLiteral(node) || isStringLiteral(node);
}
exports.isPropertyNameNonComputed = isPropertyNameNonComputed;
function isStringLiteral(node) {
return isLiteral(node) && typeof node.value === 'string';
}
exports.isStringLiteral = isStringLiteral;
function isClassExpressionWithName(node) {
return isClassExpression(node) && node.id !== null;
}
exports.isClassExpressionWithName = isClassExpressionWithName;
function isFunctionExpressionWithName(node) {
return isFunctionExpression(node) && node.id !== null;
}
exports.isFunctionExpressionWithName = isFunctionExpressionWithName;
function isNormalAnonymousExpression(node) {
const ANONYMOUS_EXPRESSION_GUARDS = [
isArrowFunctionExpression,
isClassExpression,
isFunctionExpression,
isObjectExpression
];
return ANONYMOUS_EXPRESSION_GUARDS.some((guard) => guard(node));
}
exports.isNormalAnonymousExpression = isNormalAnonymousExpression;
function isNormalAssignmentPattern(node) {
return isAssignmentPattern(node) && isIdentifier(node.left);
}
exports.isNormalAssignmentPattern = isNormalAssignmentPattern;
function isNormalClassPropertyDefinition(node) {
return (isPropertyDefinition(node) &&
(isIdentifier(node.key) || isPrivateIdentifier(node.key)) &&
node.value !== null);
}
exports.isNormalClassPropertyDefinition = isNormalClassPropertyDefinition;
function isNormalMethodDefinition(node) {
return isMethodDefinition(node) && (isIdentifier(node.key) || isPrivateIdentifier(node.key));
}
exports.isNormalMethodDefinition = isNormalMethodDefinition;
function isNormalObjectProperty(node) {
return isProperty(node) && (isIdentifier(node.key) || isPrivateIdentifier(node.key));
}
exports.isNormalObjectProperty = isNormalObjectProperty;
function isNormalVariableDeclarator(node) {
return isVariableDeclarator(node) && isIdentifier(node.id) && node.init !== null;
}
exports.isNormalVariableDeclarator = isNormalVariableDeclarator;
function isNormalAssignmentPatternWithAnonymousExpressionAssigned(node) {
return isNormalAssignmentPattern(node) && isNormalAnonymousExpression(node.right);
}
exports.isNormalAssignmentPatternWithAnonymousExpressionAssigned = isNormalAssignmentPatternWithAnonymousExpressionAssigned;
function isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node) {
return isNormalVariableDeclarator(node) && isNormalAnonymousExpression(node.init);
}
exports.isNormalVariableDeclaratorWithAnonymousExpressionAssigned = isNormalVariableDeclaratorWithAnonymousExpressionAssigned;
function isNormalObjectPropertyWithAnonymousExpressionAssigned(node) {
return isNormalObjectProperty(node) && isNormalAnonymousExpression(node.value);
}
exports.isNormalObjectPropertyWithAnonymousExpressionAssigned = isNormalObjectPropertyWithAnonymousExpressionAssigned;
function isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node) {
return isNormalClassPropertyDefinition(node) && isNormalAnonymousExpression(node.value);
}
exports.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned = isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned;
function isNodeWithName(node) {
return (isClassDeclarationWithName(node) ||
isFunctionDeclarationWithName(node) ||
isClassExpressionWithName(node) ||
isFunctionExpressionWithName(node) ||
isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node) ||
isNormalObjectPropertyWithAnonymousExpressionAssigned(node) ||
isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node) ||
isNormalAssignmentPatternWithAnonymousExpressionAssigned(node) ||
isNormalMethodDefinition(node) ||
isTSEnumDeclaration(node) ||
isTSInterfaceDeclaration(node) ||
isTSTypeAliasDeclaration(node));
}
exports.isNodeWithName = isNodeWithName;
//# sourceMappingURL=ast-guards.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,21 @@
import { TSESTree } from '@typescript-eslint/types';
/**
* @throws Throws an error if the command to retrieve the root path fails.
* @returns The root path of the monorepo.
*/
export declare function getGitRootPath(): string;
export declare const GitRootPath: string;
export declare function shouldBulkSuppress(params: {
filename: string;
currentNode: TSESTree.Node;
ruleId: string;
}): boolean;
export declare function onFinish(params: {
filename: string;
}): void;
export declare function BulkSuppressionsPrune(params: {
filename: string;
}): void;
export declare function requireFromPathToLinterJS(importPath: string): any;
export declare function patchClass<T, U extends T>(originalClass: new () => T, patchedClass: new () => U): void;
//# sourceMappingURL=bulk-suppressions-patch.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"bulk-suppressions-patch.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/bulk-suppressions-patch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AA4DpD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAED,eAAO,MAAM,WAAW,QAAmB,CAAC;AAuJ5C,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAqBV;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAI3D;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAWxE;AAGD,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAOjE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,UAAU,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,GAAG,IAAI,CAkBtG"}

View File

@ -0,0 +1,273 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.patchClass = exports.requireFromPathToLinterJS = exports.BulkSuppressionsPrune = exports.onFinish = exports.shouldBulkSuppress = exports.GitRootPath = exports.getGitRootPath = void 0;
const child_process_1 = require("child_process");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const Guards = __importStar(require("./ast-guards"));
const _patch_base_1 = require("../_patch-base");
function getNodeName(node) {
if (!Guards.isNodeWithName(node))
return null;
if (Guards.isClassDeclarationWithName(node))
return node.id.name;
if (Guards.isFunctionDeclarationWithName(node))
return node.id.name;
if (Guards.isClassExpressionWithName(node))
return node.id.name;
if (Guards.isFunctionExpressionWithName(node))
return node.id.name;
if (Guards.isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node))
return node.id.name;
if (Guards.isNormalObjectPropertyWithAnonymousExpressionAssigned(node))
return node.key.name;
if (Guards.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node))
return node.key.name;
if (Guards.isNormalAssignmentPatternWithAnonymousExpressionAssigned(node))
return node.left.name;
if (Guards.isNormalMethodDefinition(node))
return node.key.name;
if (Guards.isTSEnumDeclaration(node))
return node.id.name;
if (Guards.isTSInterfaceDeclaration(node))
return node.id.name;
if (Guards.isTSTypeAliasDeclaration(node))
return node.id.name;
return null;
}
function calculateScopeId(node) {
const scopeIds = [];
for (let current = node; current; current = current.parent) {
const scopeIdForASTNode = getNodeName(current);
if (scopeIdForASTNode !== null)
scopeIds.unshift(scopeIdForASTNode);
}
if (scopeIds.length === 0)
return '.';
return '.' + scopeIds.join('.');
}
/**
* @throws Throws an error if the command to retrieve the root path fails.
* @returns The root path of the monorepo.
*/
function getGitRootPath() {
const result = (0, child_process_1.spawnSync)('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8' });
if (result.status !== 0)
throw new Error(`get root path failed`);
return result.stdout.toString().trim();
}
exports.getGitRootPath = getGitRootPath;
exports.GitRootPath = getGitRootPath();
function findEslintrcDirectory(fileAbsolutePath) {
for (let currentDir = fileAbsolutePath; currentDir.startsWith(exports.GitRootPath); currentDir = path_1.default.dirname(currentDir))
if (['.eslintrc.js', '.eslintrc.cjs'].some((eslintrc) => fs_1.default.existsSync(path_1.default.join(currentDir, eslintrc))))
return currentDir;
throw new Error('Cannot locate eslintrc');
}
function validateSuppressionsJson(json) {
if (typeof json !== 'object')
throw new Error(`Invalid JSON object: ${JSON.stringify(json, null, 2)}`);
if (json === null)
throw new Error('JSON object is null.');
if (!json.hasOwnProperty('suppressions'))
throw new Error('Missing "suppressions" property.');
if (!Array.isArray(json.suppressions))
throw new Error('"suppressions" property is not an array.');
if (!json.suppressions.every((suppression) => {
if (typeof suppression !== 'object')
throw new Error(`Invalid suppression: ${JSON.stringify(suppression, null, 2)}`);
if (suppression === null)
throw new Error(`Suppression is null: ${JSON.stringify(suppression, null, 2)}`);
if (!suppression.hasOwnProperty('file'))
throw new Error(`Missing "file" property in suppression: ${JSON.stringify(suppression, null, 2)}`);
if (typeof suppression.file !== 'string')
throw new Error(`"file" property in suppression is not a string: ${JSON.stringify(suppression, null, 2)}`);
if (!suppression.hasOwnProperty('scopeId'))
throw new Error(`Missing "scopeId" property in suppression: ${JSON.stringify(suppression, null, 2)}`);
if (typeof suppression.scopeId !== 'string')
throw new Error(`"scopeId" property in suppression is not a string: ${JSON.stringify(suppression, null, 2)}`);
if (!suppression.hasOwnProperty('rule'))
throw new Error(`Missing "rule" property in suppression: ${JSON.stringify(suppression, null, 2)}`);
if (typeof suppression.rule !== 'string')
throw new Error(`"rule" property in suppression is not a string: ${JSON.stringify(suppression, null, 2)}`);
return true;
})) {
throw new Error(`Invalid suppression in "suppressions" array: ${JSON.stringify(json.suppressions, null, 2)}`);
}
return true;
}
function readSuppressionsJson(fileAbsolutePath) {
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
const suppressionsPath = path_1.default.join(eslintrcDirectory, '.eslint-bulk-suppressions.json');
let suppressionsJson = { suppressions: [] };
try {
const fileContent = fs_1.default.readFileSync(suppressionsPath, 'utf-8');
suppressionsJson = JSON.parse(fileContent);
if (!validateSuppressionsJson(suppressionsJson)) {
console.warn(`Unexpected file content in .eslint-bulk-suppressions.json. JSON expected to be in the following format:
{
suppressions: {
file: string;
scopeId: string;
rule: string;
}[];
}
Please check file content, or delete file if suppressions are no longer needed.
`);
suppressionsJson = { suppressions: [] };
}
}
catch (_a) {
// Do nothing and let JSON.parse() log the error. suppressionsJson will stay as the initialized value.
}
return suppressionsJson;
}
function shouldWriteSuppression(fileAbsolutePath, suppression) {
if (process.env.ESLINT_BULK_SUPPRESS === undefined)
return false;
if (isSuppressed(fileAbsolutePath, suppression))
return false;
const rulesToSuppress = process.env.ESLINT_BULK_SUPPRESS.split(',');
if (rulesToSuppress.length === 1 && rulesToSuppress[0] === '*')
return true;
return rulesToSuppress.includes(suppression.rule);
}
function isSuppressed(fileAbsolutePath, suppression) {
const suppressionsJson = readSuppressionsJson(fileAbsolutePath);
return (suppressionsJson.suppressions.find((element) => element.file === suppression.file &&
element.scopeId === suppression.scopeId &&
element.rule === suppression.rule) !== undefined);
}
function insort(array, item, compareFunction) {
const index = array.findIndex((element) => compareFunction(element, item) > 0);
if (index === -1)
array.push(item);
else
array.splice(index, 0, item);
}
function compareSuppressions(a, b) {
if (a.file < b.file)
return -1;
if (a.file > b.file)
return 1;
if (a.scopeId < b.scopeId)
return -1;
if (a.scopeId > b.scopeId)
return 1;
if (a.rule < b.rule)
return -1;
if (a.rule > b.rule)
return 1;
return 0;
}
function writeSuppressionToFile(fileAbsolutePath, suppression) {
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
const suppressionsJson = readSuppressionsJson(fileAbsolutePath);
insort(suppressionsJson.suppressions, suppression, compareSuppressions);
const suppressionsPath = path_1.default.join(eslintrcDirectory, '.eslint-bulk-suppressions.json');
fs_1.default.writeFileSync(suppressionsPath, JSON.stringify(suppressionsJson, null, 2));
}
const usedSuppressions = new Set();
function serializeSuppression(fileAbsolutePath, suppression) {
return `${fileAbsolutePath}|${suppression.file}|${suppression.scopeId}|${suppression.rule}`;
}
function deserializeSuppression(serializedSuppression) {
const [file, scopeId, rule] = serializedSuppression.split('|');
return { file, scopeId, rule };
}
// One-line insert into the ruleContext report method to prematurely exit if the ESLint problem has been suppressed
function shouldBulkSuppress(params) {
// Use this ENV variable to turn off eslint-bulk-suppressions functionality, default behavior is on
if (process.env.ESLINT_BULK_ENABLE === 'false')
return false;
const { filename: fileAbsolutePath, currentNode, ruleId: rule } = params;
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
const fileRelativePath = path_1.default.relative(eslintrcDirectory, fileAbsolutePath);
const scopeId = calculateScopeId(currentNode);
const suppression = { file: fileRelativePath, scopeId, rule };
if (shouldWriteSuppression(fileAbsolutePath, suppression)) {
writeSuppressionToFile(fileAbsolutePath, suppression);
}
const shouldBulkSuppress = isSuppressed(fileAbsolutePath, suppression);
if (shouldBulkSuppress) {
usedSuppressions.add(serializeSuppression(fileAbsolutePath, suppression));
}
return shouldBulkSuppress;
}
exports.shouldBulkSuppress = shouldBulkSuppress;
function onFinish(params) {
if (process.env.ESLINT_BULK_PRUNE === 'true') {
BulkSuppressionsPrune(params);
}
}
exports.onFinish = onFinish;
function BulkSuppressionsPrune(params) {
const { filename: fileAbsolutePath } = params;
const suppressionsJson = readSuppressionsJson(fileAbsolutePath);
const newSuppressionsJson = {
suppressions: suppressionsJson.suppressions.filter((suppression) => {
return usedSuppressions.has(serializeSuppression(fileAbsolutePath, suppression));
})
};
const eslintrcDirectory = findEslintrcDirectory(fileAbsolutePath);
const suppressionsPath = path_1.default.join(eslintrcDirectory, '.eslint-bulk-suppressions.json');
fs_1.default.writeFileSync(suppressionsPath, JSON.stringify(newSuppressionsJson, null, 2));
}
exports.BulkSuppressionsPrune = BulkSuppressionsPrune;
// utility function for linter-patch.js to make require statements that use relative paths in linter.js work in linter-patch.js
function requireFromPathToLinterJS(importPath) {
if (!_patch_base_1.eslintFolder) {
return require(importPath);
}
const pathToLinterFolder = path_1.default.join(_patch_base_1.eslintFolder, 'lib', 'linter');
const moduleAbsolutePath = require.resolve(importPath, { paths: [pathToLinterFolder] });
return require(moduleAbsolutePath);
}
exports.requireFromPathToLinterJS = requireFromPathToLinterJS;
function patchClass(originalClass, patchedClass) {
// Get all the property names of the patched class prototype
let patchedProperties = Object.getOwnPropertyNames(patchedClass.prototype);
// Loop through all the properties
for (let prop of patchedProperties) {
// Override the property in the original class
originalClass.prototype[prop] = patchedClass.prototype[prop];
}
// Handle getters and setters
let descriptors = Object.getOwnPropertyDescriptors(patchedClass.prototype);
for (let prop in descriptors) {
let descriptor = descriptors[prop];
if (descriptor.get || descriptor.set) {
Object.defineProperty(originalClass.prototype, prop, descriptor);
}
}
}
exports.patchClass = patchClass;
//# sourceMappingURL=bulk-suppressions-patch.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
export declare function prune(): void;
//# sourceMappingURL=prune.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/prune.ts"],"names":[],"mappings":"AAOA,wBAAgB,KAAK,SAsCpB"}

View File

@ -0,0 +1,35 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.prune = void 0;
const child_process_1 = require("child_process");
const get_eslint_cli_1 = require("./utils/get-eslint-cli");
const print_help_1 = require("./utils/print-help");
function prune() {
const args = process.argv.slice(3);
if (args.includes('--help') || args.includes('-h')) {
(0, print_help_1.printPruneHelp)();
process.exit(0);
}
if (args.length > 0) {
throw new Error(`@rushstack/eslint-bulk: Unknown arguments: ${args.join(' ')}`);
}
const eslintCLI = (0, get_eslint_cli_1.getEslintCli)(process.cwd());
const env = Object.assign(Object.assign({}, process.env), { ESLINT_BULK_PRUNE: 'true' });
(0, child_process_1.exec)(`${eslintCLI} . --format=json`, { env }, (error, stdout, stderr) => {
// if errorCount != 0, ESLint will process.exit(1) giving the false impression
// that the exec failed, even though linting errors are to be expected
const eslintOutputWithErrorRegex = /"errorCount":(?!0)\d+/;
const isEslintError = error !== null && error.code === 1 && eslintOutputWithErrorRegex.test(stdout);
if (error && !isEslintError) {
throw new Error(`@rushstack/eslint-bulk execution error: ${error.message}`);
}
if (stderr) {
throw new Error(`@rushstack/eslint-bulk ESLint errors: ${stderr}`);
}
console.log(`@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json files under directory ${process.cwd()}`);
});
}
exports.prune = prune;
//# sourceMappingURL=prune.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/prune.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,iDAAoD;AACpD,2DAAsD;AACtD,mDAAoD;AAEpD,SAAgB,KAAK;IACnB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,IAAA,2BAAc,GAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8CAA8C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE9C,MAAM,GAAG,mCAA2B,OAAO,CAAC,GAAG,KAAE,iBAAiB,EAAE,MAAM,GAAE,CAAC;IAE7E,IAAA,oBAAI,EACF,GAAG,SAAS,kBAAkB,EAC9B,EAAE,GAAG,EAAE,EACP,CAAC,KAA2B,EAAE,MAAc,EAAE,MAAc,EAAE,EAAE;QAC9D,8EAA8E;QAC9E,sEAAsE;QACtE,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;QAC3D,MAAM,aAAa,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEpG,IAAI,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,2CAA2C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,EAAE,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,CAAC,GAAG,CACT,+HAA+H,OAAO,CAAC,GAAG,EAAE,EAAE,CAC/I,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAtCD,sBAsCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { ExecException, exec } from 'child_process';\nimport { getEslintCli } from './utils/get-eslint-cli';\nimport { printPruneHelp } from './utils/print-help';\n\nexport function prune() {\n const args = process.argv.slice(3);\n\n if (args.includes('--help') || args.includes('-h')) {\n printPruneHelp();\n process.exit(0);\n }\n\n if (args.length > 0) {\n throw new Error(`@rushstack/eslint-bulk: Unknown arguments: ${args.join(' ')}`);\n }\n\n const eslintCLI = getEslintCli(process.cwd());\n\n const env: NodeJS.ProcessEnv = { ...process.env, ESLINT_BULK_PRUNE: 'true' };\n\n exec(\n `${eslintCLI} . --format=json`,\n { env },\n (error: ExecException | null, stdout: string, stderr: string) => {\n // if errorCount != 0, ESLint will process.exit(1) giving the false impression\n // that the exec failed, even though linting errors are to be expected\n const eslintOutputWithErrorRegex = /\"errorCount\":(?!0)\\d+/;\n const isEslintError = error !== null && error.code === 1 && eslintOutputWithErrorRegex.test(stdout);\n\n if (error && !isEslintError) {\n throw new Error(`@rushstack/eslint-bulk execution error: ${error.message}`);\n }\n\n if (stderr) {\n throw new Error(`@rushstack/eslint-bulk ESLint errors: ${stderr}`);\n }\n\n console.log(\n `@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json files under directory ${process.cwd()}`\n );\n }\n );\n}\n"]}

View File

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=start.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/start.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,50 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const prune_1 = require("./prune");
const suppress_1 = require("./suppress");
const is_correct_cwd_1 = require("./utils/is-correct-cwd");
const print_help_1 = require("./utils/print-help");
if (process.argv.includes('-h') || process.argv.includes('-H') || process.argv.includes('--help')) {
(0, print_help_1.printHelp)();
process.exit(0);
}
if (process.argv.length < 3) {
(0, print_help_1.printHelp)();
process.exit(1);
}
if (!(0, is_correct_cwd_1.isCorrectCwd)(process.cwd())) {
console.error('@rushstack/eslint-bulk: Please call this command from the directory that contains .eslintrc.js or .eslintrc.cjs');
process.exit(1);
}
const subcommand = process.argv[2];
if (subcommand === 'suppress') {
try {
(0, suppress_1.suppress)();
}
catch (e) {
if (e instanceof Error) {
console.error(e.message);
process.exit(1);
}
throw e;
}
}
else if (subcommand === 'prune') {
try {
(0, prune_1.prune)();
}
catch (e) {
if (e instanceof Error) {
console.error(e.message);
process.exit(1);
}
throw e;
}
}
else {
console.error('@rushstack/eslint-bulk: Unknown subcommand: ' + subcommand);
process.exit(1);
}
//# sourceMappingURL=start.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/start.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,mCAAgC;AAChC,yCAAsC;AACtC,2DAAsD;AACtD,mDAA+C;AAE/C,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAClG,IAAA,sBAAS,GAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;IAC5B,IAAA,sBAAS,GAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,IAAA,6BAAY,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;IACjC,OAAO,CAAC,KAAK,CACX,iHAAiH,CAClH,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;IAC9B,IAAI,CAAC;QACH,IAAA,mBAAQ,GAAE,CAAC;IACb,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;KAAM,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;IAClC,IAAI,CAAC;QACH,IAAA,aAAK,GAAE,CAAC;IACV,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,KAAK,CAAC,8CAA8C,GAAG,UAAU,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { prune } from './prune';\nimport { suppress } from './suppress';\nimport { isCorrectCwd } from './utils/is-correct-cwd';\nimport { printHelp } from './utils/print-help';\n\nif (process.argv.includes('-h') || process.argv.includes('-H') || process.argv.includes('--help')) {\n printHelp();\n process.exit(0);\n}\n\nif (process.argv.length < 3) {\n printHelp();\n process.exit(1);\n}\n\nif (!isCorrectCwd(process.cwd())) {\n console.error(\n '@rushstack/eslint-bulk: Please call this command from the directory that contains .eslintrc.js or .eslintrc.cjs'\n );\n process.exit(1);\n}\nconst subcommand = process.argv[2];\n\nif (subcommand === 'suppress') {\n try {\n suppress();\n } catch (e) {\n if (e instanceof Error) {\n console.error(e.message);\n process.exit(1);\n }\n throw e;\n }\n} else if (subcommand === 'prune') {\n try {\n prune();\n } catch (e) {\n if (e instanceof Error) {\n console.error(e.message);\n process.exit(1);\n }\n throw e;\n }\n} else {\n console.error('@rushstack/eslint-bulk: Unknown subcommand: ' + subcommand);\n process.exit(1);\n}\n"]}

View File

@ -0,0 +1,2 @@
export declare function suppress(): void;
//# sourceMappingURL=suppress.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"suppress.d.ts","sourceRoot":"","sources":["../../../src/eslint-bulk-suppressions/cli/suppress.ts"],"names":[],"mappings":"AAOA,wBAAgB,QAAQ,SA4FvB"}

View File

@ -0,0 +1,76 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.suppress = void 0;
const child_process_1 = require("child_process");
const get_eslint_cli_1 = require("./utils/get-eslint-cli");
const print_help_1 = require("./utils/print-help");
function suppress() {
const args = process.argv.slice(3);
if (args.includes('--help') || args.includes('-h')) {
(0, print_help_1.printSuppressHelp)();
process.exit(0);
}
// Use reduce to create an object with all the parsed arguments
const parsedArgs = args.reduce((acc, arg, index, arr) => {
if (arg === '--rule') {
// continue because next arg should be the rule
}
else if (index > 0 && arr[index - 1] === '--rule' && arr[index + 1]) {
acc.rules.push(arg);
}
else if (arg === '--all') {
acc.all = true;
}
else if (arg.startsWith('--')) {
throw new Error(`@rushstack/eslint-bulk: Unknown option: ${arg}`);
}
else {
acc.files.push(arg);
}
return acc;
}, { rules: [], all: false, files: [] });
if (parsedArgs.files.length === 0) {
throw new Error('@rushstack/eslint-bulk: Files argument is required. Use glob patterns to specify files or use `.` to suppress all files for the specified rules.');
}
if (parsedArgs.rules.length === 0 && !parsedArgs.all) {
throw new Error('@rushstack/eslint-bulk: Please specify at least one rule to suppress. Use --all to suppress all rules.');
}
const eslintCLI = (0, get_eslint_cli_1.getEslintCli)(process.cwd());
// Find the index of the last argument that starts with '--'
const lastOptionIndex = args
.map((arg, i) => (arg.startsWith('--') ? i : -1))
.reduce((lastIndex, currentIndex) => Math.max(lastIndex, currentIndex), -1);
// Check if options come before files
if (parsedArgs.files.some((file) => args.indexOf(file) < lastOptionIndex)) {
throw new Error('@rushstack/eslint-bulk: Unable to parse command line arguments. All options should come before files argument.');
}
const env = Object.assign({}, process.env);
if (parsedArgs.all) {
env.ESLINT_BULK_SUPPRESS = '*';
}
else if (parsedArgs.rules.length > 0) {
env.ESLINT_BULK_SUPPRESS = parsedArgs.rules.join(',');
}
(0, child_process_1.exec)(`${eslintCLI} ${parsedArgs.files.join(' ')} --format=json`, { env }, (error, stdout, stderr) => {
// if errorCount != 0, ESLint will process.exit(1) giving the false impression
// that the exec failed, even though linting errors are to be expected
const eslintOutputWithErrorRegex = /"errorCount":(?!0)\d+/;
const isEslintError = error !== null && error.code === 1 && eslintOutputWithErrorRegex.test(stdout);
if (error && !isEslintError) {
throw new Error(`@rushstack/eslint-bulk execution error: ${error.message}`);
}
if (stderr) {
throw new Error(`@rushstack/eslint-bulk ESLint errors: ${stderr}`);
}
if (parsedArgs.all) {
console.log(`@rushstack/eslint-bulk: Successfully suppressed all rules for file(s) ${parsedArgs.files}`);
}
else if (parsedArgs.rules.length > 0) {
console.log(`@rushstack/eslint-bulk: Successfully suppressed rules ${parsedArgs.rules} for file(s) ${parsedArgs.files}`);
}
});
}
exports.suppress = suppress;
//# sourceMappingURL=suppress.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
export declare function getEslintCli(packagePath: string): string;
//# sourceMappingURL=get-eslint-cli.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"get-eslint-cli.d.ts","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/get-eslint-cli.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAqBxD"}

View File

@ -0,0 +1,30 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEslintCli = void 0;
const path_1 = __importDefault(require("path"));
const TESTED_VERSIONS = ['8.6.0', '8.7.0', '8.21.0', '8.22.0', '8.23.0', '8.23.1'];
function getEslintCli(packagePath) {
// Try to find a local ESLint installation, the one that should be listed as a dev dependency in package.json
// and installed in node_modules
try {
const localEslintApiPath = require.resolve('eslint', { paths: [packagePath] });
const localEslintPath = path_1.default.dirname(path_1.default.dirname(localEslintApiPath));
const eslintPackageJson = require(path_1.default.join(localEslintPath, 'package.json'));
const localEslintVersion = eslintPackageJson.version;
const eslintExecutable = path_1.default.join(localEslintPath, 'bin', 'eslint.js');
if (!TESTED_VERSIONS.includes(localEslintVersion)) {
console.warn('@rushstack/eslint-bulk: Be careful, the installed ESLint version has not been tested with eslint-bulk.');
}
return `node ${eslintExecutable}`;
}
catch (e) {
throw new Error('@rushstack/eslint-bulk: eslint is specified as a dev dependency in package.json, but eslint-bulk cannot find it in node_modules.');
}
}
exports.getEslintCli = getEslintCli;
//# sourceMappingURL=get-eslint-cli.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"get-eslint-cli.js","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/get-eslint-cli.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,gDAAwB;AAExB,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAEnF,SAAgB,YAAY,CAAC,WAAmB;IAC9C,6GAA6G;IAC7G,gCAAgC;IAChC,IAAI,CAAC;QACH,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC/E,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACvE,MAAM,iBAAiB,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;QAC9E,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAAC;QACrD,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QAExE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,CACV,wGAAwG,CACzG,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,gBAAgB,EAAE,CAAC;IACpC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,kIAAkI,CACnI,CAAC;IACJ,CAAC;AACH,CAAC;AArBD,oCAqBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport path from 'path';\n\nconst TESTED_VERSIONS = ['8.6.0', '8.7.0', '8.21.0', '8.22.0', '8.23.0', '8.23.1'];\n\nexport function getEslintCli(packagePath: string): string {\n // Try to find a local ESLint installation, the one that should be listed as a dev dependency in package.json\n // and installed in node_modules\n try {\n const localEslintApiPath = require.resolve('eslint', { paths: [packagePath] });\n const localEslintPath = path.dirname(path.dirname(localEslintApiPath));\n const eslintPackageJson = require(path.join(localEslintPath, 'package.json'));\n const localEslintVersion = eslintPackageJson.version;\n const eslintExecutable = path.join(localEslintPath, 'bin', 'eslint.js');\n\n if (!TESTED_VERSIONS.includes(localEslintVersion)) {\n console.warn(\n '@rushstack/eslint-bulk: Be careful, the installed ESLint version has not been tested with eslint-bulk.'\n );\n }\n return `node ${eslintExecutable}`;\n } catch (e) {\n throw new Error(\n '@rushstack/eslint-bulk: eslint is specified as a dev dependency in package.json, but eslint-bulk cannot find it in node_modules.'\n );\n }\n}\n"]}

View File

@ -0,0 +1,2 @@
export declare function isCorrectCwd(cwd: string): boolean;
//# sourceMappingURL=is-correct-cwd.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"is-correct-cwd.d.ts","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/is-correct-cwd.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD"}

View File

@ -0,0 +1,15 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCorrectCwd = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
function isCorrectCwd(cwd) {
return fs_1.default.existsSync(path_1.default.join(cwd, '.eslintrc.js')) || fs_1.default.existsSync(path_1.default.join(cwd, '.eslintrc.cjs'));
}
exports.isCorrectCwd = isCorrectCwd;
//# sourceMappingURL=is-correct-cwd.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"is-correct-cwd.js","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/is-correct-cwd.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,4CAAoB;AACpB,gDAAwB;AAExB,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;AACzG,CAAC;AAFD,oCAEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport fs from 'fs';\nimport path from 'path';\n\nexport function isCorrectCwd(cwd: string): boolean {\n return fs.existsSync(path.join(cwd, '.eslintrc.js')) || fs.existsSync(path.join(cwd, '.eslintrc.cjs'));\n}\n"]}

View File

@ -0,0 +1,4 @@
export declare function printPruneHelp(): void;
export declare function printHelp(): void;
export declare function printSuppressHelp(): void;
//# sourceMappingURL=print-help.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"print-help.d.ts","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/print-help.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,SAa7B;AAED,wBAAgB,SAAS,SA8BxB;AAED,wBAAgB,iBAAiB,SA6BhC"}

View File

@ -0,0 +1,82 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.printSuppressHelp = exports.printHelp = exports.printPruneHelp = void 0;
const wrap_words_to_lines_1 = require("./wrap-words-to-lines");
function printPruneHelp() {
const help = `eslint-bulk prune
Usage:
eslint-bulk prune
This command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to delete all unused suppression entries in all .eslint-bulk-suppressions.json files under the current working directory.`;
const wrapped = (0, wrap_words_to_lines_1.wrapWordsToLines)(help);
for (const line of wrapped) {
console.log(line);
}
}
exports.printPruneHelp = printPruneHelp;
function printHelp() {
const help = `eslint-bulk <command>
Usage:
eslint-bulk suppress --rule RULENAME1 [--rule RULENAME2...] PATH1 [PATH2...]
eslint-bulk suppress --all PATH1 [PATH2...]
eslint-bulk suppress --help
eslint-bulk prune
eslint-bulk prune --help
eslint-bulk --help
This command line tool is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to suppress or prune unused suppressions in the local .eslint-bulk-suppressions.json file.
Commands:
eslint-bulk suppress [options] <path...>
Use this command to generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.
Please run "eslint-bulk suppress --help" to learn more.
eslint-bulk prune
Use this command to delete all unused suppression entries in all .eslint-bulk-suppressions.json files under the current working directory.
Please run "eslint-bulk prune --help" to learn more.
`;
const wrapped = (0, wrap_words_to_lines_1.wrapWordsToLines)(help);
for (const line of wrapped) {
console.log(line);
}
}
exports.printHelp = printHelp;
function printSuppressHelp() {
const help = `eslint-bulk suppress [options] <path...>
Usage:
eslint-bulk suppress --rule RULENAME1 [--rule RULENAME2...] PATH1 [PATH2...]
eslint-bulk suppress --all PATH1 [PATH2...]
eslint-bulk suppress --help
This command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to either generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.
Argument:
<path...>
Glob patterns for paths to suppress, same as eslint files argument. Should be relative to the project root.
Options:
-h, -H, --help
Display this help message.
-R, --rule
The full name of the ESLint rule you want to bulk-suppress. Specify multiple rules with --rule NAME1 --rule RULENAME2.
-A, --all
Bulk-suppress all rules in the specified file patterns.`;
const wrapped = (0, wrap_words_to_lines_1.wrapWordsToLines)(help);
for (const line of wrapped) {
console.log(line);
}
}
exports.printSuppressHelp = printSuppressHelp;
//# sourceMappingURL=print-help.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"print-help.js","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/print-help.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,+DAAyD;AAEzD,SAAgB,cAAc;IAC5B,MAAM,IAAI,GAAG;;;;;;sNAMuM,CAAC;IAErN,MAAM,OAAO,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAbD,wCAaC;AAED,SAAgB,SAAS;IACvB,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;CAuBd,CAAC;IAEA,MAAM,OAAO,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AA9BD,8BA8BC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;4DAsB6C,CAAC;IAE3D,MAAM,OAAO,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AA7BD,8CA6BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { wrapWordsToLines } from './wrap-words-to-lines';\n\nexport function printPruneHelp() {\n const help = `eslint-bulk prune\n\nUsage:\n\neslint-bulk prune\n\nThis command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to delete all unused suppression entries in all .eslint-bulk-suppressions.json files under the current working directory.`;\n\n const wrapped = wrapWordsToLines(help);\n for (const line of wrapped) {\n console.log(line);\n }\n}\n\nexport function printHelp() {\n const help = `eslint-bulk <command>\n\nUsage:\n\neslint-bulk suppress --rule RULENAME1 [--rule RULENAME2...] PATH1 [PATH2...]\neslint-bulk suppress --all PATH1 [PATH2...]\neslint-bulk suppress --help\n\neslint-bulk prune\neslint-bulk prune --help\n\neslint-bulk --help\n\nThis command line tool is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to suppress or prune unused suppressions in the local .eslint-bulk-suppressions.json file.\n\nCommands:\n eslint-bulk suppress [options] <path...>\n Use this command to generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.\n Please run \"eslint-bulk suppress --help\" to learn more.\n\n eslint-bulk prune\n Use this command to delete all unused suppression entries in all .eslint-bulk-suppressions.json files under the current working directory.\n Please run \"eslint-bulk prune --help\" to learn more.\n`;\n\n const wrapped = wrapWordsToLines(help);\n for (const line of wrapped) {\n console.log(line);\n }\n}\n\nexport function printSuppressHelp() {\n const help = `eslint-bulk suppress [options] <path...>\n\nUsage:\n\neslint-bulk suppress --rule RULENAME1 [--rule RULENAME2...] PATH1 [PATH2...]\neslint-bulk suppress --all PATH1 [PATH2...]\neslint-bulk suppress --help\n\nThis command is a thin wrapper around ESLint that communicates with @rushstack/eslint-patch to either generate a new .eslint-bulk-suppressions.json file or add suppression entries to the existing file. Specify the files and rules you want to suppress.\n\nArgument:\n <path...>\n Glob patterns for paths to suppress, same as eslint files argument. Should be relative to the project root.\n\nOptions:\n -h, -H, --help\n Display this help message.\n\n -R, --rule\n The full name of the ESLint rule you want to bulk-suppress. Specify multiple rules with --rule NAME1 --rule RULENAME2.\n\n -A, --all\n Bulk-suppress all rules in the specified file patterns.`;\n\n const wrapped = wrapWordsToLines(help);\n for (const line of wrapped) {\n console.log(line);\n }\n}\n"]}

View File

@ -0,0 +1,26 @@
/**
* Applies word wrapping and returns an array of lines.
*
* @param text - The text to wrap
* @param maxLineLength - The maximum length of a line, defaults to the console width
* @param indent - The number of spaces to indent the wrapped lines, defaults to 0
*/
export declare function wrapWordsToLines(text: string, maxLineLength?: number, indent?: number): string[];
/**
* Applies word wrapping and returns an array of lines.
*
* @param text - The text to wrap
* @param maxLineLength - The maximum length of a line, defaults to the console width
* @param linePrefix - The string to prefix each line with, defaults to ''
*/
export declare function wrapWordsToLines(text: string, maxLineLength?: number, linePrefix?: string): string[];
/**
* Applies word wrapping and returns an array of lines.
*
* @param text - The text to wrap
* @param maxLineLength - The maximum length of a line, defaults to the console width
* @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix
* each line with, defaults to no prefix
*/
export declare function wrapWordsToLines(text: string, maxLineLength?: number, indentOrLinePrefix?: number | string): string[];
//# sourceMappingURL=wrap-words-to-lines.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"wrap-words-to-lines.d.ts","sourceRoot":"","sources":["../../../../src/eslint-bulk-suppressions/cli/utils/wrap-words-to-lines.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AAClG;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AACtG;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,aAAa,CAAC,EAAE,MAAM,EACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,GACnC,MAAM,EAAE,CAAC"}

View File

@ -0,0 +1,69 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapWordsToLines = void 0;
function wrapWordsToLines(text, maxLineLength, indentOrLinePrefix) {
var _a;
let linePrefix;
switch (typeof indentOrLinePrefix) {
case 'number':
linePrefix = ' '.repeat(indentOrLinePrefix);
break;
case 'string':
linePrefix = indentOrLinePrefix;
break;
default:
linePrefix = '';
break;
}
const linePrefixLength = linePrefix.length;
if (!maxLineLength) {
maxLineLength = process.stdout.getWindowSize()[0];
}
// Apply word wrapping and the provided line prefix, while also respecting existing newlines
// and prefix spaces that may exist in the text string already.
const lines = text.split(/\r?\n/);
const wrappedLines = [];
for (const line of lines) {
if (line.length + linePrefixLength <= maxLineLength) {
wrappedLines.push(linePrefix + line);
}
else {
const lineAdditionalPrefix = ((_a = line.match(/^\s*/)) === null || _a === void 0 ? void 0 : _a[0]) || '';
const whitespaceRegexp = /\s+/g;
let currentWhitespaceMatch = null;
let previousWhitespaceMatch;
let currentLineStartIndex = lineAdditionalPrefix.length;
let previousBreakRanOver = false;
while ((currentWhitespaceMatch = whitespaceRegexp.exec(line)) !== null) {
if (currentWhitespaceMatch.index + linePrefixLength - currentLineStartIndex > maxLineLength) {
let whitespaceToSplitAt;
if (!previousWhitespaceMatch ||
// Handle the case where there are two words longer than the maxLineLength in a row
previousBreakRanOver) {
whitespaceToSplitAt = currentWhitespaceMatch;
}
else {
whitespaceToSplitAt = previousWhitespaceMatch;
}
wrappedLines.push(linePrefix +
lineAdditionalPrefix +
line.substring(currentLineStartIndex, whitespaceToSplitAt.index));
previousBreakRanOver = whitespaceToSplitAt.index - currentLineStartIndex > maxLineLength;
currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;
}
else {
previousBreakRanOver = false;
}
previousWhitespaceMatch = currentWhitespaceMatch;
}
if (currentLineStartIndex < line.length) {
wrappedLines.push(linePrefix + lineAdditionalPrefix + line.substring(currentLineStartIndex));
}
}
}
return wrappedLines;
}
exports.wrapWordsToLines = wrapWordsToLines;
//# sourceMappingURL=wrap-words-to-lines.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
/**
* Dynamically generate file to properly patch many versions of ESLint
* @param inputFilePath Must be an iteration of https://github.com/eslint/eslint/blob/main/lib/linter/linter.js
* @param outputFilePath Some small changes to linter.js
*/
export declare function generatePatchedFileIfDoesntExist(inputFilePath: string, outputFilePath: string): void;
//# sourceMappingURL=generate-patched-file.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"generate-patched-file.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/generate-patched-file.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CA2QpG"}

View File

@ -0,0 +1,251 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePatchedFileIfDoesntExist = void 0;
const fs_1 = __importDefault(require("fs"));
/**
* Dynamically generate file to properly patch many versions of ESLint
* @param inputFilePath Must be an iteration of https://github.com/eslint/eslint/blob/main/lib/linter/linter.js
* @param outputFilePath Some small changes to linter.js
*/
function generatePatchedFileIfDoesntExist(inputFilePath, outputFilePath) {
if (fs_1.default.existsSync(outputFilePath)) {
return;
}
const inputFile = fs_1.default.readFileSync(inputFilePath).toString();
let inputIndex = 0;
/**
* Extract from the stream until marker is reached. When matching marker,
* ignore whitespace in the stream and in the marker. Return the extracted text.
*/
function scanUntilMarker(marker) {
const trimmedMarker = marker.replace(/\s/g, '');
let output = '';
let trimmed = '';
while (inputIndex < inputFile.length) {
const char = inputFile[inputIndex++];
output += char;
if (!/^\s$/.test(char)) {
trimmed += char;
}
if (trimmed.endsWith(trimmedMarker)) {
return output;
}
}
throw new Error('Unexpected end of input while looking for ' + JSON.stringify(marker));
}
function scanUntilNewline() {
let output = '';
while (inputIndex < inputFile.length) {
const char = inputFile[inputIndex++];
output += char;
if (char === '\n') {
return output;
}
}
throw new Error('Unexpected end of input while looking for new line');
}
function scanUntilEnd() {
const output = inputFile.substring(inputIndex);
inputIndex = inputFile.length;
return output;
}
/**
* Returns index of next public method
* @param {number} fromIndex index of inputFile to search if public method still exists
* @returns {number} -1 if public method does not exist or index of next public method
*/
function getIndexOfNextPublicMethod(fromIndex) {
const rest = inputFile.substring(fromIndex);
const endOfClassIndex = rest.indexOf('\n}');
const markerForStartOfClassMethod = '\n */\n ';
const startOfClassMethodIndex = rest.indexOf(markerForStartOfClassMethod);
if (startOfClassMethodIndex === -1 || startOfClassMethodIndex > endOfClassIndex) {
return -1;
}
let afterMarkerIndex = rest.indexOf(markerForStartOfClassMethod) + markerForStartOfClassMethod.length;
const isPublicMethod = rest[afterMarkerIndex] !== '_' &&
rest[afterMarkerIndex] !== '#' &&
!rest.substring(afterMarkerIndex, rest.indexOf('\n', afterMarkerIndex)).includes('static') &&
!rest.substring(afterMarkerIndex, rest.indexOf('\n', afterMarkerIndex)).includes('constructor');
if (isPublicMethod) {
return fromIndex + afterMarkerIndex;
}
return getIndexOfNextPublicMethod(fromIndex + afterMarkerIndex);
}
/**
* @param {number} indexToScanTo
* @returns {string}
*/
function scanUntilIndex(indexToScanTo) {
const output = inputFile.substring(inputIndex, indexToScanTo);
inputIndex = indexToScanTo;
return output;
}
let outputFile = '';
// Match this:
// //------------------------------------------------------------------------------
// // Requirements
// //------------------------------------------------------------------------------
outputFile += scanUntilMarker('// Requirements');
outputFile += scanUntilMarker('//--');
outputFile += scanUntilNewline();
outputFile += `
// --- BEGIN MONKEY PATCH ---
const bulkSuppressionsPatch = require('../../bulk-suppressions-patch');
const requireFromPathToLinterJS = bulkSuppressionsPatch.requireFromPathToLinterJS;
`;
// Match this:
// //------------------------------------------------------------------------------
// // Typedefs
// //------------------------------------------------------------------------------
const requireSection = scanUntilMarker('// Typedefs');
// Match something like this:
//
// const path = require('path'),
// eslintScope = require('eslint-scope'),
// evk = require('eslint-visitor-keys'),
//
// Convert to something like this:
//
// const path = require('path'),
// eslintScope = requireFromPathToLinterJS('eslint-scope'),
// evk = requireFromPathToLinterJS('eslint-visitor-keys'),
//
outputFile += requireSection.replace(/require\s*\((?:'([^']+)'|"([^"]+)")\)/g, (match, p1, p2) => {
var _a;
const importPath = (_a = p1 !== null && p1 !== void 0 ? p1 : p2) !== null && _a !== void 0 ? _a : '';
if (importPath !== 'path') {
if (p1) {
return `requireFromPathToLinterJS('${p1}')`;
}
if (p2) {
return `requireFromPathToLinterJS("${p2}")`;
}
}
// Keep as-is
return match;
});
outputFile += `--- END MONKEY PATCH ---
`;
// Match this:
// const ruleContext = Object.freeze(
// Object.assign(Object.create(sharedTraversalContext), {
// id: ruleId,
// options: getRuleOptions(configuredRules[ruleId]),
// report(...args) {
// /*
// * Create a report translator lazily.
//
// Convert to something like this:
//
// const ruleContext = Object.freeze(
// Object.assign(Object.create(sharedTraversalContext), {
// id: ruleId,
// options: getRuleOptions(configuredRules[ruleId]),
// report(...args) {
// if (bulkSuppressionsPatch.shouldBulkSuppress({ filename, currentNode, ruleId })) return;
// /*
// * Create a report translator lazily.
//
outputFile += scanUntilMarker('const ruleContext = Object.freeze(');
outputFile += scanUntilMarker('report(...args) {');
outputFile += scanUntilNewline();
outputFile += `
// --- BEGIN MONKEY PATCH ---
if (bulkSuppressionsPatch.shouldBulkSuppress({ filename, currentNode, ruleId })) return;
// --- END MONKEY PATCH ---
`;
// Match this:
// nodeQueue.forEach((traversalInfo) => {
// currentNode = traversalInfo.node;
//
// try {
// if (traversalInfo.isEntering) {
// eventGenerator.enterNode(currentNode);
// } else {
// eventGenerator.leaveNode(currentNode);
// }
// } catch (err) {
// err.currentNode = currentNode;
// throw err;
// }
// });
//
// return lintingProblems;
//
// Convert to this:
// nodeQueue.forEach((traversalInfo) => {
// currentNode = traversalInfo.node;
//
// try {
// if (traversalInfo.isEntering) {
// eventGenerator.enterNode(currentNode);
// } else {
// eventGenerator.leaveNode(currentNode);
// }
// } catch (err) {
// err.currentNode = currentNode;
// throw err;
// }
// });
//
// // --- BEGIN MONKEY PATCH ---
// bulkSuppressionsPatch.onFinish({ filename });
// // --- END MONKEY PATCH ---
//
// return lintingProblems;
outputFile += scanUntilMarker('nodeQueue.forEach(traversalInfo => {');
outputFile += scanUntilMarker('});');
outputFile += scanUntilNewline();
outputFile += `
// --- BEGIN MONKEY PATCH ---
bulkSuppressionsPatch.onFinish({ filename });
// --- END MONKEY PATCH ---
`;
outputFile += scanUntilMarker('class Linter {');
outputFile += scanUntilNewline();
outputFile += `
// --- BEGIN MONKEY PATCH ---
/**
* We intercept ESLint execution at the .eslintrc.js file, but unfortunately the Linter class is
* initialized before the .eslintrc.js file is executed. This means the internalSlotsMap that all
* the patched methods refer to is not initialized. This method checks if the internalSlotsMap is
* initialized, and if not, initializes it.
*/
_conditionallyReinitialize({ cwd, configType } = {}) {
if (internalSlotsMap.get(this) === undefined) {
internalSlotsMap.set(this, {
cwd: normalizeCwd(cwd),
lastConfigArray: null,
lastSourceCode: null,
lastSuppressedMessages: [],
configType, // TODO: Remove after flat config conversion
parserMap: new Map([['espree', espree]]),
ruleMap: new Rules()
});
this.version = pkg.version;
}
}
// --- END MONKEY PATCH ---
`;
let indexOfNextPublicMethod = getIndexOfNextPublicMethod(inputIndex);
while (indexOfNextPublicMethod !== -1) {
outputFile += scanUntilIndex(indexOfNextPublicMethod);
outputFile += scanUntilNewline();
outputFile += ` // --- BEGIN MONKEY PATCH ---
this._conditionallyReinitialize();
// --- END MONKEY PATCH ---
`;
indexOfNextPublicMethod = getIndexOfNextPublicMethod(inputIndex);
}
outputFile += scanUntilEnd();
fs_1.default.writeFileSync(outputFilePath, outputFile);
}
exports.generatePatchedFileIfDoesntExist = generatePatchedFileIfDoesntExist;
//# sourceMappingURL=generate-patched-file.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/index.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,24 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const _patch_base_1 = require("../_patch-base");
const path_utils_1 = require("./path-utils");
const bulk_suppressions_patch_1 = require("./bulk-suppressions-patch");
const generate_patched_file_1 = require("./generate-patched-file");
if (!_patch_base_1.eslintFolder) {
console.error('@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.');
process.exit(1);
}
if (process.env._RUSHSTACK_ESLINT_BULK_DETECT === 'true') {
(0, path_utils_1.findAndConsoleLogPatchPathCli)(__dirname);
process.exit(0);
}
const pathToLinterJS = (0, path_utils_1.getPathToLinterJS)();
const nameOfGeneratedPatchFile = (0, path_utils_1.getNameOfGeneratedPatchFile)();
const pathToGeneratedPatch = (0, path_utils_1.getPathToGeneratedPatch)(__dirname, nameOfGeneratedPatchFile);
(0, generate_patched_file_1.generatePatchedFileIfDoesntExist)(pathToLinterJS, pathToGeneratedPatch);
const { Linter: LinterPatch } = require(pathToGeneratedPatch);
const { Linter } = require(pathToLinterJS);
(0, bulk_suppressions_patch_1.patchClass)(Linter, LinterPatch);
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,gDAA8C;AAC9C,6CAKsB;AACtB,uEAAuD;AACvD,mEAA2E;AAE3E,IAAI,CAAC,0BAAY,EAAE,CAAC;IAClB,OAAO,CAAC,KAAK,CACX,gGAAgG,CACjG,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,KAAK,MAAM,EAAE,CAAC;IACzD,IAAA,0CAA6B,EAAC,SAAS,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,cAAc,GAAG,IAAA,8BAAiB,GAAE,CAAC;AAC3C,MAAM,wBAAwB,GAAG,IAAA,wCAA2B,GAAE,CAAC;AAE/D,MAAM,oBAAoB,GAAG,IAAA,oCAAuB,EAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;AAC1F,IAAA,wDAAgC,EAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;AACvE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE9D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAE3C,IAAA,oCAAU,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { eslintFolder } from '../_patch-base';\nimport {\n findAndConsoleLogPatchPathCli,\n getPathToLinterJS,\n getPathToGeneratedPatch,\n getNameOfGeneratedPatchFile\n} from './path-utils';\nimport { patchClass } from './bulk-suppressions-patch';\nimport { generatePatchedFileIfDoesntExist } from './generate-patched-file';\n\nif (!eslintFolder) {\n console.error(\n '@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.'\n );\n process.exit(1);\n}\n\nif (process.env._RUSHSTACK_ESLINT_BULK_DETECT === 'true') {\n findAndConsoleLogPatchPathCli(__dirname);\n process.exit(0);\n}\n\nconst pathToLinterJS = getPathToLinterJS();\nconst nameOfGeneratedPatchFile = getNameOfGeneratedPatchFile();\n\nconst pathToGeneratedPatch = getPathToGeneratedPatch(__dirname, nameOfGeneratedPatchFile);\ngeneratePatchedFileIfDoesntExist(pathToLinterJS, pathToGeneratedPatch);\nconst { Linter: LinterPatch } = require(pathToGeneratedPatch);\n\nconst { Linter } = require(pathToLinterJS);\n\npatchClass(Linter, LinterPatch);\n"]}

View File

@ -0,0 +1,5 @@
export declare function findAndConsoleLogPatchPathCli(patchPath: string): void;
export declare function getPathToLinterJS(): string;
export declare function getPathToGeneratedPatch(patchPath: string, nameOfGeneratedPatchFile: string): string;
export declare function getNameOfGeneratedPatchFile(): string;
//# sourceMappingURL=path-utils.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/path-utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAoBrE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAM1C;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,GAAG,MAAM,CAKnG;AAcD,wBAAgB,2BAA2B,WAI1C"}

View File

@ -0,0 +1,60 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNameOfGeneratedPatchFile = exports.getPathToGeneratedPatch = exports.getPathToLinterJS = exports.findAndConsoleLogPatchPathCli = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const _patch_base_1 = require("../_patch-base");
function findAndConsoleLogPatchPathCli(patchPath) {
if (process.env._RUSHSTACK_ESLINT_BULK_DETECT !== 'true') {
return;
}
const startDelimiter = 'RUSHSTACK_ESLINT_BULK_START';
const endDelimiter = 'RUSHSTACK_ESLINT_BULK_END';
const configuration = {
/**
* `@rushtack/eslint`-bulk should report an error if its package.json is older than this number
*/
minCliVersion: '0.0.0',
/**
* `@rushtack/eslint-bulk` will invoke this entry point
*/
cliEntryPoint: path_1.default.resolve(patchPath, '..', 'exports', 'eslint-bulk.js')
};
console.log(startDelimiter + JSON.stringify(configuration) + endDelimiter);
}
exports.findAndConsoleLogPatchPathCli = findAndConsoleLogPatchPathCli;
function getPathToLinterJS() {
if (!_patch_base_1.eslintFolder) {
throw new Error('Cannot find ESLint installation to patch.');
}
return path_1.default.join(_patch_base_1.eslintFolder, 'lib', 'linter', 'linter.js');
}
exports.getPathToLinterJS = getPathToLinterJS;
function getPathToGeneratedPatch(patchPath, nameOfGeneratedPatchFile) {
fs_1.default.mkdirSync(path_1.default.join(patchPath, 'temp', 'patches'), { recursive: true });
const pathToGeneratedPatch = path_1.default.join(patchPath, 'temp', 'patches', nameOfGeneratedPatchFile);
return pathToGeneratedPatch;
}
exports.getPathToGeneratedPatch = getPathToGeneratedPatch;
function getEslintPackageVersion() {
if (!_patch_base_1.eslintFolder) {
throw new Error('Cannot find ESLint installation to patch.');
}
const eslintPackageJsonPath = path_1.default.join(_patch_base_1.eslintFolder, 'package.json');
const eslintPackageJson = fs_1.default.readFileSync(eslintPackageJsonPath).toString();
const eslintPackageObject = JSON.parse(eslintPackageJson);
const eslintPackageVersion = eslintPackageObject.version;
return eslintPackageVersion;
}
function getNameOfGeneratedPatchFile() {
const eslintPackageVersion = getEslintPackageVersion();
const nameOfGeneratedPatchFile = `linter-patch-v${eslintPackageVersion}.js`;
return nameOfGeneratedPatchFile;
}
exports.getNameOfGeneratedPatchFile = getNameOfGeneratedPatchFile;
//# sourceMappingURL=path-utils.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../src/eslint-bulk-suppressions/path-utils.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,4CAAoB;AACpB,gDAAwB;AACxB,gDAA8C;AAE9C,SAAgB,6BAA6B,CAAC,SAAiB;IAC7D,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,KAAK,MAAM,EAAE,CAAC;QACzD,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,6BAA6B,CAAC;IACrD,MAAM,YAAY,GAAG,2BAA2B,CAAC;IAEjD,MAAM,aAAa,GAAG;QACpB;;WAEG;QACH,aAAa,EAAE,OAAO;QACtB;;WAEG;QACH,aAAa,EAAE,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,CAAC;KAC1E,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC,CAAC;AAC7E,CAAC;AApBD,sEAoBC;AAED,SAAgB,iBAAiB;IAC/B,IAAI,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ed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport fs from 'fs';\nimport path from 'path';\nimport { eslintFolder } from '../_patch-base';\n\nexport function findAndConsoleLogPatchPathCli(patchPath: string): void {\n if (process.env._RUSHSTACK_ESLINT_BULK_DETECT !== 'true') {\n return;\n }\n\n const startDelimiter = 'RUSHSTACK_ESLINT_BULK_START';\n const endDelimiter = 'RUSHSTACK_ESLINT_BULK_END';\n\n const configuration = {\n /**\n * `@rushtack/eslint`-bulk should report an error if its package.json is older than this number\n */\n minCliVersion: '0.0.0',\n /**\n * `@rushtack/eslint-bulk` will invoke this entry point\n */\n cliEntryPoint: path.resolve(patchPath, '..', 'exports', 'eslint-bulk.js')\n };\n\n console.log(startDelimiter + JSON.stringify(configuration) + endDelimiter);\n}\n\nexport function getPathToLinterJS(): string {\n if (!eslintFolder) {\n throw new Error('Cannot find ESLint installation to patch.');\n }\n\n return path.join(eslintFolder, 'lib', 'linter', 'linter.js');\n}\n\nexport function getPathToGeneratedPatch(patchPath: string, nameOfGeneratedPatchFile: string): string {\n fs.mkdirSync(path.join(patchPath, 'temp', 'patches'), { recursive: true });\n const pathToGeneratedPatch = path.join(patchPath, 'temp', 'patches', nameOfGeneratedPatchFile);\n\n return pathToGeneratedPatch;\n}\n\nfunction getEslintPackageVersion() {\n if (!eslintFolder) {\n throw new Error('Cannot find ESLint installation to patch.');\n }\n const eslintPackageJsonPath = path.join(eslintFolder, 'package.json');\n const eslintPackageJson = fs.readFileSync(eslintPackageJsonPath).toString();\n const eslintPackageObject = JSON.parse(eslintPackageJson);\n const eslintPackageVersion = eslintPackageObject.version;\n\n return eslintPackageVersion;\n}\n\nexport function getNameOfGeneratedPatchFile() {\n const eslintPackageVersion = getEslintPackageVersion();\n const nameOfGeneratedPatchFile = `linter-patch-v${eslintPackageVersion}.js`;\n return nameOfGeneratedPatchFile;\n}\n"]}