From 9f504667964140336b841a7f7ba55d728488739d Mon Sep 17 00:00:00 2001 From: Orta Date: Thu, 29 Jun 2017 06:34:45 -0400 Subject: [PATCH] Add support for customizing the document types (#82) fix https://github.com/shinnn/vscode-stylelint/issues/38 fix https://github.com/shinnn/vscode-stylelint/issues/52 close https://github.com/shinnn/vscode-stylelint/pull/48 --- README.md | 7 +++++++ index.js | 4 +++- package.json | 10 +++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 51650446..e80b81fd 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/index.js b/index.js index b0c5f448..5185cb24 100644 --- a/index.js +++ b/index.js @@ -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: { @@ -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}') diff --git a/package.json b/package.json index 2e73c9cf..49a8dc64 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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." } } },