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

Set properties order for Stylelint #22

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 25 additions & 1 deletion packages/stylelint/.stylelintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["stylelint-config-standard"],
"extends": ["stylelint-config-standard", "stylelint-config-concentric-order"],
"rules": {
"at-rule-empty-line-before": [
"always",
Expand Down Expand Up @@ -95,6 +95,30 @@
{
"camelCaseSvgKeywords": true
}
],

"order/order": [
[
"custom-properties",
"declarations",
{
"type": "at-rule",
"name": "supports",
"hasBlock": true
},
{
"type": "at-rule",
"name": "container",
"hasBlock": true
},
{
"type": "at-rule",
"name": "media",
"hasBlock": true
},
"rules"
],
{ "unspecified": "bottom" }
]
}
}
22 changes: 19 additions & 3 deletions packages/stylelint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,26 @@

[Stylelint configuration file](https://stylelint.io/user-guide/configure) used on [w0s.jp](https://w0s.jp/)

## `extends`
## Features

- [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard)
- [stylelint-config-recommended](https://github.com/stylelint/stylelint-config-recommended)
It is based on [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard) with its own rule settings.

- Disallow `!important` within declarations.
- 🙁 `color: #000 !important`
- 🙂 `color: #000`
- Do not use ID selector.
- 😨 `#foo { color: #000 }`
- 🙂 `.foo { color: #000 }`
- Use of CSS physical properties and values is not recommended. Use [logical properties and values](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values).
- 🙁 `margin-top: 1em`
- 🙂 `margin-block-start: 1em`
- 🙁 `text-align: right`
- 🙂 `text-align: end`
- The order of properties within declaration blocks follows [`stylelint-config-concentric-order`](https://github.com/chaucerbao/stylelint-config-concentric-order).
- 😨 `.foo { padding: 1em; margin: 1em }`
- 🙂 `.foo { margin: 1em; padding: 1em }`

See [source code](.stylelintrc) for other details.

## Usage

Expand Down
6 changes: 6 additions & 0 deletions packages/stylelint/__tests__/invalid/oder.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.order {
padding: initial;
margin: initial;

--custom-properties: 'x';
}
34 changes: 34 additions & 0 deletions packages/stylelint/__tests__/valid/order.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.order {
--x: "x";

margin: initial;
padding: initial;

@supports () {
--x: "x";
}

@container container () {
--x: "x";
}

@media print {
--x: "x";
}

&:focus {
--x: "x";
}

&::after {
--x: "x";
}

& > .inner {
--x: "x";

@media print {
--x: "x";
}
}
}
1 change: 1 addition & 0 deletions packages/stylelint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"test-invalid": "stylelint __tests__/invalid/*.css"
},
"dependencies": {
"stylelint-config-concentric-order": "^5.2.0",
"stylelint-config-standard": "^36.0.0"
},
"devDependencies": {
Expand Down