Code Monkey home page Code Monkey logo

stylelint-config-xwp's Introduction

stylelint-config-xwp

NPM version

XWP shareable config for stylelint that extends WordPress CSS Coding Standards.

This project is based on stylelint-config-wordpress.

Table of Contents

Why not just WordPress standards?

We decided to relax or override some of the rules defined in the stylelint-config-wordpress ruleset. We feel that with the following changes, the CSS code is more consistent and better reflects the WordPress coding standards for PHP and Javascript.

Here are key differences to the official WordPress CSS standards:

  • function-url-quotes - use quotes in all functions.
  • string-quotes - use single quotes instead of double quotes.
  • function-parentheses-space-inside - add whitespace after opening and before closing parentheses.
  • color-hex-length - relax hex color values formatting. Shortening the hex values whenever possible is a micro-optimization which can be easily automated nowadays by using build tools.

There are also grey areas not defined in the WordPress CSS Coding Standards, but standardized in the stylelint-config-wordpress, which are altered in stylelint-config-xwp:

  • at-rule-empty-line-before - allow for grouping of the same name blockless at rules (blockless-after-same-name-blockless). Also, ignore not only @else but also @elseif rule.
  • selector-pseudo-element-colon-notation - the single colon notation is included in the stylelint-config-wordpress in order to maintain the Internet Explorer 8 support. Since IE 8 is no longer supported by WordPress as of version 4.8, we opt for using a valid CSS notation, i.e. double colons.

Installation

$ npm install stylelint-config-xwp --save-dev

Usage

If you've installed stylelint-config-xwp locally within your project, just set your stylelint config to:

{
  "extends": "stylelint-config-xwp"
}

If you've globally installed stylelint-config-xwp using the -g flag, then you'll need to use the absolute path to stylelint-config-xwp in your config:

{
  "extends": "/absolute/path/to/stylelint-config-xwp"
}

Presets

In addition to the default preset, there are also specific presets. All presets extend the default one.

SCSS

{
  "extends": [
    "stylelint-config-xwp/scss"
  ]
}

Extending the config

Simply add a "rules" key to your config and add your overrides there.

For example, to change the indentation to four spaces and turn off the number-leading-zero rule:

{
  "extends": "stylelint-config-xwp",
  "rules": {
    "indentation": 4,
    "number-leading-zero": null
  }
}

Changelog

License

stylelint-config-xwp's People

Contributors

delawski avatar mehigh avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.