-
-
Notifications
You must be signed in to change notification settings - Fork 28
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 7d9a9db
Showing
13 changed files
with
651 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,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = 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,27 @@ | ||
{ | ||
"version": "0.1.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceRoot}", | ||
"${workspaceRoot}/fixture.css" | ||
], | ||
"stopOnEntry": false | ||
}, | ||
{ | ||
"name": "Launch Tests", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceRoot}", | ||
"--extensionTestsPath=${workspaceRoot}/test" | ||
], | ||
"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,3 @@ | ||
{ | ||
"javascript.validate.syntaxValidation": 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,8 @@ | ||
.editorconfig | ||
.gitignore | ||
.vscode/** | ||
*.css | ||
*.png | ||
*.scss | ||
media/*.ai | ||
test |
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,56 @@ | ||
# vscode-stylelint | ||
|
||
[![Dependency Status](https://david-dm.org/shinnn/vscode-stylelint.svg)](https://david-dm.org/shinnn/vscode-stylelint) | ||
[![devDependency Status](https://david-dm.org/shinnn/vscode-stylelint/dev-status.svg)](https://david-dm.org/shinnn/vscode-stylelint#info=devDependencies) | ||
|
||
A [Visual Studio Code](https://code.visualstudio.com/) extension to lint [CSS](https://www.w3.org/Style/CSS/)/[SCSS](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) with [stylelint](http://stylelint.io/) | ||
|
||
![screenshot](screenshot.png) | ||
|
||
## Installation | ||
|
||
1. Run [`Install Extension`](https://code.visualstudio.com/docs/editor/extension-gallery#_install-an-extension) command from [Command Palette](https://code.visualstudio.com/Docs/editor/codebasics#_command-palette). | ||
2. Search and choose `stylelint`. | ||
|
||
See the [extension installation guide](https://code.visualstudio.com/docs/editor/extension-gallery) for details. | ||
|
||
## Usage | ||
|
||
Enable the linter in the VS Code [settings](https://code.visualstudio.com/docs/customization/userandworkspace). | ||
|
||
```json | ||
{ | ||
"stylelint.enable": true | ||
} | ||
``` | ||
|
||
### Configurations | ||
|
||
*In addition to the VS Code settings mentioned below, you can set the config by adding [`.stylelintrc`](https://github.com/stylelint/stylelint/blob/master/docs/user-guide/configuration.md#configuration) file to the workspace directory or its ancestor ones.* | ||
|
||
#### stylelint.enable | ||
|
||
Type: `Boolean` | ||
Default: `false` | ||
|
||
Control whether [stylelint](https://github.com/stylelint/stylelint/) is enabled for CSS/SCSS files or not. | ||
|
||
#### stylelint.config | ||
|
||
Type: `Object` | ||
Default: `null` | ||
|
||
Will be directly passed to [`config`](https://github.com/stylelint/stylelint/blob/master/docs/user-guide/node-api.md#config) option. | ||
|
||
#### stylelint.configOverrides | ||
|
||
Type: `Object` | ||
Default: `null` | ||
|
||
Will be directly passed to [`configOverrides`](https://github.com/stylelint/stylelint/blob/master/docs/user-guide/node-api.md#configoverrides) option. | ||
|
||
## License | ||
|
||
Copyright (c) 2015 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
|
||
Licensed under [the MIT License](./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,32 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
const langClient = require('vscode-languageclient'); | ||
const LanguageClient = langClient.LanguageClient; | ||
const SettingMonitor = langClient.SettingMonitor; | ||
const vscode = require('vscode'); | ||
|
||
exports.activate = function activateStylelint(context) { | ||
const serverModule = path.join(__dirname, 'server.js'); | ||
|
||
const client = new LanguageClient('stylelint', { | ||
run: { | ||
module: serverModule | ||
}, | ||
debug: { | ||
module: serverModule, | ||
options: { | ||
execArgv: ['--nolazy', '--debug=6004'] | ||
} | ||
} | ||
}, { | ||
documentSelector: ['css', 'sass'], | ||
synchronize: { | ||
configurationSection: 'stylelint', | ||
fileEvents: vscode.workspace.createFileSystemWatcher('**/.stylelintrc') | ||
} | ||
}); | ||
|
||
context.subscriptions.push(new SettingMonitor(client, 'stylelint.enable').start()); | ||
}; |
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,63 @@ | ||
{ | ||
"name": "stylelint", | ||
"version": "0.1.0", | ||
"displayName": "stylelint", | ||
"description": "Modern CSS/SCSS linter", | ||
"publisher": "shinnn", | ||
"repository": "https://github.com/shinnn/vscode-stylelint", | ||
"homepage": "https://github.com/shinnn/vscode-stylelint#readme", | ||
"bugs": "https://github.com/shinnn/vscode-stylelint/issues", | ||
"license": "MIT", | ||
"icon": "media/icon.svg", | ||
"galleryBanner": { | ||
"color": "#32CD32", | ||
"theme": "light" | ||
}, | ||
"engines": { | ||
"vscode": "^0.10.1" | ||
}, | ||
"categories": [ | ||
"Linters" | ||
], | ||
"activationEvents": [ | ||
"onLanguage:css", | ||
"onLanguage:sass" | ||
], | ||
"main": "extension.js", | ||
"contributes": { | ||
"configuration": { | ||
"type": "object", | ||
"title": "stylelint configuration options", | ||
"properties": { | ||
"stylelint.enable": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Control whether stylelint is enabled for CSS/SCSS files or not." | ||
}, | ||
"stylelint.config": { | ||
"type": "object", | ||
"default": null, | ||
"description": "A stylelint configuration object." | ||
}, | ||
"stylelint.configOverrides": { | ||
"type": "object", | ||
"default": null, | ||
"description": "A partial stylelint config whose properties override the existing ones." | ||
} | ||
} | ||
} | ||
}, | ||
"scripts": { | ||
"test": "eslint --config @shinnn/node --fix extension.js server.js" | ||
}, | ||
"dependencies": { | ||
"stylelint-vscode": "^1.0.0", | ||
"vscode-languageclient": "0.10.7", | ||
"vscode-languageserver": "0.10.6" | ||
}, | ||
"devDependencies": { | ||
"@shinnn/eslint-config-node": "^1.0.1", | ||
"eslint": "^1.10.1", | ||
"vscode": "^0.10.6" | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,61 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
const langServer = require('vscode-languageserver'); | ||
const stylelintVSCode = require('stylelint-vscode'); | ||
|
||
let configBasedir; | ||
let config; | ||
let configOverrides; | ||
|
||
const connection = langServer.createConnection(process.stdin, process.stdout); | ||
const documents = new langServer.TextDocuments(); | ||
|
||
function validate(document) { | ||
return stylelintVSCode({ | ||
code: document.getText(), | ||
config, | ||
configOverrides, | ||
configBasedir, | ||
syntax: path.extname(String(document.uri)).toLowerCase() === '.scss' ? 'scss' : null | ||
}).then(diagnostics => { | ||
connection.sendDiagnostics({uri: document.uri, diagnostics}); | ||
}).catch(err => { | ||
if (err.reasons) { | ||
err.reasons.forEach(reason => connection.window.showErrorMessage('stylelint: ' + reason)); | ||
return; | ||
} | ||
|
||
connection.window.showErrorMessage('stylelint: ' + err.message); | ||
}); | ||
} | ||
|
||
function validateAll() { | ||
return Promise.all(documents.all().map(document => validate(document))); | ||
} | ||
|
||
connection.onInitialize(params => { | ||
configBasedir = params.rootPath; | ||
|
||
validateAll(); | ||
|
||
return { | ||
capabilities: { | ||
textDocumentSync: documents.syncKind | ||
} | ||
}; | ||
}); | ||
connection.onDidChangeConfiguration(params => { | ||
const settings = params.settings; | ||
config = settings.stylelint.config || {}; | ||
configOverrides = settings.stylelint.configOverrides || {}; | ||
|
||
validateAll(); | ||
}); | ||
connection.onDidChangeWatchedFiles(() => validateAll()); | ||
|
||
documents.onDidChangeContent(event => validate(event.document)); | ||
documents.listen(connection); | ||
|
||
connection.listen(); |