-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9673db9
Showing
11 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// A launch configuration that launches the extension inside a new window | ||
{ | ||
"version": "0.1.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ], | ||
"stopOnEntry": false | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.vscode/** | ||
typings/** | ||
test/** | ||
.editorconfig | ||
.gitignore | ||
.travis.yml | ||
jsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# VS Code PostCSS Sorting | ||
|
||
> VS Code plugin to sort CSS rules content with specified order. Powered by [postcss-sorting](https://github.com/hudochenkov/postcss-sorting). | ||
![2016-04-10_02-46-24](https://cloud.githubusercontent.com/assets/7034281/14407132/77dd07c4-fec6-11e5-8361-a47af434459c.gif) | ||
|
||
## Install | ||
|
||
To install, press `F1` and select `Extensions: Install Extensions` and then search for and select `postcss-sorting`. | ||
|
||
## Usage | ||
|
||
Press `F1` and run the command named `PostCSS Sorting`. | ||
|
||
## Keyboard shortcuts | ||
|
||
For changes keyboard shortcuts, create a new rule in `File -> Preferences -> Keyboard Shortcuts`: | ||
|
||
```json | ||
{ | ||
"key": "ctrl+shift+c", | ||
"command": "PostCSSSorting.processEditor" | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
You can override the default and user settings for individual projects. Just add an `PostCSSSorting` object to the `settings.json`file. | ||
|
||
For example: | ||
|
||
```json | ||
{ | ||
"PostCSSSorting": { | ||
"sort-order": ["padding", "margin"], | ||
"sort-on-save": true | ||
} | ||
} | ||
``` | ||
|
||
See the [postcss-sorting documentation](https://github.com/hudochenkov/postcss-sorting#options) for all rules and predefined configs. | ||
|
||
## Changelog | ||
|
||
See the [Releases section of our GitHub project](https://github.com/mrmlnc/vscode-attrs-sorter/releases) for changelogs for each release version. | ||
|
||
## License | ||
|
||
This software is released under the terms of the MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
var vscode = require('vscode'); | ||
var postcss = require('postcss'); | ||
var postcssSorter = require('postcss-sorting'); | ||
|
||
function activate(context) { | ||
var processEditor = vscode.commands.registerTextEditorCommand('PostCSSSorting.processEditor', function(textEditor) { | ||
var options = Object.assign({ | ||
'sort-order': 'default', | ||
'empty-lines-between-children-rules': 0, | ||
'sort-on-save': false | ||
}, vscode.workspace.getConfiguration('PostCSSSorting')); | ||
|
||
var document = textEditor.document; | ||
var documentText = document.getText(); | ||
var lastLine = document.lineAt(document.lineCount - 1); | ||
var selectAll = new vscode.Range(0, 0, lastLine.lineNumber, lastLine.range.end.character); | ||
|
||
postcss([postcssSorter(options)]) | ||
.process(documentText) | ||
.then(function(result) { | ||
textEditor.edit(function(editBuilder) { | ||
editBuilder.replace(selectAll, result.css); | ||
}); | ||
}); | ||
}); | ||
|
||
context.subscriptions.push(processEditor); | ||
} | ||
|
||
exports.activate = activate; | ||
|
||
// this method is called when your extension is deactivated | ||
function deactivate() { | ||
} | ||
exports.deactivate = deactivate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "ES5", | ||
"noLib": true | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"name": "vscode-postcss-sorting", | ||
"displayName": "PostCSS Sorting", | ||
"description": "VS Code plugin to sort CSS rules content with specified order.", | ||
"version": "1.0.0", | ||
"publisher": "mrmlnc", | ||
"engines": { | ||
"vscode": "^0.10.10" | ||
}, | ||
"icon": "icon.png", | ||
"homepage": "https://github.com/mrmlnc/vscode-postcss-sorting", | ||
"categories": [ | ||
"Other" | ||
], | ||
"activationEvents": [ | ||
"onCommand:PostCSSSorting.processEditor" | ||
], | ||
"main": "./extension", | ||
"contributes": { | ||
"commands": [{ | ||
"command": "PostCSSSorting.processEditor", | ||
"title": "PostCSS Sorting" | ||
}], | ||
"configuration": { | ||
"type": "object", | ||
"title": "PostCSSSorting configuration", | ||
"properties": { | ||
"PostCSSSorting": { | ||
"default": {}, | ||
"description": "Settings for PostCSS Sorting plugin" | ||
} | ||
} | ||
} | ||
}, | ||
"scripts": { | ||
"postinstall": "node ./node_modules/vscode/bin/install" | ||
}, | ||
"devDependencies": { | ||
"vscode": "^0.11.0", | ||
"xo": "^0.14.0" | ||
}, | ||
"dependencies": { | ||
"postcss": "^5.0.19", | ||
"postcss-sorting": "^1.2.3" | ||
}, | ||
"xo": { | ||
"rules": { | ||
"arrow-parens": [ | ||
2, | ||
"always" | ||
], | ||
"object-curly-spacing": [ | ||
2, | ||
"always" | ||
], | ||
"babel/object-curly-spacing": 0, | ||
"space-before-function-paren": [ | ||
2, | ||
"never" | ||
] | ||
}, | ||
"envs": [ | ||
"node", | ||
"mocha" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../node_modules/vscode/typings/node.d.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../node_modules/vscode/typings/index-js.d.ts" /> |