"readme": "> Modern CSS Formatter\n\n<div align=\"center\">\n <a href=\"https://github.com/morishitter/stylefmt\">\n <img width=360px src=\"http://morishitter.github.io/stylefmt-logo.svg\">\n </a>\n</div>\n<br>\n\n<p align=\"center\"><big>\n\n</big></p>\n\n<p align=\"center\">\n <a href=\"https://travis-ci.org/morishitter/stylefmt\">\n <img src=\"https://travis-ci.org/morishitter/stylefmt.svg\"\n alt=\"Build Status\">\n </a>\n\n <a href=\"https://www.npmjs.com/package/stylefmt\">\n <img src=\"https://img.shields.io/npm/v/stylefmt.svg?style=flat-square\"\n alt=\"NPM Version\">\n </a>\n\n <a href=\"https://www.npmjs.org/package/stylefmt\">\n <img src=\"https://img.shields.io/npm/dm/stylefmt.svg?style=flat-square\"\n alt=\"Downloads\">\n </a>\n\n <a href=\"https://david-dm.org/morishitter/stylefmt\">\n <img src=\"https://david-dm.org/morishitter/stylefmt.svg\"\n alt=\"Dependency Status\">\n </a>\n\n <a href=\"https://opensource.org/licenses/MIT\">\n <img src=\"https://img.shields.io/badge/license-MIT-444444.svg?style=flat-square\"\n alt=\"License\">\n </a>\n\n <a href=\"https://gitter.im/morishitter/stylefmt\">\n <img src=\"https://badges.gitter.im/Join%20Chat.svg\"\n alt=\"Gitter\">\n </a>\n</p>\n<br>\n\nstylefmt is a tool that automatically formats CSS according to [stylelint](http://stylelint.io/) rules.\n\nstylefmt'd code is:\n\n- easier to **write** : never worry about minor formatting concerns while hacking away.\n- easier to **read** : when all code looks the same you need not mentally convert others' formatting style into something you can understand.\n- easier to **maintain** : mechanical changes to the source don't cause unrelated changes to the file's formatting; diffs show only the real changes.\n- **uncontroversial** : never have a debate about spacing or brace position ever again!\n\n## NOTICE: Consider other tools before adopting stylefmt\n\nIf you are using stylefmt with stylelint configuration to format according to its rules, you can now use stylelint's [--fix](https://github.com/stylelint/stylelint/releases/tag/7.11.0) option (from v7.11.0) to autofix.\n\nAnother on the other hand, [prettier](https://github.com/prettier/prettier) supports to format not only JavaScript but also CSS, SCSS and Less code.\n\n## Features\n\n- **Supports the latest CSS syntax:** Including custom properties, range context for media features, `calc()` and nesting.\n- **Understands CSS-like syntaxes:** stylefmt is powered by [PostCSS](https://github.com/postcss/postcss), so it understands any syntax that PostCSS can parse, including SCSS.\n- **Works well with stylelint:** [stylelint](http://stylelint.io/) is a mighty, modern CSS linter. stylefmt can understand the formatting rules specified in your stylelint configuration file (`.stylelintrc`).\n\n## Examples\n\n### Future CSS syntax (cssnext)\n\nInput (input.css):\n\n```css\n/* custom properties */\n:root{--fontSize: 1rem;\n --mainColor :#12345678;\n--highlightColor:hwb(190, 35%, 20%);\n}\n\n/* custom media queries */\n@custom-media\n\n--viewport-medium(width<=50rem);\n\n/* some var() & calc() */\nbody{color:var(--mainColor);\n font-size:var(--fontSize);\n line-height: calc(var(--fontSize) * 1.5);\npadding: calc((var(--fontSize) / 2) + 1px)}\n\n/* custom media query usage */\n@media (--viewport-medium) {\nbody {font-size: calc(var(--fontSize) * 1.2); }\n}\n\n/* custom selectors */\n@custom-selector :--heading h1,h2,h3, h4,h5,h6;\n:--heading { margin-top:0 }\n\n/* colors stuff */\na{\ncolor:var(--highlightColor);\n transition:color 1s;\n}\na:hover{color :gray(255,50%) }\na:active{color : rebeccapurple }\na:any-link { color:color(var(--highlightColor) blackness(+20%)) }\n\n/* font stuff */\nh2 {font-variant-caps:small-caps;\n}table{font-variant-numeric: lining-nums;\n}\n\n/* filters */\n.blur{filter:blur(4px)}.sepia{\nfilter: sepia(.8);}\n\n```\n\nYield:\n\n```css\n/* custom properties */\n:root {\n --fontSize: 1rem;\n --mainColor: #12345678;\n --highlightColor: hwb(190, 35%, 20%);\n}\n\n/* custom media queries */\n@custom-media --viewport-medium (width <= 50rem);\n\n/* some var() & calc() */\nbody {\n color: var(--mainColor);\n font-size: var(--fontSize);\n line-height: calc(var(--fontSize) * 1.5);\n padding: calc((var(--fontSize) / 2) + 1px);\n}\n\n/* custom media query usage */\n@media (--viewport-medium) {\n body {\n font-size: calc(var(--fontSize) * 1.2);\n }\n}\n\n/* custom selectors */\n@custom-selector :--heading h1, h2, h3, h4, h5, h6;\n\n:--heading {\n margin-top: 0;\n}\n\n/* colors stuff */\na {\n color: var(--highlightColor);\n transition: color 1s;\n}\n\na:hover {\n color: gray(255, 50%);\n}\n\na:active {\n color: rebeccapurple;\n}\n\na:any-link {\n color: color(var(--highlightColor) blackness(+20%));\n}\n\n/* font stuff */\nh2 {\n font-variant-caps: small-caps;\n}\n\ntable {\n font-variant-numeric: lining-nums;\n}\n\n/* filters */\n.blur {\n filter: blur(4px);\n}\n\n.sepia {\n filter: sepia(.8);\n}\n\n```\n\n### SCSS syntax\n\nInput (input.scss):\n\n```scss\n// mixin for clearfix\n\n\n @mixin clearfix () { &:before,\n &:after {\n content:\" \";\n display : table; }\n\n &:after {clear: both;}\n }.class\n{\n padding:10px;@include clearfix();}\n .base { color: red; }\n\n// placeholder\n%base\n{\n\n\npadding: 12px\n}\n\n.foo{\n@extend .base;}\n\n.bar\n { @extend %base;\n\n}\n```\n\nYield:\n\n```scss\n// mixin for clearfix\n@mixin clearfix () {\n &:before,\n &:after {\n content: \" \";\n display: table;\n }\n\n &:after {\n clear: both;\n }\n}\n\n.class {\n padding: 10px;\n @include clearfix();\n}\n\n.base {\n color: red;\n}\n\n// placeholder\n%base {\n padding: 12px;\n}\n\n.foo {\n @extend .base;\n}\n\n.bar {\n @extend %base;\n}\n```\n\n## Installation\n\n```shell\n$ npm install stylefmt\n```\n\n## Usage\n\n### in Command Line\n\nCLI Help:\n\n```\n$ stylefmt --help\n```\n\n```\nUsage: stylefmt [options] input-name [output-name]\n\nOptions:\n\n -b, --config-basedir Path to the directory that relative paths defining \"extends\"\n -c, --config Path to a specific configuration file (JSON, YAML, or CommonJS)\n -d, --diff Output diff against original file\n -r, --recursive Format list of space seperated files(globs) in place\n -v, --version Output the version number\n -h, --help Output usage information\n -i, --ignore-path Path to a file containing patterns that describe files to ignore.\n --stdin-filename A filename to assign stdin input.\n```\n\nstylefmt can also read a file from stdin if there are no input-file as argument in CLI.\n\n```\n$ cat input.css | stylefmt --stdin-filename input.css\n```\n\n### in Node.js\n\n```js\nvar fs = require('fs');\nvar postcss = require('postcss');\nvar scss = require('postcss-scss'); // when you use scss syntax\nvar stylefmt = require('stylefmt');\n\nvar css = fs.readFileSync('input.css', 'utf-8');\n\npostcss([\n stylefmt\n]).process(css, {\n from: 'input.css',\n syntax: scss\n })\n .then(function (result) {\n result.css; // formatted code\n });\n```\n\n### in Task Runners\n\nWe can use stylefmt in [Grunt](https://github.com/morishitter/grunt-stylefmt), [gulp](https://github.com/morishitter/gulp-stylefmt), and [Fly](https://github.com/morishitter/fly-cssfmt).\n\n\n## stylelint rules that stylefmt can handle\n\nstylefmt :heart: stylelint\n\nstylefmt supports the following stylelint rules:\n\n- [at-rule-empty-line-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/at-rule-empty-line-before) (\"always\"|\"never\" and except \"blockless-group\" only)\n- [at-rule-semicolon-newline-after](https://github.com/stylelint/stylelint/tree/master/lib/rules/at-rule-semicolon-newline-after)\n- [block-closing-brace-newline-after](https://github.com/stylelint/stylelint/tree/master/lib/rules/block-closing-brace-newline-after)\n- [block-closing-brace-newline-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/block-closing-brace-newline-before)\n- [block-opening-brace-newline-after](https://github.com/stylelint/stylelint/tree/master/lib/rules/block-opening-brace-newline-after)\n- [block-opening-brace-newline-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/block-opening-brace-newline-before)\n- [block-opening-brace-space-after](https://github.com/stylelint/stylelint/tree/master/lib/rules/block-opening-brace-space-after)\n- [block-opening-brace-space-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/block-opening-brace-space-before)\n- [color-hex-case](https://github.com/stylelint/stylelint/tree/master/lib/rules/color-hex-case)\n- [color-hex-length](https://github.com/stylelint/stylelint/tree/master/lib/rules/color-hex-length)\n- [declaration-block-properties-order](https://github.com/stylelint/stylelint/tree/master/lib/rules/declaration-block-properties-order)\n- [declaration-colon-space-after](https://github.com/stylelint/stylelint/tree/master/lib/rules/declaration-colon-space-after)\n- [declaration-colon-space-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/declaration-colon-space-before)\n- [declaration-empty-line-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/declaration-empty-line-before)\n- [indentation](https://github.com/stylelint/stylelint/tree/master/lib/rules/indentation)\n- [length-zero-no-unit](https://github.com/stylelint/stylelint/tree/master/lib/rules/length-zero-no-unit)\n- [number-leading-zero](https://github.com/stylelint/stylelint/tree/master/lib/rules/number-leading-zero)\n- [number-no-trailing-zeros](https://github.com/stylelint/stylelint/tree/master/lib/rules/number-no-trailing-zeros)\n- [selector-combinator-space-after](https://github.com/stylelint/stylelint/tree/master/lib/rules/selector-combinator-space-after)\n- [selector-combinator-space-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/selector-combinator-space-before)\n- [selector-list-comma-newline-after](https://github.com/stylelint/stylelint/tree/master/lib/rules/selector-list-comma-newline-after)\n- [selector-list-comma-newline-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/selector-list-comma-newline-before)\n- [selector-list-comma-space-after](https://github.com/stylelint/stylelint/tree/master/lib/rules/selector-list-comma-space-after)\n- [selector-list-comma-space-before](https://github.com/stylelint/stylelint/tree/master/lib/rules/selector-list-comma-space-before)\n- [shorthand-property-no-redundant-values](https://github.com/stylelint/stylelint/tree/master/lib/rules/shorthand-property-no-redundant-values)\n- [string-quotes](https://github.com/stylelint/stylelint/tree/master/lib/rules/string-quotes)\n\nand we can also format from the other stylelint's configration files or packages (e.g. [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard), [stylelint-config-suitcss](https://github.com/suitcss/stylelint-config-suitcss) and so on) using `extends` property.\n\n## Default formatting rules (without stylelint config file)\n\n### Basic\n\n- 2 spaces indentation\n- require 1 space between a simple selector and combinator\n- require 1 space between selectors and `{`\n- require new line after `{`\n- disallow any spaces between property and `:`\n- require 1 space between `:` and values\n- require new line after declarations\n- require `;` in last declaration\n- require 1 space between values and `!important`\n- disallow any spaces between `!` and `important`\n- leave 1 blank line between rules\n- leave 1 blank line between rules in atrules\n- disallow any blank lines between `@import`\n\n### for nested selector syntax\n\n- leave 1 line between declarations and nested rules\n\n### SCSS\n\n- require 1 space between `@mixin` and mixin name\n- require 1 space between mixin name and `(`\n- require 1 space between `@extend` and base rules\n- require 1 space between `@include` and mixin name\n- disallow any spaces between `$variable` and `:`\n- require 1 space between `:` and name of variable\n\n## Option projects\n\n### Editor plugins\n\n- [sublime-stylefmt](https://github.com/dmnsgn/sublime-stylefmt) by [@dmnsgn](https://github.com/dmnsgn)\n- [atom-stylefmt](https://github.com/1000ch/atom-stylefmt) by [@1000ch](https://github.com/1000ch)\n- [vim-stylefmt](https://github.com/kewah/vim-stylefmt) by [@kewah](https://github.com/kewah)\n- [stylefmt.el](https://github.com/KeenS/stylefmt.el) by [@KeenS](https://github.com/KeenS)\n- [vscode-stylefmt](https://github.com/mrmlnc/vscode-stylefmt) by [@mrmlnc](https://github.com/mrmlnc)\n\n### for Task Runners\n\n- [gulp-stylefmt](https://github.com/morishitter/gulp-stylefmt)\n- [grunt-stylefmt](https://github.com/morishitter/grunt-stylefmt)\n- [fly-stylefmt](https://github.com/morishitter/fly-cssfmt)\n- [laravel-elixir-stylefmt](https://github.com/appleboy/laravel-elixir-cssfmt) by [@appleboy](https://github.com/appleboy)\n- [stylefmt-loader](https://github.com/tomasAlabes/stylefmt-loader) by [@tomasAlabes](https://github.com/tomasAlabes)\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Masaaki Morishita\n",
0 commit comments