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

Shorthand properties #29

Open
ismay opened this issue Jun 3, 2024 · 2 comments
Open

Shorthand properties #29

ismay opened this issue Jun 3, 2024 · 2 comments

Comments

@ismay
Copy link

ismay commented Jun 3, 2024

Currently (if I'm not mistaken) the plugin does not deal with shorthand properties like margin, padding, etc. In looking at the spec: https://www.w3.org/TR/css-logical-1/#logical-shorthand-keyword, it looks like this is still under discussion, so that's not surprising.

I was wondering what the opinions are on how to best deal with this. Would it be too invasive to do this for example, when autofixing with this plugin:

/* from this */
blockquote {
  margin: 1em 2em 3em 4em;
}

/* to this */
blockquote {
  margin-block-start:  1em;
  margin-inline-start: 2em;
  margin-block-end:    3em;
  margin-inline-end:   4em;
}

I suppose one could also outlaw the usage of shorthand via other rules, but was just curious on the recommended course of action.

@romainmenke
Copy link
Member

I suppose one could also outlaw the usage of shorthand via other rules,

I think that is the best solution :)

@ismay
Copy link
Author

ismay commented Jun 4, 2024

All right, thanks for the quick reply. I agree that as long as the spec is in flux that makes the most sense. For those encountering this as well, https://stylelint.io/user-guide/rules/declaration-property-value-disallowed-list seems most appropriate. This should do the job:

{
  "declaration-property-value-disallowed-list": [
    {
      "border-color": [],
      "border-style": [],
      "border-width": [],
      inset: [],
      margin: [],
      padding: [],
      "scroll-margin": [],
      "scroll-padding": [],
    },
    {
      message: (prop) =>
        `Use longhand form of ${prop} so that it can be autofixed to logical properties and values`,
      severity: "warning",
    },
  ],
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants