项目作者: rl-king

项目描述 :
Scss stylesheet formatter
高级语言: Haskell
项目地址: git://github.com/rl-king/scss-format.git
创建时间: 2019-10-05T10:57:50Z
项目社区:https://github.com/rl-king/scss-format

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Actions Status

scss-format

A non-configurable scss formatter

  • Sort properties
  • Indent four spaces
  • A single newline inbetween selectors
  • Add newlines around top level comments
  • Add closing ; to last property if missing

Usage

  1. Usage: scss-format [--verbose]
  2. [(-p|--path PATH) [-v|--verify] [-o|--overwrite] | --stdin]
  3. Format scss files and directories, prints the result to stdout by default, use
  4. '-o' to replace the original file.
  5. Available options:
  6. --verbose Log a bit
  7. -p,--path PATH Path or dir to a scss file(s)
  8. -v,--verify Test if file is correctly formatted
  9. -o,--overwrite Replace the orginal file
  10. --stdin Read from stdin
  11. -h,--help Show this help text

Unformatted

  1. // PAGE
  2. .page {
  3. margin: 1rem;
  4. @include breakpoint($small) {
  5. padding: 1rem;
  6. .body-text {padding-left: 1.5rem;}
  7. }
  8. padding: 2rem;
  9. h4 {
  10. margin: .5em 0 .25em;
  11. font-size: 1em
  12. }
  13. }

Formatted

  1. // PAGE
  2. .page {
  3. padding: 1rem;
  4. margin: 1rem;
  5. h4 {
  6. margin: .5em 0 .25em;
  7. font-size: 1em;
  8. }
  9. @include breakpoint($small) {
  10. padding: 2rem;
  11. .body-text {
  12. padding-left: 1.5rem;
  13. }
  14. }
  15. }

Install executable

Asumes haskell-stack is installed

  1. clone repository
  2. cd into directory
  3. stack install
  4. scss-format —path ‘./style.scss’

Install emacs

Install reformatter and add the following to your config:

  1. (reformatter-define scss-format
  2. :program "scss-format"
  3. :args '("--stdin")
  4. :lighter " SCSSF")

Enable format on save by adding (add-hook 'scss-mode-hook 'scss-format-on-save-mode) to your config as well.

VSCode

Install steefh.external-formatters, search in extensions tab. Configure with:

  1. "externalFormatters.languages": {
  2. "scss": {
  3. "command": "scss-format",
  4. "arguments": [
  5. "--stdin"
  6. ]
  7. }
  8. }

Develop

Compile (and run in case of ghcid) on save

Asumes ghcid is installed

ghcid --command 'stack ghci' --test 'dev' --warnings

or

stack build --file-watch --fast