@rushstack/eslint-patch
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -17,4 +17,5 @@ export interface ISuppression { | ||
export declare function getAllBulkSuppressionsConfigsByEslintrcFolderPath(): [string, IBulkSuppressionsConfig][]; | ||
export declare function writeSuppressionsJsonToFile(eslintrcDirectory: string, suppressionsConfig: IBulkSuppressionsConfig): void; | ||
export declare function writeSuppressionsJsonToFile(eslintrcFolderPath: string, suppressionsConfig: IBulkSuppressionsConfig): void; | ||
export declare function deleteBulkSuppressionsFileInEslintrcFolder(eslintrcFolderPath: string): void; | ||
export declare function serializeSuppression({ file, scopeId, rule }: ISuppression): string; | ||
//# sourceMappingURL=bulk-suppressions-file.d.ts.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serializeSuppression = exports.writeSuppressionsJsonToFile = exports.getAllBulkSuppressionsConfigsByEslintrcFolderPath = exports.getSuppressionsConfigForEslintrcFolderPath = void 0; | ||
exports.serializeSuppression = exports.deleteBulkSuppressionsFileInEslintrcFolder = exports.writeSuppressionsJsonToFile = exports.getAllBulkSuppressionsConfigsByEslintrcFolderPath = exports.getSuppressionsConfigForEslintrcFolderPath = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -77,12 +77,7 @@ const constants_1 = require("./constants"); | ||
exports.getAllBulkSuppressionsConfigsByEslintrcFolderPath = getAllBulkSuppressionsConfigsByEslintrcFolderPath; | ||
function writeSuppressionsJsonToFile(eslintrcDirectory, suppressionsConfig) { | ||
suppressionsJsonByFolderPath.set(eslintrcDirectory, { readTime: Date.now(), suppressionsConfig }); | ||
const suppressionsPath = `${eslintrcDirectory}/${SUPPRESSIONS_JSON_FILENAME}`; | ||
function writeSuppressionsJsonToFile(eslintrcFolderPath, suppressionsConfig) { | ||
suppressionsJsonByFolderPath.set(eslintrcFolderPath, { readTime: Date.now(), suppressionsConfig }); | ||
const suppressionsPath = `${eslintrcFolderPath}/${SUPPRESSIONS_JSON_FILENAME}`; | ||
if (suppressionsConfig.jsonObject.suppressions.length === 0) { | ||
try { | ||
fs_1.default.unlinkSync(suppressionsPath); | ||
} | ||
catch (e) { | ||
throwIfAnythingOtherThanNotExistError(e); | ||
} | ||
deleteFile(suppressionsPath); | ||
} | ||
@@ -95,2 +90,15 @@ else { | ||
exports.writeSuppressionsJsonToFile = writeSuppressionsJsonToFile; | ||
function deleteBulkSuppressionsFileInEslintrcFolder(eslintrcFolderPath) { | ||
const suppressionsPath = `${eslintrcFolderPath}/${SUPPRESSIONS_JSON_FILENAME}`; | ||
deleteFile(suppressionsPath); | ||
} | ||
exports.deleteBulkSuppressionsFileInEslintrcFolder = deleteBulkSuppressionsFileInEslintrcFolder; | ||
function deleteFile(filePath) { | ||
try { | ||
fs_1.default.unlinkSync(filePath); | ||
} | ||
catch (e) { | ||
throwIfAnythingOtherThanNotExistError(e); | ||
} | ||
} | ||
function serializeSuppression({ file, scopeId, rule }) { | ||
@@ -97,0 +105,0 @@ return `${file}|${scopeId}|${rule}`; |
@@ -23,9 +23,17 @@ "use strict"; | ||
} | ||
process.env[constants_1.ESLINT_BULK_PRUNE_ENV_VAR_NAME] = '1'; | ||
const allFiles = await getAllFilesWithExistingSuppressionsForCwdAsync(); | ||
await (0, runEslint_1.runEslintAsync)(allFiles, 'prune'); | ||
const normalizedCwd = process.cwd().replace(/\\/g, '/'); | ||
const allFiles = await getAllFilesWithExistingSuppressionsForCwdAsync(normalizedCwd); | ||
if (allFiles.length > 0) { | ||
process.env[constants_1.ESLINT_BULK_PRUNE_ENV_VAR_NAME] = '1'; | ||
console.log(`Pruning suppressions for ${allFiles.length} files...`); | ||
await (0, runEslint_1.runEslintAsync)(allFiles, 'prune'); | ||
} | ||
else { | ||
console.log('No files with existing suppressions found.'); | ||
(0, bulk_suppressions_file_1.deleteBulkSuppressionsFileInEslintrcFolder)(normalizedCwd); | ||
} | ||
} | ||
exports.pruneAsync = pruneAsync; | ||
async function getAllFilesWithExistingSuppressionsForCwdAsync() { | ||
const { jsonObject: bulkSuppressionsConfigJson } = (0, bulk_suppressions_file_1.getSuppressionsConfigForEslintrcFolderPath)(process.cwd().replace(/\\/g, '/')); | ||
async function getAllFilesWithExistingSuppressionsForCwdAsync(normalizedCwd) { | ||
const { jsonObject: bulkSuppressionsConfigJson } = (0, bulk_suppressions_file_1.getSuppressionsConfigForEslintrcFolderPath)(normalizedCwd); | ||
const allFiles = new Set(); | ||
@@ -52,5 +60,4 @@ for (const { file: filePath } of bulkSuppressionsConfigJson.suppressions) { | ||
} | ||
console.log(`Pruning suppressions for ${allExistingFiles.length} files...`); | ||
return allExistingFiles; | ||
} | ||
//# sourceMappingURL=prune.js.map |
@@ -31,7 +31,8 @@ "use strict"; | ||
async function runEslintAsync(files, mode) { | ||
const eslintPath = (0, get_eslint_cli_1.getEslintPath)(process.cwd()); | ||
const cwd = process.cwd(); | ||
const eslintPath = (0, get_eslint_cli_1.getEslintPath)(cwd); | ||
const { ESLint } = require(eslintPath); | ||
const eslint = new ESLint({ | ||
useEslintrc: true, | ||
cwd: process.cwd() | ||
cwd | ||
}); | ||
@@ -56,13 +57,11 @@ let results; | ||
} | ||
const stylishFormatter = await eslint.loadFormatter(); | ||
const formattedResults = stylishFormatter.format(results); | ||
if (formattedResults) { | ||
if (results.length > 0) { | ||
const stylishFormatter = await eslint.loadFormatter(); | ||
const formattedResults = stylishFormatter.format(results); | ||
console.log(formattedResults); | ||
throw new Error(`@rushstack/eslint-bulk ESLint errors`); | ||
} | ||
else { | ||
console.log(`@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json files under directory ${process.cwd()}`); | ||
} | ||
console.log('@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json ' + | ||
`files under directory ${cwd}`); | ||
} | ||
exports.runEslintAsync = runEslintAsync; | ||
//# sourceMappingURL=runEslint.js.map |
{ | ||
"name": "@rushstack/eslint-patch", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "Enhance ESLint with better support for large scale monorepos", | ||
@@ -5,0 +5,0 @@ "main": "lib/usage.js", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
239588
1893