Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Sanitize input in icon synonyms update script #33989

Merged
merged 1 commit into from Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions docs/scripts/updateIconSynonyms.js
Expand Up @@ -21,8 +21,23 @@ async function run() {
const data = JSON.parse(text.replace(")]}'", ''));

const materialIcons = data.icons.reduce((acc, icon) => {
// remove the icon name strings from the tags
icon.tags = not(icon.tags, icon.name.replace('_'));
icon.tags = not(icon.tags, icon.name.replace('_')) // remove the icon name strings from the tags
.filter((t) => {
// remove invalid tags
if (
t.includes('Remove') ||
t.includes('Duplicate') ||
t.includes('Same as') ||
t.includes('remove others')
) {
console.log(`Skipping invalid tag (${t}) in ${icon.name}`);
return false;
}

return true;
})
.map((t) => t.replace(/'/g, ''));

// Fix names that can't be exported as ES modules.
icon.name = myDestRewriter({ base: icon.name });

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -28,7 +28,7 @@
"docs:typescript": "yarn docs:typescript:formatted --watch",
"docs:typescript:check": "yarn workspace docs typescript",
"docs:typescript:formatted": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/formattedTSDemos",
"docs:mdicons:synonyms": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/updateIconSynonyms",
"docs:mdicons:synonyms": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/updateIconSynonyms && yarn prettier",
"extract-error-codes": "cross-env MUI_EXTRACT_ERROR_CODES=true lerna run --parallel build:modern",
"template:screenshot": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/generateTemplateScreenshots",
"install:codesandbox": "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn install --ignore-engines",
Expand Down