パッケージの詳細

stylelint-config-gds

alphagov57.3kMIT2.0.0

A Stylelint configuration for the UK Government Digital Service.

govuk, gds, stylelint, css

readme

GDS Stylelint Config

This provides a Stylelint configuration for linting SCSS and CSS files as per the conventions of the Government Digital Service (GDS).

It builds upon stylelint-config-standard with conventions GDS have adopted over the years.

Project goals

This project was developed with a number of goals in mind, these should be considered whenever proposals are made to add to or amend the rules.

  1. Lean on community standards over defining our own rules as much as possible - it's not a good use of our time to debate preferences so let's follow common community guidelines unless we have a compelling reason not to do so.
  2. Be consistent with GOV.UK Design System patterns and conventions, most of the initial rules of this project were defined to maintain consistency.
  3. Reflect modern CSS practices over providing compatibility for legacy projects, if it is unfeasible for legacy projects to adopt all these rules they are encouraged to disable problematic rules in their project configuration.
  4. Support CSS and SCSS equally.
  5. Be sufficiently agreeable that these rules can be used, or aspired to, across all GDS programmes.

Usage

These rules are expected to be mostly used for SCSS projects (as these are more common at GDS) however the CSS rules can be used alone.

To add this to your project, install Stylelint and this module:

npm install --save-dev stylelint stylelint-config-gds

You then need to configure Stylelint.

To lint SCSS you can add the following property to your package.json:

"stylelint": {
  "extends": "stylelint-config-gds/scss"
}

To lint CSS add the following:

"stylelint": {
  "extends": "stylelint-config-gds/css"
}

You should then be able to run a lint with node_modules/.bin/stylelint '**/*.(s)?css'.

Development

Make changes to rules that affect both CSS and SCSS in ./css-rules.js, for rules that only apply to SCSS add them to ./scss-rules.js.

You can lint the JS and run tests with npm test

Releasing

GitHub Actions is used to release new versions of this module when a PR is merged into the main branch and there is a new version number.

To create a new release you should amend package.json to have the new version number (based on semvar) and run npm install to update package-lock.json. You should then update the CHANGELOG.md. Finally, open a PR - once this is merged the change will be released.

Licence

MIT License

更新履歴

Changelog

  • We follow Semantic Versioning conventions for numbering releases
  • Don't include changes that are purely internal. The CHANGELOG should be a useful summary for people upgrading their application, not a replication of the commit log.

2.0.0

This release upgrades to Stylelint 16 and removes rules deprecated in Stylelint 15

Breaking change: Requires Node.js v18.12.0+

The minimum Node.js version is now v18.12.0 but note the following changes for Stylelint API users:

  • Supports ES module plugins, custom syntaxes and formatters
  • Updates rules, formatters and utilities to return Promises
  • Deprecates the CommonJS Node.js API
  • Requires Node.js v18.12.0+

Read about breaking changes in the Stylelint Migrating to v16.0.0 guide.

1.1.1

This release includes:

1.1.0

This release includes:

1.0.0

This release upgrades to Stylelint 15 and now includes:

  • Checks for media query syntax, rules and values
  • Checks for number precision inside CSS functions
  • Fixes for duplicate rules with intentionally different units

Read about breaking changes in the Stylelint Migrating to v15.0.0 guide.

Breaking change: Removal of stylistic rules

We have removed all stylistic rules (such as tabs/spaces, indentation, etc) as they're no longer included in Stylelint common configurations as part of their deprecation in Stylelint 15).

As per Stylelint's own documentation, we recommend that projects adopt Prettier for formatting instead.

If this is not possible for your project, you can configure your projects' Stylelint configuration to use the stylelint-stylistic or stylelint-codeguide plugins to restore the deprecated rules instead.

This change was made in pull request #44: Remove deprecated stylistic rules.

Removal of rule enforcing single-colon pseudo elements

We removed the rule selector-pseudo-element-colon-notation preventing double-colon ::before and ::after pseudo elements.

Internet Explorer 8, 9 and 10 require single-colon :before and :after pseudo elements, but supporting these old browsers has not been a requirement for services since June 2018. If you wish to keep support you can configure your Stylelint to re-enable it.

This change was made in pull request #36: Remove selector-pseudo-element-colon-notation.

0.3.0

This release updates all bundled configs to the maximum version supported by Stylelint 14. This work is in preparation for Stylelint 15 deprecating all stylistic rules with a recommendation to use Prettier for formatting.

Updates to bundled configs include new rule changes to maintain compatibility:

  • New rule selector-not-notation (added in stylelint@14.7.0) configured with simple :not() notation from CSS Selectors Level 3, maintaining support for older browsers
  • New rule annotation-no-unknown (added in stylelint@14.10.0) configured to maintain support for Sass flags such as !default and !global

0.2.0

  • Utilise stylelint-config-standard-scss as base rules for SCSS
  • Upgrade to Stylelint 14

0.1.0

  • Initial release