Skip to content

Commit

Permalink
Add support for customizing the document types (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
orta authored and shinnn committed Jun 29, 2017
1 parent 4296f66 commit 9f50466
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ Default: `null`

Will be directly passed to [`config`](https://github.com/stylelint/stylelint/blob/master/docs/user-guide/node-api.md#config) option. Note that if you set `config` option, this plugin ignores all the stylelint configuration files.

#### stylelint.additionalDocumentSelectors

Type: `array`
Default: `[]`

A set of document types that you can use to run stylelint against if you are using CSS inside document types like: `javascriptreact`, `typescriptreact` or `vue`.

## License

Copyright (c) 2015 - 2017 [Shinnosuke Watanabe](https://github.com/shinnn)
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const vscode = require('vscode');

exports.activate = context => {
const serverModule = path.join(__dirname, 'server.js');
const workspaceConfig = vscode.workspace.getConfiguration('stylelint');
const additionalDocuments = workspaceConfig.get('additionalDocumentSelectors');

const client = new LanguageClient('stylelint', {
run: {
Expand All @@ -21,7 +23,7 @@ exports.activate = context => {
}
}
}, {
documentSelector: ['css', 'less', 'postcss', 'scss'],
documentSelector: ['css', 'less', 'postcss', 'scss', ...additionalDocuments],
synchronize: {
configurationSection: 'stylelint',
fileEvents: vscode.workspace.createFileSystemWatcher('**/{.stylelintrc,stylelint.config.js}')
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"onLanguage:css",
"onLanguage:less",
"onLanguage:postcss",
"onLanguage:scss"
"onLanguage:scss",
"workspaceContains:node_modules/stylelint-processor-styled-components/package.json"
],
"main": "index.js",
"contributes": {
Expand Down Expand Up @@ -58,6 +59,13 @@
],
"default": null,
"description": "A partial stylelint config whose properties override the existing ones."
},
"stylelint.additionalDocumentSelectors": {
"type": [
"array"
],
"default": [],
"description": "A optional set of additional document types to run stylelint against."
}
}
},
Expand Down

0 comments on commit 9f50466

Please sign in to comment.