Skip to content

Commit

Permalink
Added an eslint warning to restrict the import of useMediaQuery becau…
Browse files Browse the repository at this point in the history
…se it causes more trouble than it solves
  • Loading branch information
paales committed Aug 24, 2023
1 parent 5f1380e commit 08f1ae1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-cougars-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/eslint-config-pwa': patch
---

Added an eslint warning to restrict the import of useMediaQuery because it causes more trouble than it solves
9 changes: 7 additions & 2 deletions packagesDev/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = {
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
'@typescript-eslint/no-unbound-method': 'off',
'@typescript-eslint/no-restricted-imports': [
'error',
'warn',
{
paths: [
{
Expand All @@ -134,7 +134,12 @@ module.exports = {
'TextField',
'ToggleButtonGroup',
],
message: `Please use \`import { SelectElement, TextFieldElement, etc } from '@graphcommerce/ecommerce-ui'\` for usage in forms. https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/ecommerce-ui/components/FormComponents`,
message: `Please use \`import { SelectElement, TextFieldElement, etc } from '@graphcommerce/ecommerce-ui'\` for usage in forms. https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/ecommerce-ui/components/FormComponents You can add '// eslint-disable-next-line @typescript-eslint/no-restricted-imports' comment if you're sure you want to use it.`,
},
{
name: '@mui/material',
importNames: ['useMediaQuery'],
message: `useMediaQuery can cause large CLS/LCP issues when used to render a specific UI on a breakpoint. See https://mui.com/system/display/#hiding-elements for alternatives. You can add '// eslint-disable-next-line @typescript-eslint/no-restricted-imports' comment if you're sure you want to use it.`,
},
{
name: '@emotion/react',
Expand Down

0 comments on commit 08f1ae1

Please sign in to comment.