@pragmatics/stylelint-config

Opinionated stylelint config providing pragmatic code style

Usage no npm install needed!

<script type="module">
  import pragmaticsStylelintConfig from 'https://cdn.skypack.dev/@pragmatics/stylelint-config';
</script>

README

Stylelint Config

NPM version Maintenance Package size
Release Status Dependencies Issues open Code coverage Quality Gate Status

Stylelint config enforcing an understandable and consistent code style.

Summary

Getting started

Installation

Install prettier, stylelint and this config as part of your devDependencies.

yarn add prettier stylelint @pragmatics/stylelint-config -D

Usage

Stylelint config

Add @pragmatics/stylelint-config to your Stylelint configuration file:

extends:
  - '@pragmatics/stylelint-config'

Extend with Prettier config

In order to play nicely with Prettier we disable all formatting related Stylelint rules with stylelint-config-prettier.

Add a prettier configuration file with your formatting preferences, for example:

# .prettier.yml
singleQuote: true
tabWidth: 2
printWidth: 100

Automation

We recommend configuring your editor to automatically format your code by on save.

You can use Prettier and 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 Prettier and Stylelint are 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.

Customization

Being opinionated it's best to limit the amount of rules you use yourself.

The following rule extensions are already part of this module:

extends:
  - stylelint-config-standard
  - '@pragmatics/stylelint-config-order'
  - stylelint-prettier/recommended

A number of rules are defined to make Stylelint play nicely with Scss and Prettier. We recommend you add rules which do not manipulate the order or code format to get maximum benefit of this config.

Use @pragmatics/stylelint-config-order if you only want the ordering rules.

Learn more about Stylelint.

Testing

We use Jest for testing, run npm test to run all tests.

System test

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:

Vision

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
  • to simplify stylelint configuration
  • to avoid changing specificity

Built With

Contributing

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.

Versioning

We use SemVer for versioning. For the available versions, see the tags on this repository.

Authors

See the list of contributors who participated in this project.

License

This project is licensed under the ISC License.

Acknowledgements

The name was inspired by pragmatism and pracmatics.

The following guidelines, methodologies and architectures have been used as inspiration for this config: