├── .editorconfig ├── .gitattributes ├── .gitignore ├── demo.gif ├── index.js ├── license.md ├── menus └── csscomb.cson ├── package-lock.json ├── package.json └── readme.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text eol=lf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | .idea 4 | node_modules 5 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1000ch/atom-csscomb/5056c9b7bb1f81582dfa9485307ea0fdd8f46223/demo.gif -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import { CompositeDisposable } from 'atom'; 4 | import * as path from 'path'; 5 | import Comb from 'csscomb'; 6 | import { find } from 'atom-linter'; 7 | 8 | let subscriptions; 9 | let projectConfig; 10 | let presetConfig; 11 | let extendPreset; 12 | 13 | export function activate(state) { 14 | subscriptions = new CompositeDisposable(); 15 | 16 | subscriptions.add(atom.config.observe('atom-csscomb.presetConfig', value => { 17 | presetConfig = Comb.getConfig(value); 18 | })); 19 | 20 | subscriptions.add(atom.config.observe('atom-csscomb.extendPreset', value => { 21 | extendPreset = value; 22 | })); 23 | 24 | atom.commands.add('atom-workspace', 'atom-csscomb:comb', () => { 25 | comb(atom.workspace.getActiveTextEditor()); 26 | }); 27 | } 28 | 29 | export function deactivate() { 30 | subscriptions.dispose(); 31 | } 32 | 33 | function getConfig(filePath) { 34 | const configFile = find(path.dirname(filePath), '.csscomb.json'); 35 | const projectConfig = configFile ? require(configFile) : null; 36 | 37 | if (extendPreset) { 38 | return Object.assign(presetConfig, projectConfig); 39 | } 40 | 41 | return projectConfig || presetConfig; 42 | } 43 | 44 | async function comb(editor) { 45 | if (!editor) { 46 | return; 47 | } 48 | 49 | const position = editor.getCursorBufferPosition(); 50 | const config = getConfig(editor.getPath()); 51 | 52 | try { 53 | const comb = new Comb(config); 54 | const css = await comb.processString(editor.getText(), { 55 | syntax: editor.getGrammar().name.toLowerCase() 56 | }); 57 | 58 | editor.setText(css); 59 | editor.setCursorBufferPosition(position); 60 | } catch (e) { 61 | console.error(e); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Shogo Sensui 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /menus/csscomb.cson: -------------------------------------------------------------------------------- 1 | 'context-menu': 2 | 'atom-text-editor': [{ 3 | label: 'Sort CSS properties' 4 | command: 'atom-csscomb:comb' 5 | }] 6 | 7 | 'menu': [{ 8 | 'label': 'Packages' 9 | 'submenu': [ 10 | 'label': 'CSSComb' 11 | 'submenu': [{ 12 | label: 'Sort CSS properties', 13 | command: 'atom-csscomb:comb' 14 | }] 15 | ] 16 | }] 17 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-csscomb", 3 | "version": "2.0.4", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "atom-linter": { 8 | "version": "10.0.0", 9 | "resolved": "https://registry.npmjs.org/atom-linter/-/atom-linter-10.0.0.tgz", 10 | "integrity": "sha1-0nu3Tl+PCKdKQL6ynuGlDZdUPIk=", 11 | "requires": { 12 | "named-js-regexp": "1.3.2", 13 | "sb-exec": "4.0.0", 14 | "sb-promisify": "2.0.2", 15 | "tmp": "0.0.31" 16 | } 17 | }, 18 | "babel-polyfill": { 19 | "version": "6.23.0", 20 | "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.23.0.tgz", 21 | "integrity": "sha1-g2TKYt+Or7gwSZ9pkXdGbDsDSZ0=", 22 | "requires": { 23 | "babel-runtime": "6.23.0", 24 | "core-js": "2.4.1", 25 | "regenerator-runtime": "0.10.5" 26 | } 27 | }, 28 | "babel-runtime": { 29 | "version": "6.23.0", 30 | "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.23.0.tgz", 31 | "integrity": "sha1-CpSJ8UTecO+zzkMArM2zKeL8VDs=", 32 | "requires": { 33 | "core-js": "2.4.1", 34 | "regenerator-runtime": "0.10.5" 35 | } 36 | }, 37 | "balanced-match": { 38 | "version": "1.0.0", 39 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 40 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" 41 | }, 42 | "brace-expansion": { 43 | "version": "1.1.8", 44 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", 45 | "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", 46 | "requires": { 47 | "balanced-match": "1.0.0", 48 | "concat-map": "0.0.1" 49 | } 50 | }, 51 | "concat-map": { 52 | "version": "0.0.1", 53 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 54 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" 55 | }, 56 | "consistent-env": { 57 | "version": "1.3.1", 58 | "resolved": "https://registry.npmjs.org/consistent-env/-/consistent-env-1.3.1.tgz", 59 | "integrity": "sha1-9oI018afxt2WVviuI0Kc4EmbZfs=", 60 | "requires": { 61 | "lodash.uniq": "4.5.0" 62 | } 63 | }, 64 | "core-js": { 65 | "version": "2.4.1", 66 | "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz", 67 | "integrity": "sha1-TekR5mew6ukSTjQlS1OupvxhjT4=" 68 | }, 69 | "csscomb": { 70 | "version": "4.2.0", 71 | "resolved": "https://registry.npmjs.org/csscomb/-/csscomb-4.2.0.tgz", 72 | "integrity": "sha512-HXXCSVTpHck64PUMIn/2I8auBGmIpx+cD/Hs+KnYH+p9iaMTN0cd38l22qYVp8vEp6v9w+Bbi0SD8iN8fgrINg==", 73 | "requires": { 74 | "babel-polyfill": "6.23.0", 75 | "glob": "7.1.2", 76 | "gonzales-pe": "3.4.7", 77 | "minimatch": "3.0.2", 78 | "minimist": "1.1.3", 79 | "vow": "0.4.4", 80 | "vow-fs": "0.3.6" 81 | }, 82 | "dependencies": { 83 | "minimist": { 84 | "version": "1.1.3", 85 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.1.3.tgz", 86 | "integrity": "sha1-O+39kaktOQFvz6ocaB6Pqhoe/ag=" 87 | } 88 | } 89 | }, 90 | "fs.realpath": { 91 | "version": "1.0.0", 92 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 93 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" 94 | }, 95 | "glob": { 96 | "version": "7.1.2", 97 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", 98 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", 99 | "requires": { 100 | "fs.realpath": "1.0.0", 101 | "inflight": "1.0.6", 102 | "inherits": "2.0.3", 103 | "minimatch": "3.0.4", 104 | "once": "1.4.0", 105 | "path-is-absolute": "1.0.1" 106 | }, 107 | "dependencies": { 108 | "minimatch": { 109 | "version": "3.0.4", 110 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 111 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 112 | "requires": { 113 | "brace-expansion": "1.1.8" 114 | } 115 | } 116 | } 117 | }, 118 | "gonzales-pe": { 119 | "version": "3.4.7", 120 | "resolved": "https://registry.npmjs.org/gonzales-pe/-/gonzales-pe-3.4.7.tgz", 121 | "integrity": "sha1-F8e+Z61sr/Ynej44esc26YPSgOw=", 122 | "requires": { 123 | "minimist": "1.1.3" 124 | }, 125 | "dependencies": { 126 | "minimist": { 127 | "version": "1.1.3", 128 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.1.3.tgz", 129 | "integrity": "sha1-O+39kaktOQFvz6ocaB6Pqhoe/ag=" 130 | } 131 | } 132 | }, 133 | "inflight": { 134 | "version": "1.0.6", 135 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 136 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 137 | "requires": { 138 | "once": "1.4.0", 139 | "wrappy": "1.0.2" 140 | } 141 | }, 142 | "inherits": { 143 | "version": "2.0.3", 144 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 145 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 146 | }, 147 | "lodash.uniq": { 148 | "version": "4.5.0", 149 | "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", 150 | "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=" 151 | }, 152 | "minimatch": { 153 | "version": "3.0.2", 154 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.2.tgz", 155 | "integrity": "sha1-DzmKcwDqRB6cNIyD2Yq4ydv5xAo=", 156 | "requires": { 157 | "brace-expansion": "1.1.8" 158 | } 159 | }, 160 | "named-js-regexp": { 161 | "version": "1.3.2", 162 | "resolved": "https://registry.npmjs.org/named-js-regexp/-/named-js-regexp-1.3.2.tgz", 163 | "integrity": "sha1-lnd5uSPCOB4kOpfLijlBMUHe8kE=" 164 | }, 165 | "once": { 166 | "version": "1.4.0", 167 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 168 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 169 | "requires": { 170 | "wrappy": "1.0.2" 171 | } 172 | }, 173 | "os-tmpdir": { 174 | "version": "1.0.2", 175 | "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", 176 | "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" 177 | }, 178 | "path-is-absolute": { 179 | "version": "1.0.1", 180 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 181 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" 182 | }, 183 | "regenerator-runtime": { 184 | "version": "0.10.5", 185 | "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz", 186 | "integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=" 187 | }, 188 | "sb-exec": { 189 | "version": "4.0.0", 190 | "resolved": "https://registry.npmjs.org/sb-exec/-/sb-exec-4.0.0.tgz", 191 | "integrity": "sha1-RnR/DfFiYmwW6/D+pCJFrRqoWco=", 192 | "requires": { 193 | "consistent-env": "1.3.1", 194 | "lodash.uniq": "4.5.0", 195 | "sb-npm-path": "2.0.0" 196 | } 197 | }, 198 | "sb-memoize": { 199 | "version": "1.0.2", 200 | "resolved": "https://registry.npmjs.org/sb-memoize/-/sb-memoize-1.0.2.tgz", 201 | "integrity": "sha1-EoN1xi3bnMT/qQXQxaWXwZuurY4=" 202 | }, 203 | "sb-npm-path": { 204 | "version": "2.0.0", 205 | "resolved": "https://registry.npmjs.org/sb-npm-path/-/sb-npm-path-2.0.0.tgz", 206 | "integrity": "sha1-D2zCzzcd68p9k27Xa31MPMHrPVg=", 207 | "requires": { 208 | "sb-memoize": "1.0.2", 209 | "sb-promisify": "2.0.2" 210 | } 211 | }, 212 | "sb-promisify": { 213 | "version": "2.0.2", 214 | "resolved": "https://registry.npmjs.org/sb-promisify/-/sb-promisify-2.0.2.tgz", 215 | "integrity": "sha1-QnelR1RIiqlnXYhuNU24lMm9yYE=" 216 | }, 217 | "tmp": { 218 | "version": "0.0.31", 219 | "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", 220 | "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", 221 | "requires": { 222 | "os-tmpdir": "1.0.2" 223 | } 224 | }, 225 | "uuid": { 226 | "version": "2.0.3", 227 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", 228 | "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" 229 | }, 230 | "vow": { 231 | "version": "0.4.4", 232 | "resolved": "https://registry.npmjs.org/vow/-/vow-0.4.4.tgz", 233 | "integrity": "sha1-yf5GCRKdf1qmIVCOvmS1HJW8e5g=" 234 | }, 235 | "vow-fs": { 236 | "version": "0.3.6", 237 | "resolved": "https://registry.npmjs.org/vow-fs/-/vow-fs-0.3.6.tgz", 238 | "integrity": "sha1-LUxZviLivyYY3fWXq0uqkjvnIA0=", 239 | "requires": { 240 | "glob": "7.1.2", 241 | "uuid": "2.0.3", 242 | "vow": "0.4.16", 243 | "vow-queue": "0.4.2" 244 | }, 245 | "dependencies": { 246 | "vow": { 247 | "version": "0.4.16", 248 | "resolved": "https://registry.npmjs.org/vow/-/vow-0.4.16.tgz", 249 | "integrity": "sha1-u51U2TjV+AUg1linQOeoleMP7us=" 250 | } 251 | } 252 | }, 253 | "vow-queue": { 254 | "version": "0.4.2", 255 | "resolved": "https://registry.npmjs.org/vow-queue/-/vow-queue-0.4.2.tgz", 256 | "integrity": "sha1-5/4XFg4Vx8QYTRtmapvGThjjAYQ=", 257 | "requires": { 258 | "vow": "0.4.4" 259 | } 260 | }, 261 | "wrappy": { 262 | "version": "1.0.2", 263 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 264 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" 265 | } 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-csscomb", 3 | "version": "3.0.0", 4 | "private": true, 5 | "description": "Sort CSS properties with CSSComb.", 6 | "activationCommands": { 7 | "atom-text-editor:not([mini])": [ 8 | "atom-csscomb:comb" 9 | ] 10 | }, 11 | "repository": "https://github.com/1000ch/atom-csscomb", 12 | "license": "MIT", 13 | "author": { 14 | "name": "1000ch", 15 | "email": "shogo.sensui@gmail.com", 16 | "url": "https://github.com/1000ch" 17 | }, 18 | "engines": { 19 | "atom": "*", 20 | "node": "*" 21 | }, 22 | "dependencies": { 23 | "atom-linter": "^10.0.0", 24 | "csscomb": "^4.2.0" 25 | }, 26 | "configSchema": { 27 | "presetConfig": { 28 | "title": "Configure with preset", 29 | "description": "Select preset config bundled with CSSComb.", 30 | "type": "string", 31 | "default": "csscomb", 32 | "enum": [ 33 | "csscomb", 34 | "zen", 35 | "yandex" 36 | ] 37 | }, 38 | "extendPreset": { 39 | "title": "Extend preset", 40 | "description": "Extend selected preset config with project config if exists.", 41 | "type": "boolean", 42 | "default": false 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # [atom-csscomb](https://atom.io/packages/atom-csscomb) [![Dependency Status](https://david-dm.org/1000ch/atom-csscomb.svg)](https://david-dm.org/1000ch/atom-csscomb) 2 | 3 | Sort CSS properties with [CSSComb](https://github.com/csscomb/csscomb.js). 4 | 5 | ![demo](https://raw.githubusercontent.com/1000ch/atom-csscomb/master/demo.gif) 6 | 7 | ## Installation 8 | 9 | ```bash 10 | $ apm install atom-csscomb 11 | ``` 12 | 13 | ## Usage 14 | 15 | - Packages > CSSComb > Sort properties 16 | - Context Menu > Sort properties 17 | - Command Palette ( + shift + P) > **CSSComb: Comb** 18 | 19 | ## Configuration 20 | 21 | To configure with [`.csscomb.json`](https://github.com/csscomb/csscomb.js/blob/master/doc/options.md), just put it to workspace. 22 | 23 | ### Preset config 24 | 25 | Configure with presets (`csscomb`, `zen`, `yandex`). 26 | 27 | ### Extend preset 28 | 29 | Extend selected preset config with project config if exists. 30 | 31 | ## License 32 | 33 | [MIT](https://1000ch.mit-license.org) © [Shogo Sensui](https://github.com/1000ch) 34 | --------------------------------------------------------------------------------