Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styles that need shorthands are not being errored when they are inside of selectors #78

Closed
khmakoto opened this issue Mar 17, 2022 · 2 comments
Labels
🐞 bug Something isn't working

Comments

@khmakoto
Copy link
Member

Styles like padding and margin which need the use of a shorthand to be expanded into their left, right, top, bottom equivalents error when you try to use them in a makeStyles call. However, if they are used inside of a selector that's not part of CSS.Pseudos then they do not error out and the styles are ultimately ignored.

We should fix the types so that these styles always error out to indicate the user that they need to change them to shorthands.

Example:

const useStyles = makeStyles({
  base: {
    ':hover': {
      // will error out
      padding: "1px"
    },

    [`& .${testClassName}`]': {
      // will not error out
      padding: "1px"
    }
  }
});
@khmakoto khmakoto added the 🐞 bug Something isn't working label Mar 17, 2022
@miroslavstastny
Copy link
Member

Unfortunately we have not found a way how to avoid this in Typescript.
Currently Griffel already warns on the padding in development mode and never adds it to DOM (see #47).
We plan to add Lint rules to improve the build time check in #76.

@layershifter
Copy link
Member

We cannot do anything against it unfortunately. But the ESLint plugin with a matching rule was implemented in #99, you can find an example how it could be consumed in docs or in the real PR (microsoft/fluentui#22961).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants