Skip to content

Commit

Permalink
chore: add a script that validates that we don't use prohibited mui m…
Browse files Browse the repository at this point in the history
…aterial-icons import (#6516)

This PR adds a check that should fail the build if we use disallowed
imports from `@mui/icons-material`
  • Loading branch information
FredrikOseberg committed Mar 12, 2024
1 parent 2a57acc commit 9c29461
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_frontend_prs.yml
Expand Up @@ -20,6 +20,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn run lint:material:icons
- run: yarn --frozen-lockfile
- run: yarn run lint:check
- run: yarn run test
Expand Down
7 changes: 7 additions & 0 deletions frontend/check-imports.rc
@@ -0,0 +1,7 @@
if grep -R --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" "from '@mui/icons-material'" src; then
echo "Prohibited import from '@mui/icons-material' found. Use default imports referencing the file instead of the
global package. Example: import Delete from '@mui/icons-material/Delete';'"
exit 1
else
echo "No prohibited imports from '@mui/icons-material' found."
fi
14 changes: 11 additions & 3 deletions frontend/package.json
Expand Up @@ -2,12 +2,15 @@
"name": "unleash-frontend-local",
"version": "0.0.0",
"private": true,
"files": ["index.js", "build"],
"files": [
"index.js",
"build"
],
"engines": {
"node": ">=18"
},
"scripts": {
"build": "vite build",
"build": "yarn run lint:material:icons && vite build",
"dev": "vite",
"start": "vite",
"start:prod": "vite build && vite preview",
Expand All @@ -19,6 +22,7 @@
"test": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" vitest run",
"test:snapshot": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" yarn test -u",
"test:watch": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" vitest watch",
"lint:material:icons": "./check-imports.rc",
"lint": "biome lint src --apply",
"lint:check": "biome check src",
"fmt": "biome format src --write",
Expand Down Expand Up @@ -142,7 +146,11 @@
}
},
"browserslist": {
"production": [">0.2%", "not dead", "not op_mini all"],
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
Expand Down

0 comments on commit 9c29461

Please sign in to comment.