1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

chore: add a script that validates that we don't use prohibited mui material-icons import (#6516)

This PR adds a check that should fail the build if we use disallowed
imports from `@mui/icons-material`
This commit is contained in:
Fredrik Strand Oseberg 2024-03-12 13:29:52 +01:00 committed by GitHub
parent 2a57acca41
commit 9c29461ee5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 3 deletions

View File

@ -20,6 +20,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: yarn run lint:material:icons
- run: yarn --frozen-lockfile - run: yarn --frozen-lockfile
- run: yarn run lint:check - run: yarn run lint:check
- run: yarn run test - run: yarn run test

7
frontend/check-imports.rc Executable file
View File

@ -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

View File

@ -2,12 +2,15 @@
"name": "unleash-frontend-local", "name": "unleash-frontend-local",
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"files": ["index.js", "build"], "files": [
"index.js",
"build"
],
"engines": { "engines": {
"node": ">=18" "node": ">=18"
}, },
"scripts": { "scripts": {
"build": "vite build", "build": "yarn run lint:material:icons && vite build",
"dev": "vite", "dev": "vite",
"start": "vite", "start": "vite",
"start:prod": "vite build && vite preview", "start:prod": "vite build && vite preview",
@ -19,6 +22,7 @@
"test": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" vitest run", "test": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" vitest run",
"test:snapshot": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" yarn test -u", "test:snapshot": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" yarn test -u",
"test:watch": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" vitest watch", "test:watch": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" vitest watch",
"lint:material:icons": "./check-imports.rc",
"lint": "biome lint src --apply", "lint": "biome lint src --apply",
"lint:check": "biome check src", "lint:check": "biome check src",
"fmt": "biome format src --write", "fmt": "biome format src --write",
@ -142,7 +146,11 @@
} }
}, },
"browserslist": { "browserslist": {
"production": [">0.2%", "not dead", "not op_mini all"], "production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [ "development": [
"last 1 chrome version", "last 1 chrome version",
"last 1 firefox version", "last 1 firefox version",