-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to count rules for README (#4409)
- Loading branch information
1 parent
0d68574
commit 13a5cf2
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const url = require('node:url'); | ||
const path = require('node:path'); | ||
const fs = require('node:fs'); | ||
|
||
const pathToJsTsRules = path.join( | ||
__dirname, | ||
'..', | ||
'sonar-plugin', | ||
'javascript-checks', | ||
'src', | ||
'main', | ||
'resources', | ||
'org', | ||
'sonar', | ||
'l10n', | ||
'javascript', | ||
'rules', | ||
'javascript', | ||
); | ||
const pathToCssRules = path.join( | ||
__dirname, | ||
'..', | ||
'sonar-plugin', | ||
'css', | ||
'src', | ||
'main', | ||
'resources', | ||
'org', | ||
'sonar', | ||
'l10n', | ||
'css', | ||
'rules', | ||
'css', | ||
); | ||
|
||
const jsTsRules = getJsonFiles(pathToJsTsRules); | ||
|
||
const jsRules = jsTsRules.filter(rule => rule.compatibleLanguages.includes('JAVASCRIPT')); | ||
const tsRules = jsTsRules.filter(rule => rule.compatibleLanguages.includes('TYPESCRIPT')); | ||
|
||
const cssRules = getJsonFiles(pathToCssRules); | ||
|
||
console.log(`JS/TS rules: ${jsTsRules.length}`); | ||
console.log(`JS rules: ${jsRules.length}`); | ||
console.log(`TS rules: ${tsRules.length}`); | ||
console.log(`CSS rules: ${cssRules.length}`); | ||
|
||
function getJsonFiles(pathToRules) { | ||
const filenames = fs.readdirSync(pathToRules); | ||
return filenames | ||
.filter(filename => filename.endsWith('.json') && filename.length <= 'S1234.json'.length) | ||
.map(file => require(path.join(pathToRules, file))); | ||
} |