Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rushstack/eslint-patch

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rushstack/eslint-patch - npm Package Compare versions

Comparing version 1.10.4 to 2.0.0-pr5055.0

10

lib/eslint-bulk-suppressions/bulk-suppressions-file.js

@@ -13,3 +13,2 @@ "use strict";

const TEN_SECONDS_MS = 10 * 1000;
const SUPPRESSIONS_JSON_FILENAME = '.eslint-bulk-suppressions.json';
function throwIfAnythingOtherThanNotExistError(e) {

@@ -34,6 +33,7 @@ if ((e === null || e === void 0 ? void 0 : e.code) !== 'ENOENT') {

if (shouldLoad) {
const suppressionsPath = `${eslintrcFolderPath}/${SUPPRESSIONS_JSON_FILENAME}`;
const suppressionsPath = `${eslintrcFolderPath}/${constants_1.SUPPRESSIONS_JSON_FILENAME}`;
let rawJsonFile;
try {
rawJsonFile = fs_1.default.readFileSync(suppressionsPath).toString();
// Decoding during read hits an optimized fast path in NodeJS.
rawJsonFile = fs_1.default.readFileSync(suppressionsPath, 'utf8');
}

@@ -80,3 +80,3 @@ catch (e) {

suppressionsJsonByFolderPath.set(eslintrcFolderPath, { readTime: Date.now(), suppressionsConfig });
const suppressionsPath = `${eslintrcFolderPath}/${SUPPRESSIONS_JSON_FILENAME}`;
const suppressionsPath = `${eslintrcFolderPath}/${constants_1.SUPPRESSIONS_JSON_FILENAME}`;
if (suppressionsConfig.jsonObject.suppressions.length === 0) {

@@ -92,3 +92,3 @@ deleteFile(suppressionsPath);

function deleteBulkSuppressionsFileInEslintrcFolder(eslintrcFolderPath) {
const suppressionsPath = `${eslintrcFolderPath}/${SUPPRESSIONS_JSON_FILENAME}`;
const suppressionsPath = `${eslintrcFolderPath}/${constants_1.SUPPRESSIONS_JSON_FILENAME}`;
deleteFile(suppressionsPath);

@@ -95,0 +95,0 @@ }

import type { TSESTree } from '@typescript-eslint/types';
import { type IBulkSuppressionsConfig, type ISuppression } from './bulk-suppressions-file';
declare const SUPPRESSION_SYMBOL: unique symbol;
import { type ISuppression } from './bulk-suppressions-file';
interface IBulkSuppression {
suppression: ISuppression;
serializedSuppression: string;
}
interface IProblem {
[SUPPRESSION_SYMBOL]?: {
config: IBulkSuppressionsConfig;
suppression: ISuppression;
serializedSuppression: string;
};
line: number;
column: number;
ruleId: string;
suppressions?: {
kind: string;
justification: string;
}[];
}
export declare function shouldBulkSuppress(params: {
filename: string;
currentNode: TSESTree.Node;
ruleId: string;
interface ILocation {
line: number;
column: number;
}
interface ISourceCode {
ast: TSESTree.Node;
getNodeByRangeIndex(index: number): TSESTree.Node;
getIndexFromLoc(loc: ILocation): number;
text: string;
visitorKeys: Record<string, string[]>;
}
export interface ITraverser {
traverse(node: TSESTree.Node, options: ITraverseOptions): void;
}
export interface ITraverseMethods {
break(): void;
skip(): void;
}
export interface ITraverseOptions {
visitorKeys: Record<string, string[]>;
enter(this: ITraverseOptions & ITraverseMethods, node: TSESTree.Node): void;
leave(this: ITraverseOptions & ITraverseMethods, node: TSESTree.Node): void;
}
interface ILinterInternalSlots {
lastSourceCode: ISourceCode | undefined;
lastSuppressedMessages: IProblem[] | undefined;
}
export declare function getBulkSuppression(params: {
serializedSuppressions: Set<string>;
fileRelativePath: string;
scopeId: string;
problem: IProblem;
}): boolean;
}): IBulkSuppression | undefined;
export declare function prune(): void;
export declare function write(): void;
export declare function requireFromPathToLinterJS(importPath: string): import('eslint').Linter;
export declare function patchClass<T, U extends T>(originalClass: new () => T, patchedClass: new () => U): void;
/**

@@ -27,4 +57,4 @@ * This returns a wrapped version of the "verify" function from ESLint's Linter class

*/
export declare function extendVerifyFunction(originalFn: (this: unknown, ...args: unknown[]) => IProblem[] | undefined): (this: unknown, ...args: unknown[]) => IProblem[] | undefined;
export declare function extendVerifyFunction(originalFn: (this: unknown, ...args: unknown[]) => IProblem[] | undefined, getLinterInternalSlots: (linter: unknown) => ILinterInternalSlots, traverser: ITraverser): (this: unknown, ...args: unknown[]) => IProblem[] | undefined;
export {};
//# sourceMappingURL=bulk-suppressions-patch.d.ts.map

@@ -31,6 +31,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.extendVerifyFunction = exports.patchClass = exports.requireFromPathToLinterJS = exports.write = exports.prune = exports.shouldBulkSuppress = void 0;
exports.extendVerifyFunction = exports.write = exports.prune = exports.getBulkSuppression = void 0;
const fs_1 = __importDefault(require("fs"));
const Guards = __importStar(require("./ast-guards"));
const _patch_base_1 = require("../_patch-base");
const constants_1 = require("./constants");

@@ -44,3 +43,2 @@ const bulk_suppressions_file_1 = require("./bulk-suppressions-file");

];
const SUPPRESSION_SYMBOL = Symbol('suppression');
const ESLINT_BULK_SUPPRESS_ENV_VAR_VALUE = process.env[constants_1.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME];

@@ -89,19 +87,10 @@ const SUPPRESS_ALL_RULES = ESLINT_BULK_SUPPRESS_ENV_VAR_VALUE === '*';

}
function calculateScopeId(node) {
const scopeIds = [];
for (let current = node; current; current = current.parent) {
const scopeIdForASTNode = getNodeName(current);
if (scopeIdForASTNode !== undefined) {
scopeIds.unshift(scopeIdForASTNode);
}
}
if (scopeIds.length === 0) {
return '.';
}
else {
return '.' + scopeIds.join('.');
}
}
const eslintrcPathByFileOrFolderPath = new Map();
function findEslintrcFolderPathForNormalizedFileAbsolutePath(normalizedFilePath) {
// Heft, for example, suppresses nested eslintrc files, so it can pass this environment variable to suppress
// searching for the eslintrc file completely.
let eslintrcFolderPath = process.env[constants_1.ESLINT_BULK_ESLINTRC_FOLDER_PATH_ENV_VAR_NAME];
if (eslintrcFolderPath) {
return eslintrcFolderPath;
}
const cachedFolderPathForFilePath = eslintrcPathByFileOrFolderPath.get(normalizedFilePath);

@@ -113,3 +102,2 @@ if (cachedFolderPathForFilePath) {

const pathsToCache = [normalizedFilePath];
let eslintrcFolderPath;
findEslintrcFileLoop: for (let currentFolder = normalizedFileFolderPath; currentFolder; // 'something'.substring(0, -1) is ''

@@ -139,27 +127,23 @@ currentFolder = currentFolder.substring(0, currentFolder.lastIndexOf('/'))) {

}
// 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[constants_1.ESLINT_BULK_ENABLE_ENV_VAR_NAME] === 'false') {
return false;
}
const { filename: fileAbsolutePath, currentNode, ruleId: rule, problem } = params;
const normalizedFileAbsolutePath = fileAbsolutePath.replace(/\\/g, '/');
const eslintrcDirectory = findEslintrcFolderPathForNormalizedFileAbsolutePath(normalizedFileAbsolutePath);
const fileRelativePath = normalizedFileAbsolutePath.substring(eslintrcDirectory.length + 1);
const scopeId = calculateScopeId(currentNode);
function getBulkSuppression(params) {
const { fileRelativePath, serializedSuppressions, scopeId, problem } = params;
const { ruleId: rule } = problem;
const suppression = { file: fileRelativePath, scopeId, rule };
const config = (0, bulk_suppressions_file_1.getSuppressionsConfigForEslintrcFolderPath)(eslintrcDirectory);
const serializedSuppression = (0, bulk_suppressions_file_1.serializeSuppression)(suppression);
const currentNodeIsSuppressed = config.serializedSuppressions.has(serializedSuppression);
const currentNodeIsSuppressed = serializedSuppressions.has(serializedSuppression);
if (currentNodeIsSuppressed || SUPPRESS_ALL_RULES || (RULES_TO_SUPPRESS === null || RULES_TO_SUPPRESS === void 0 ? void 0 : RULES_TO_SUPPRESS.has(suppression.rule))) {
problem[SUPPRESSION_SYMBOL] = {
// The suppressions object should already be empty, otherwise we shouldn't see this problem
problem.suppressions = [
{
kind: 'bulk',
justification: serializedSuppression
}
];
return {
suppression,
serializedSuppression,
config
serializedSuppression
};
}
return process.env[constants_1.ESLINT_BULK_PRUNE_ENV_VAR_NAME] !== '1' && currentNodeIsSuppressed;
}
exports.shouldBulkSuppress = shouldBulkSuppress;
exports.getBulkSuppression = getBulkSuppression;
function prune() {

@@ -188,28 +172,72 @@ for (const [eslintrcFolderPath, suppressionsConfig] of (0, bulk_suppressions_file_1.getAllBulkSuppressionsConfigsByEslintrcFolderPath)()) {

exports.write = write;
// 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);
function binarySearch(arr, target, low, high) {
while (low <= high) {
// eslint-disable-next-line no-bitwise
const mid = (low + high) >> 1;
const midVal = arr[mid];
if (midVal === target) {
return mid;
}
else if (midVal < target) {
low = mid + 1;
}
else {
high = mid - 1;
}
}
const pathToLinterFolder = `${_patch_base_1.eslintFolder}/lib/linter`;
const moduleAbsolutePath = require.resolve(importPath, { paths: [pathToLinterFolder] });
return require(moduleAbsolutePath);
// eslint-disable-next-line no-bitwise
return ~low;
}
exports.requireFromPathToLinterJS = requireFromPathToLinterJS;
function patchClass(originalClass, patchedClass) {
// Get all the property names of the patched class prototype
const patchedProperties = Object.getOwnPropertyNames(patchedClass.prototype);
// Loop through all the properties
for (const prop of patchedProperties) {
// Override the property in the original class
originalClass.prototype[prop] = patchedClass.prototype[prop];
function getScopeIdMap(traverser, sourceCode, positions) {
const scopeIdMap = new Map();
if (positions.length === 0) {
return scopeIdMap;
}
// Handle getters and setters
for (const [prop, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(patchedClass.prototype))) {
if (descriptor.get || descriptor.set) {
Object.defineProperty(originalClass.prototype, prop, descriptor);
let low = 0;
let high = positions.length - 1;
const max = positions[high];
const highStack = [];
traverser.traverse(sourceCode.ast, {
visitorKeys: sourceCode.visitorKeys,
enter(node) {
const startInclusive = node.range[0];
if (startInclusive > max) {
// Future nodes irrelevant. We can break out of the traversal.
return this.break();
}
highStack.push(high);
const endInclusive = node.range[1] - 1;
let newLow = binarySearch(positions, startInclusive, low, high);
let newHigh = binarySearch(positions, endInclusive, low, high);
if (newLow < 0) {
// Start point before the current minimum gets excluded
newLow = ~newLow;
}
if (newHigh < 0) {
// End point above the current maximum gets excluded
newHigh = ~newHigh - 1;
}
if (newLow > newHigh) {
return this.skip();
}
low = newLow;
high = newHigh;
const currentNodeName = getNodeName(node);
if (currentNodeName) {
const existingScopeId = scopeIdMap.get(positions[low]);
const newScopeId = `${existingScopeId !== null && existingScopeId !== void 0 ? existingScopeId : ''}.${currentNodeName}`;
for (let i = low; i <= high; i++) {
scopeIdMap.set(positions[i], newScopeId);
}
}
},
leave(node) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const oldHigh = highStack.pop();
// Traversal has monotonically increasing positions, so no need to reduce low
high = oldHigh;
}
}
});
return scopeIdMap;
}
exports.patchClass = patchClass;
/**

@@ -221,18 +249,65 @@ * This returns a wrapped version of the "verify" function from ESLint's Linter class

*/
function extendVerifyFunction(originalFn) {
function extendVerifyFunction(originalFn, getLinterInternalSlots, traverser) {
return function (...args) {
var _a;
const problems = originalFn.apply(this, args);
if (problems) {
for (const problem of problems) {
if (problem[SUPPRESSION_SYMBOL]) {
const { serializedSuppression, suppression, config: { newSerializedSuppressions, jsonObject: { suppressions }, newJsonObject: { suppressions: newSuppressions } } } = problem[SUPPRESSION_SYMBOL];
if (!newSerializedSuppressions.has(serializedSuppression)) {
newSerializedSuppressions.add(serializedSuppression);
newSuppressions.push(suppression);
suppressions.push(suppression);
}
if (!problems) {
return problems;
}
const internalSlots = getLinterInternalSlots(this);
const { lastSourceCode } = internalSlots;
if (!lastSourceCode) {
// We don't have a file for context, nothing we can do here.
return problems;
}
if (args.length < 3) {
throw new Error('Expected at least 3 arguments to Linter.prototype.verify');
}
const fileNameOrOptions = args[2];
const filename = typeof fileNameOrOptions === 'string' ? fileNameOrOptions : fileNameOrOptions.filename;
let { lastSuppressedMessages } = internalSlots;
const positions = [];
const problemToPositionMap = new Map();
for (const problem of problems) {
const { line, column } = problem;
if (typeof line === 'number' && typeof column === 'number') {
const position = lastSourceCode.getIndexFromLoc({ line, column: column - 1 });
problemToPositionMap.set(problem, position);
positions.push(position);
}
}
positions.sort((x, y) => x - y);
const scopeIdMap = getScopeIdMap(traverser, lastSourceCode, positions);
const normalizedFileAbsolutePath = filename.replace(/\\/g, '/');
const eslintrcDirectory = findEslintrcFolderPathForNormalizedFileAbsolutePath(normalizedFileAbsolutePath);
const fileRelativePath = normalizedFileAbsolutePath.substring(eslintrcDirectory.length + 1);
const config = (0, bulk_suppressions_file_1.getSuppressionsConfigForEslintrcFolderPath)(eslintrcDirectory);
const { newSerializedSuppressions, serializedSuppressions, jsonObject: { suppressions }, newJsonObject: { suppressions: newSuppressions } } = config;
const filteredProblems = [];
for (const problem of problems) {
const position = problemToPositionMap.get(problem);
const scopeId = position === undefined ? '.' : (_a = scopeIdMap.get(position)) !== null && _a !== void 0 ? _a : '.';
const bulkSuppression = getBulkSuppression({
fileRelativePath,
serializedSuppressions,
scopeId,
problem
});
if (!bulkSuppression) {
filteredProblems.push(problem);
continue;
}
const { serializedSuppression, suppression } = bulkSuppression;
if (!newSerializedSuppressions.has(serializedSuppression)) {
newSerializedSuppressions.add(serializedSuppression);
newSuppressions.push(suppression);
suppressions.push(suppression);
if (!lastSuppressedMessages) {
lastSuppressedMessages = [];
internalSlots.lastSuppressedMessages = lastSuppressedMessages;
}
lastSuppressedMessages.push(problem);
}
}
return problems;
return filteredProblems;
};

@@ -239,0 +314,0 @@ }

@@ -58,3 +58,3 @@ "use strict";

const stylishFormatter = await eslint.loadFormatter();
const formattedResults = stylishFormatter.format(results);
const formattedResults = await Promise.resolve(stylishFormatter.format(results));
console.log(formattedResults);

@@ -61,0 +61,0 @@ }

@@ -1,10 +0,10 @@

export declare const ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_PATCH_PATH';
export declare const ESLINT_BULK_SUPPRESS_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_SUPPRESS';
export declare const ESLINT_BULK_ENABLE_ENV_VAR_NAME: 'ESLINT_BULK_ENABLE';
export declare const ESLINT_BULK_PRUNE_ENV_VAR_NAME: 'ESLINT_BULK_PRUNE';
export declare const ESLINT_BULK_ESLINTRC_FOLDER_PATH_ENV_VAR_NAME: 'ESLINT_BULK_ESLINTRC_FOLDER_PATH';
export declare const ESLINT_BULK_DETECT_ENV_VAR_NAME: '_RUSHSTACK_ESLINT_BULK_DETECT';
export declare const ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME: 'RUSHSTACK_ESLINT_BULK_FORCE_REGENERATE_PATCH';
export declare const VSCODE_PID_ENV_VAR_NAME: 'VSCODE_PID';
export declare const ESLINT_PACKAGE_NAME_ENV_VAR_NAME: '_RUSHSTACK_ESLINT_PACKAGE_NAME';
export declare const BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME: string;
export declare const SUPPRESSIONS_JSON_FILENAME: '.eslint-bulk-suppressions.json';
//# sourceMappingURL=constants.d.ts.map

@@ -6,12 +6,12 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME = exports.ESLINT_PACKAGE_NAME_ENV_VAR_NAME = exports.VSCODE_PID_ENV_VAR_NAME = exports.ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME = exports.ESLINT_BULK_DETECT_ENV_VAR_NAME = exports.ESLINT_BULK_PRUNE_ENV_VAR_NAME = exports.ESLINT_BULK_ENABLE_ENV_VAR_NAME = exports.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME = exports.ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME = void 0;
exports.ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME = 'RUSHSTACK_ESLINT_BULK_PATCH_PATH';
exports.SUPPRESSIONS_JSON_FILENAME = exports.BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME = exports.ESLINT_PACKAGE_NAME_ENV_VAR_NAME = exports.VSCODE_PID_ENV_VAR_NAME = exports.ESLINT_BULK_DETECT_ENV_VAR_NAME = exports.ESLINT_BULK_ESLINTRC_FOLDER_PATH_ENV_VAR_NAME = exports.ESLINT_BULK_PRUNE_ENV_VAR_NAME = exports.ESLINT_BULK_ENABLE_ENV_VAR_NAME = exports.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME = void 0;
exports.ESLINT_BULK_SUPPRESS_ENV_VAR_NAME = 'RUSHSTACK_ESLINT_BULK_SUPPRESS';
exports.ESLINT_BULK_ENABLE_ENV_VAR_NAME = 'ESLINT_BULK_ENABLE';
exports.ESLINT_BULK_PRUNE_ENV_VAR_NAME = 'ESLINT_BULK_PRUNE';
exports.ESLINT_BULK_ESLINTRC_FOLDER_PATH_ENV_VAR_NAME = 'ESLINT_BULK_ESLINTRC_FOLDER_PATH';
exports.ESLINT_BULK_DETECT_ENV_VAR_NAME = '_RUSHSTACK_ESLINT_BULK_DETECT';
exports.ESLINT_BULK_FORCE_REGENERATE_PATCH_ENV_VAR_NAME = 'RUSHSTACK_ESLINT_BULK_FORCE_REGENERATE_PATCH';
exports.VSCODE_PID_ENV_VAR_NAME = 'VSCODE_PID';
exports.ESLINT_PACKAGE_NAME_ENV_VAR_NAME = '_RUSHSTACK_ESLINT_PACKAGE_NAME';
exports.BULK_SUPPRESSIONS_CLI_ESLINT_PACKAGE_NAME = (_a = process.env[exports.ESLINT_PACKAGE_NAME_ENV_VAR_NAME]) !== null && _a !== void 0 ? _a : 'eslint';
exports.SUPPRESSIONS_JSON_FILENAME = '.eslint-bulk-suppressions.json';
//# sourceMappingURL=constants.js.map

@@ -8,21 +8,23 @@ "use strict";

const bulk_suppressions_patch_1 = require("./bulk-suppressions-patch");
const generate_patched_file_1 = require("./generate-patched-file");
const constants_1 = require("./constants");
if (!_patch_base_1.eslintFolder) {
console.error('@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.');
process.exit(1);
function apply() {
if (!_patch_base_1.eslintFolder) {
console.error('@rushstack/eslint-patch/eslint-bulk-suppressions: Could not find ESLint installation to patch.');
process.exit(1);
}
const eslintBulkDetectEnvVarValue = process.env[constants_1.ESLINT_BULK_DETECT_ENV_VAR_NAME];
if (eslintBulkDetectEnvVarValue === 'true' || eslintBulkDetectEnvVarValue === '1') {
(0, path_utils_1.findAndConsoleLogPatchPathCli)();
process.exit(0);
}
if (process.env[constants_1.ESLINT_BULK_ENABLE_ENV_VAR_NAME] === 'false') {
return;
}
const { linterPath, traverserPath } = (0, path_utils_1.getPathsToPatch)();
const { Linter, getLinterInternalSlots } = require(linterPath);
const Traverser = require(traverserPath);
const { verify: originalVerify } = Linter.prototype;
Linter.prototype.verify = (0, bulk_suppressions_patch_1.extendVerifyFunction)(originalVerify, getLinterInternalSlots, Traverser);
}
const eslintBulkDetectEnvVarValue = process.env[constants_1.ESLINT_BULK_DETECT_ENV_VAR_NAME];
if (eslintBulkDetectEnvVarValue === 'true' || eslintBulkDetectEnvVarValue === '1') {
(0, path_utils_1.findAndConsoleLogPatchPathCli)();
process.exit(0);
}
const pathToLinterJS = (0, path_utils_1.getPathToLinterJS)();
process.env[constants_1.ESLINT_BULK_PATCH_PATH_ENV_VAR_NAME] = require.resolve('./bulk-suppressions-patch');
const pathToGeneratedPatch = (0, path_utils_1.ensurePathToGeneratedPatch)();
(0, generate_patched_file_1.generatePatchedLinterJsFileIfDoesNotExist)(pathToLinterJS, pathToGeneratedPatch);
const { Linter: LinterPatch } = require(pathToGeneratedPatch);
LinterPatch.prototype.verify = (0, bulk_suppressions_patch_1.extendVerifyFunction)(LinterPatch.prototype.verify);
const { Linter } = require(pathToLinterJS);
(0, bulk_suppressions_patch_1.patchClass)(Linter, LinterPatch);
apply();
//# sourceMappingURL=index.js.map
export declare function findAndConsoleLogPatchPathCli(): void;
export declare function getPathToLinterJS(): string;
export declare function ensurePathToGeneratedPatch(): string;
export interface IPathsToPatch {
linterPath: string;
traverserPath: string;
}
export declare function getPathsToPatch(): IPathsToPatch;
//# sourceMappingURL=path-utils.d.ts.map
"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.ensurePathToGeneratedPatch = exports.getPathToLinterJS = exports.findAndConsoleLogPatchPathCli = void 0;
const fs_1 = __importDefault(require("fs"));
const os_1 = __importDefault(require("os"));
exports.getPathsToPatch = exports.findAndConsoleLogPatchPathCli = void 0;
const _patch_base_1 = require("../_patch-base");
const constants_1 = require("./constants");
const package_json_1 = __importDefault(require("../../package.json"));
const CURRENT_PACKAGE_VERSION = package_json_1.default.version;
function findAndConsoleLogPatchPathCli() {

@@ -35,16 +28,12 @@ const eslintBulkDetectEnvVarValue = process.env[constants_1.ESLINT_BULK_DETECT_ENV_VAR_NAME];

exports.findAndConsoleLogPatchPathCli = findAndConsoleLogPatchPathCli;
function getPathToLinterJS() {
function getPathsToPatch() {
if (!_patch_base_1.eslintFolder) {
throw new Error('Cannot find ESLint installation to patch.');
}
return `${_patch_base_1.eslintFolder}/lib/linter/linter.js`;
return {
linterPath: `${_patch_base_1.eslintFolder}/lib/linter/linter.js`,
traverserPath: `${_patch_base_1.eslintFolder}/lib/shared/traverser.js`
};
}
exports.getPathToLinterJS = getPathToLinterJS;
function ensurePathToGeneratedPatch() {
const patchesFolderPath = `${os_1.default.tmpdir()}/rushstack-eslint-bulk-${CURRENT_PACKAGE_VERSION}/patches`;
fs_1.default.mkdirSync(patchesFolderPath, { recursive: true });
const pathToGeneratedPatch = `${patchesFolderPath}/linter-patch-v${_patch_base_1.eslintPackageVersion}.js`;
return pathToGeneratedPatch;
}
exports.ensurePathToGeneratedPatch = ensurePathToGeneratedPatch;
exports.getPathsToPatch = getPathsToPatch;
//# sourceMappingURL=path-utils.js.map
{
"name": "@rushstack/eslint-patch",
"version": "1.10.4",
"version": "2.0.0-pr5055.0",
"description": "Enhance ESLint with better support for large scale monorepos",

@@ -29,5 +29,5 @@ "main": "lib/usage.js",

"devDependencies": {
"@rushstack/heft": "0.66.17",
"@rushstack/heft-node-rig": "2.6.15",
"@types/eslint": "8.2.0",
"@rushstack/heft": "0.68.10",
"@rushstack/heft-node-rig": "2.6.44",
"@types/eslint": "8.56.10",
"@types/node": "18.17.15",

@@ -34,0 +34,0 @@ "@typescript-eslint/types": "~5.59.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc