From f2b3bf96a22910f69ac92778c6b336d899f37fe1 Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 19 Sep 2024 15:43:35 +0200 Subject: [PATCH] Remove mapping between Sonar and ESLint keys (#4832) --- packages/ruling/.gitignore | 1 - packages/ruling/tests/tools/lits.ts | 14 ++------------ packages/ruling/tests/tools/parseRulesData.ts | 16 ---------------- tools/prepare-ruling.js | 12 ------------ 4 files changed, 2 insertions(+), 41 deletions(-) diff --git a/packages/ruling/.gitignore b/packages/ruling/.gitignore index 4eb9ab93aa7..76190878e30 100644 --- a/packages/ruling/.gitignore +++ b/packages/ruling/.gitignore @@ -1,3 +1,2 @@ actual -eslint-to-sonar-id.json rules.json diff --git a/packages/ruling/tests/tools/lits.ts b/packages/ruling/tests/tools/lits.ts index 88dd00b2584..6bd0bf4ee0b 100644 --- a/packages/ruling/tests/tools/lits.ts +++ b/packages/ruling/tests/tools/lits.ts @@ -49,7 +49,6 @@ export function writeResults( fileSet: JsTsFiles[], actualPath: string, ) { - const eslintIdToSonarId = loadKeysMapping(); const targetProjectPath = path.join(actualPath); try { fs.rmSync(targetProjectPath, { recursive: true }); @@ -57,9 +56,8 @@ export function writeResults( fs.mkdirSync(targetProjectPath, { recursive: true }); const litsResults = transformResults(projectPath, projectName, results, fileSet); for (const [ruleId, { js: jsIssues, ts: tsIssues }] of Object.entries(litsResults.issues)) { - const sonarRuleId = eslintIdToSonarId[ruleId] || ruleId; - writeIssues(targetProjectPath, sonarRuleId, jsIssues); - writeIssues(targetProjectPath, sonarRuleId, tsIssues, false); + writeIssues(targetProjectPath, ruleId, jsIssues); + writeIssues(targetProjectPath, ruleId, tsIssues, false); } } @@ -144,11 +142,3 @@ function writeIssues(projectDir: string, ruleId: string, issues: FileIssues, isJ } } } - -/** - * Loading this through `fs` and not import because the file is absent at compile time - */ -function loadKeysMapping() { - const pathToKeysMapping = path.join(__dirname, '..', 'data', 'eslint-to-sonar-id.json'); - return JSON.parse(fs.readFileSync(pathToKeysMapping, 'utf8')); -} diff --git a/packages/ruling/tests/tools/parseRulesData.ts b/packages/ruling/tests/tools/parseRulesData.ts index bd52113b161..4a95af0e2f8 100644 --- a/packages/ruling/tests/tools/parseRulesData.ts +++ b/packages/ruling/tests/tools/parseRulesData.ts @@ -32,7 +32,6 @@ const SONARLINT_METADATA_PATH = path.join( 'classes', 'sonarlint-metadata.json', ); -const ESLINT_TO_SONAR_ID_PATH = path.join(__dirname, '..', 'data', 'eslint-to-sonar-id.json'); const RULES_PATH = path.join(__dirname, '..', 'data', 'rules.json'); // Loading this through `fs` and not import because the file is absent at compile time @@ -51,23 +50,8 @@ type RuleData = { language: 'js' | 'ts'; }; -extractKeysMapping(); extractRulesData(); -function extractKeysMapping() { - const eslintToSonar: Record = {}; - - for (const rule of rulesMetadata) { - eslintToSonar[rule.eslintKey] = extractSonarId(rule); - } - - function extractSonarId(rule: { ruleKey: string }) { - return rule.ruleKey.split(':')[1]; - } - - fs.writeFileSync(ESLINT_TO_SONAR_ID_PATH, JSON.stringify(eslintToSonar, null, 2)); -} - function extractRulesData() { const rulesData: RuleData[] = []; rulesMetadata.forEach(ruleData => { diff --git a/tools/prepare-ruling.js b/tools/prepare-ruling.js index 9beb5d5c685..88d93842448 100644 --- a/tools/prepare-ruling.js +++ b/tools/prepare-ruling.js @@ -26,15 +26,6 @@ if (fs.existsSync(LINK)) { fs.symlinkSync(TARGET, LINK); function findMissingData() { - const PATH_TO_MAPPING = path.join( - __dirname, - '..', - 'packages', - 'ruling', - 'tests', - 'data', - 'eslint-to-sonar-id.json', - ); const PATH_TO_RULES = path.join( __dirname, '..', @@ -45,9 +36,6 @@ function findMissingData() { 'rules.json', ); const missing = []; - if (!fs.existsSync(PATH_TO_MAPPING)) { - missing.push(PATH_TO_MAPPING); - } if (!fs.existsSync(PATH_TO_RULES)) { missing.push(PATH_TO_RULES); }