Skip to content

Instantly share code, notes, and snippets.

@dzava
Last active August 15, 2018 11:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dzava/f6a938e13e7ab6cd32f3b01c03e2ceb2 to your computer and use it in GitHub Desktop.
Save dzava/f6a938e13e7ab6cd32f3b01c03e2ceb2 to your computer and use it in GitHub Desktop.
pre-commit hook to format stylesheets using csscomb
{
"exclude": [
".git/**",
"node_modules/**",
"bower_components/**"
],
"always-semicolon": true,
"block-indent": " ",
"color-case": "lower",
"color-shorthand": true,
"element-case": "lower",
"eof-newline": true,
"leading-zero": false,
"quotes": "single",
"remove-empty-rulesets": true,
"space-after-colon": " ",
"space-after-combinator": " ",
"space-after-opening-brace": "\n",
"space-after-selector-delimiter": "\n",
"space-before-closing-brace": "\n",
"space-before-colon": "",
"space-before-combinator": " ",
"space-before-opening-brace": " ",
"space-before-selector-delimiter": "",
"strip-spaces": true,
"unitless-zero": true,
"vendor-prefix-align": true,
"sort-order-fallback": "abc",
"sort-order": [
[
"box-sizing",
"display",
"position",
"top",
"right",
"bottom",
"left",
"float",
"clear",
"align-content",
"align-items",
"align-self",
"flex",
"flex-basis",
"flex-direction",
"flex-flow",
"flex-grow",
"flex-shrink",
"flex-wrap",
"justify-content",
"grid",
"grid-area",
"grid-template",
"grid-template-columns",
"grid-template-rows",
"grid-template-areas",
"grid-auto-columns",
"grid-auto-rows",
"grid-auto-flow",
"grid-column",
"grid-column-start",
"grid-column-end",
"grid-row",
"grid-row-start",
"grid-row-end",
"grid-gap",
"grid-row-gap",
"grid-column-gap",
"order",
"columns",
"column-gap",
"column-fill",
"column-rule",
"column-rule-width",
"column-rule-style",
"column-rule-color",
"column-span",
"column-count",
"column-width",
"backface-visibility",
"perspective",
"perspective-origin",
"transform",
"transform-origin",
"transform-style",
"transition",
"transition-delay",
"transition-duration",
"transition-property",
"transition-timing-function",
"visibility",
"opacity",
"z-index",
"margin",
"margin-top",
"margin-right",
"margin-bottom",
"margin-left",
"outline",
"outline-offset",
"outline-width",
"outline-style",
"outline-color",
"border",
"border-top",
"border-right",
"border-bottom",
"border-left",
"border-width",
"border-top-width",
"border-right-width",
"border-bottom-width",
"border-left-width",
"border-style",
"border-top-style",
"border-right-style",
"border-bottom-style",
"border-left-style",
"border-radius",
"border-top-left-radius",
"border-top-right-radius",
"border-bottom-left-radius",
"border-bottom-right-radius",
"border-color",
"border-top-color",
"border-right-color",
"border-bottom-color",
"border-left-color",
"border-image",
"border-image-source",
"border-image-width",
"border-image-outset",
"border-image-repeat",
"border-image-slice",
"box-shadow",
"background",
"background-attachment",
"background-clip",
"background-color",
"background-image",
"background-origin",
"background-position",
"background-repeat",
"background-size",
"cursor",
"padding",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left",
"width",
"min-width",
"max-width",
"height",
"min-height",
"max-height",
"overflow",
"overflow-x",
"overflow-y",
"resize",
"list-style",
"list-style-type",
"list-style-position",
"list-style-image",
"caption-side",
"table-layout",
"border-collapse",
"border-spacing",
"empty-cells",
"animation",
"animation-name",
"animation-duration",
"animation-timing-function",
"animation-delay",
"animation-iteration-count",
"animation-direction",
"animation-fill-mode",
"animation-play-state",
"vertical-align",
"direction",
"tab-size",
"text-align",
"text-align-last",
"text-justify",
"text-indent",
"text-transform",
"text-decoration",
"text-decoration-color",
"text-decoration-line",
"text-decoration-style",
"text-rendering",
"text-shadow",
"text-overflow",
"line-height",
"word-spacing",
"letter-spacing",
"white-space",
"word-break",
"word-wrap",
"color",
"font",
"font-family",
"font-size",
"font-size-adjust",
"font-stretch",
"font-weight",
"font-smoothing",
"osx-font-smoothing",
"font-variant",
"font-style",
"content",
"quotes",
"counter-reset",
"counter-increment",
"page-break-before",
"page-break-after",
"page-break-inside"
],
[
"..."
],
[
"$include"
]
]
}
#!/bin/bash
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
files=$(git diff --cached --name-only --diff-filter=ACMR $against | grep -E "\.([s]?css)|less$" | tr '\n' ' ')
if [[ ! -z $files ]]
then
node node_modules/csscomb/bin/csscomb -tv $files > /dev/null 2>&1;
git add $files;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment