{"id":13495203,"url":"https://github.com/matype/stylefmt","last_synced_at":"2025-05-15T16:06:20.950Z","repository":{"id":35879247,"uuid":"40164655","full_name":"matype/stylefmt","owner":"matype","description":"stylefmt is a tool that automatically formats stylesheets.","archived":false,"fork":false,"pushed_at":"2019-12-06T15:16:03.000Z","size":583,"stargazers_count":2092,"open_issues_count":107,"forks_count":88,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-05-13T01:04:17.787Z","etag":null,"topics":["css","formatter","postcss","postcss-plugins","sass","stylelint"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matype.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-04T05:11:41.000Z","updated_at":"2025-05-07T09:11:47.000Z","dependencies_parsed_at":"2022-09-05T08:01:07.527Z","dependency_job_id":null,"html_url":"https://github.com/matype/stylefmt","commit_stats":null,"previous_names":["morishitter/stylefmt","morishitter/cssfmt","matype/stylefmt"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2Fstylefmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2Fstylefmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2Fstylefmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2Fstylefmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matype","download_url":"https://codeload.github.com/matype/stylefmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254374470,"owners_count":22060611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","formatter","postcss","postcss-plugins","sass","stylelint"],"created_at":"2024-07-31T19:01:32.422Z","updated_at":"2025-05-15T16:06:20.904Z","avatar_url":"https://github.com/matype.png","language":"JavaScript","readme":"\u003e Modern CSS Formatter\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/morishitter/stylefmt\"\u003e\n    \u003cimg width=360px src=\"http://morishitter.github.io/stylefmt-logo.svg\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\u003cbig\u003e\n\n\u003c/big\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.org/morishitter/stylefmt\"\u003e\n    \u003cimg src=\"https://travis-ci.org/morishitter/stylefmt.svg\"\n         alt=\"Build Status\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://www.npmjs.com/package/stylefmt\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/stylefmt.svg?style=flat-square\"\n         alt=\"NPM Version\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://www.npmjs.org/package/stylefmt\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/stylefmt.svg?style=flat-square\"\n         alt=\"Downloads\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://david-dm.org/morishitter/stylefmt\"\u003e\n    \u003cimg src=\"https://david-dm.org/morishitter/stylefmt.svg\"\n         alt=\"Dependency Status\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-444444.svg?style=flat-square\"\n         alt=\"License\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://gitter.im/morishitter/stylefmt\"\u003e\n    \u003cimg src=\"https://badges.gitter.im/Join%20Chat.svg\"\n         alt=\"Gitter\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cbr\u003e\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\u003c=50rem);\n\n/* some var() \u0026 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 \u003c= 50rem);\n\n/* some var() \u0026 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    ()      { \u0026:before,\n  \u0026:after {\n                content:\" \";\n    display              : table;  }\n\n  \u0026: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  \u0026:before,\n  \u0026:after {\n    content: \" \";\n    display: table;\n  }\n\n  \u0026: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","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatype%2Fstylefmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatype%2Fstylefmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatype%2Fstylefmt/lists"}