reactjsnext.js

React: `'` can be escaped with `'`


I got this error, but only on VErsel not in localstore. Why the difference?

./src/pages/acl/index.tsx
20:58:47.129    25:80  Error: `'` can be escaped with `'`, `‘`, `'`, `’`.  react/no-unescaped-entities

Shall I scan through all the code for special characters? Why client yarn build does not raise error locally?

  return (
    <Grid container spacing={6}>
      <Grid item md={6} xs={12}>
        <Card>
          <CardHeader title='Common' />
          <CardContent>
            <Typography sx={{ mb: 4 }}>No ability is required to view this card</Typography>
            <Typography sx={{ color: 'primary.main' }}>This card is visible to 'user' and 'admin' both</Typography>
          </CardContent>
        </Card>
      </Grid>
      {ability?.can('read', 'analytics') ? (
        <Grid item md={6} xs={12}>
          <Card>
            <CardHeader title='Analytics' />
            <CardContent>
              <Typography sx={{ mb: 4 }}>User with 'Analytics' subject's 'Read' ability can view this card</Typography>
              <Typography sx={{ color: 'error.main' }}>This card is visible to 'admin' only</Typography>
            </CardContent>
          </Card>
        </Grid>
      ) : null}
    </Grid>
  )
}

Solution

  • You're getting an ESLint error.

    You can either:

    1. Disable ESLint in your next.config.js
    module.exports = {
      eslint: {
        // Warning: This allows production builds to successfully complete even if
        // your project has ESLint errors.
        ignoreDuringBuilds: true,
      },
    }
    
    1. Disable rule in .eslintrc.*:
    "rules": {
      "react/no-unescaped-entities": "off"
    }
    
    1. Disable in specific file with comment at top of the file
    1. /* eslint react/no-unescaped-entities */