Pragmatic stylelint config enforcing an understandable and consistent code order.
@pragmatics/stylelint-config-order
does not install Stylelint for you.
Install stylelint
and this config as part of your devDependencies
.
yarn add stylelint @pragmatics/stylelint-config-order -D
Add @pragmatics/stylelint-config-order
to your Stylelint configuration file:
extends:
- '@pragmatics/stylelint-config-order'
Use @pragmatics/stylelint-config to apply pragmatic code style to the full extend (
@pragmatics/stylelint-config-order
is already a part of that config).
Learn more about Stylelint.
We recommend configuring your editor to automatically format your code by on save.
You can use Stylelint with a pre-commit tool. This can re-format your files that are marked as “staged” via git add before you commit.
Make sure Stylelint is installed and in your devDependencies before you proceed
npx mrm lint-staged
This will install husky and lint-staged, then add a configuration to the project’s package.json that will automatically format supported files in a pre-commit hook.
We use Jest for testing, use npm test
to run all tests.
By running this stylelint config in tests/system/system.test.js
on an unformatted fixture.scss
we test whether it matches our expected.scss
file.
We are planning to:
- use Jest snapshots for system tests like Stylelint does
- add more common use cases.
Inspired by pragmatism and pracmatics, the aim of this stylelint config is:
- to format
css
/scss
to be understandable, scannable and consistent - to let developers focus on writing code, instead of adhering to a styleguide
Properties with the largest impact (scope and/or importance) are put first. Using concepts from both Idiomatic CSS and ITCSS we setup our config by:
- Ordering on impact
Rules with a larger scope or more effect on the layout and box size have more impact on the UI. Seeing rules with more impact first increases understanding. - Grouping by relationship
Grouping all properties related totypography
andtheming
makes them easier to find.
Related property declarations are grouped in the following order:
- Specials
- Positioning
- Display
- Box
- Box model
- Table
- Typography
- Theming
- Accessibility & Interactions
- SVG presentation
- Transition & animation
- Webstorm - for development
- Github - for versioning and deployment
- Jest - for testing
- Contributor Covenant - for the Code of Conduct
- Creative Commons - to choose the license
Please read CONTRIBUTING.md for details on our the process for submitting issues and pull requests to us. This repository has a code of conduct, we will remove things that do not respect it.
We use SemVer for versioning. For the available versions, see the tags on this repository.
See the list of contributors who participated in this project.
This project is licensed under the ISC License.
The name is inspired by pragmatism and pracmatics.
The following guidelines, methodologies and architectures have been used as inspiration for this config: