Skip to content

Commit

Permalink
Merge pull request #2035 from graphcommerce-org/eslint-warning
Browse files Browse the repository at this point in the history
Added an eslint warning to restrict the import of useMediaQuery because it causes more trouble than it solves
  • Loading branch information
paales authored Nov 8, 2023
2 parents b576ff0 + 08f1ae1 commit a188b02
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 a188b02

Please sign in to comment.