From 9a144b2be8f578ae541c72bb7c667c57b5fcf102 Mon Sep 17 00:00:00 2001 From: Shinnosuke Watanabe Date: Tue, 20 Mar 2018 19:26:41 +0900 Subject: [PATCH] run stylelint for JS files when a CSS-in-JS processor is enabled Those languages IDs are safely supported by stylelint-vscode: https://github.com/shinnn/stylelint-vscode/commit/5e3f4556d74c1fe49f465fe7e17ae373f36a65ef --- README.md | 31 +++++++++++++++++++++---------- media/language.png | Bin 0 -> 8843 bytes package.json | 9 +++++++-- 3 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 media/language.png diff --git a/README.md b/README.md index 8883be33..22d06a28 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Read the [extension installation guide](https://code.visualstudio.com/docs/edito duplicate messages from both the built-in linter and vscode-stylelint -To prevent both [the VSCode built-in CSS linter](https://code.visualstudio.com/docs/languages/css#_syntax-verification-linting) `[css]` and this extension `[stylelint]` reporting the same CSS errors like in the screenshot, you can disable the built-in ones in User or Workspace [setting](https://code.visualstudio.com/docs/getstarted/settings): +To prevent both [the editor built-in linters](https://code.visualstudio.com/docs/languages/css#_syntax-verification-linting) `[css]` `[less]` `[scss]` and this extension `[stylelint]` from reporting essentially the same errors like in the screenshot, disable the built-in ones in User or Workspace [setting](https://code.visualstudio.com/docs/getstarted/settings): ```json "css.validate": false, @@ -27,7 +27,9 @@ To prevent both [the VSCode built-in CSS linter](https://code.visualstudio.com/d ## Usage -Once you follow [the stylelint startup guide](https://github.com/stylelint/stylelint#getting-started) by creating a [configuration](https://stylelint.io/user-guide/configuration/) file or edit [`stylelint.*` VSCode settings](#extension-settings), stylelint automatically validates documents with these [language identifiers](https://code.visualstudio.com/docs/languages/overview#_language-id): +Once a user follows [the stylelint startup guide](https://github.com/stylelint/stylelint#getting-started) by creating a [configuration](https://stylelint.io/user-guide/configuration/) file or by editting [`stylelint.*` VSCode settings](#extension-settings), stylelint automatically validates documents with these [language identifiers](https://code.visualstudio.com/docs/languages/overview#_language-id): + +UI to select a language identifier * CSS (`css`) * HTML (`html`) @@ -38,42 +40,51 @@ Once you follow [the stylelint startup guide](https://github.com/stylelint/style * [Sass (`sass`)](https://marketplace.visualstudio.com/items?itemName=robinbentley.sass-indented) * SCSS (`scss`) * [Sugarss (`sugarss`)](https://marketplace.visualstudio.com/items?itemName=mhmadhamster.postcss-language) -* [Vue (`vue`)](https://marketplace.visualstudio.com/items?itemName=octref.vetur) -* [Vue-HTML (`vue-html`)](https://marketplace.visualstudio.com/items?itemName=octref.vetur) +* [Vue (`vue`, `vue-html`)](https://marketplace.visualstudio.com/items?itemName=octref.vetur) * XML (`xml`) +If either [stylelint-processor-glamorous](https://github.com/zabute/stylelint-processor-glamorous) or [stylelint-processor-styled-components](https://github.com/styled-components/stylelint-processor-styled-components) is installed and [enabled](https://github.com/stylelint/stylelint/blob/master/docs/user-guide/configuration.md#processors), stylelint also validates the followings: + +* JavaScript (`javascript`) +* JavaScript React (`javascriptreact`) +* styled-components + * [Official (`source.css.styled`)](https://marketplace.visualstudio.com/items?itemName=jpoissonnier.vscode-styled-components) + * [Userland (`styled-css`)](https://marketplace.visualstudio.com/items?itemName=mgmcdermott.vscode-language-babel) +* TypeScript (`typescript`) +* TypeScript React (`typescriptreact`) + ### Extension settings -Though it's highly recommended to add a [stylelint configuration file](https://stylelint.io/user-guide/example-config/) to your workspace folder instead, you can also use the following extension [settings](https://code.visualstudio.com/docs/getstarted/settings). +Though it's highly recommended to add a [stylelint configuration file](https://stylelint.io/user-guide/example-config/) to the current workspace folder instead, the following extension [settings](https://code.visualstudio.com/docs/getstarted/settings) are also available. #### stylelint.enable Type: `boolean` Default: `true` -Control whether [stylelint](https://github.com/stylelint/stylelint/) is enabled or not. +Control whether this extension is enabled or not. #### 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. +Set stylelint [`configOverrides`](https://github.com/stylelint/stylelint/blob/master/docs/user-guide/node-api.md#configoverrides) option. #### 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. Note that if you set `config` option, this plugin ignores all the stylelint configuration files. +Set stylelint [`config`](https://github.com/stylelint/stylelint/blob/master/docs/user-guide/node-api.md#config) option. Note that when this option is enabled, stylelint doesn't load configuration files. #### stylelint.additionalDocumentSelectors Type: `Array` Default: `[]` -Document types that you can use to run stylelint against if you are using CSS inside document types like: `javascriptreact`, `typescriptreact`. +Document types that you can use to run stylelint against if you are using CSS inside document types. ## License -[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe +[ISC License](./LICENSE.txt) © 2018 Shinnosuke Watanabe diff --git a/media/language.png b/media/language.png new file mode 100644 index 0000000000000000000000000000000000000000..a0e6f69d24621018291212d2dae26f6744e64cd1 GIT binary patch literal 8843 zcmdUV{FfV4NHe(pyKf5Xf9Ap{C`B5B+9z`+;JbKA*o-Z{hAd;EHINy>xJQ zp8fH|eBNZ=@y&k8jCplzUjh|HK_opr6_{ZMsl1x35>5b?4Ur1#G7j+a^gPSH4gp@7}%89o>oC#DxD`0A9EZvy4|Q*rgUc%~CJg zu|pJUT(&ZseNxHif$s|*u6ZR`Em|l3ZDA`RNEjWr=W9_N>HfC+jPtcOAEzB=cdC4T zGDqD?9GZ^hLPS9YQI3VzdX_D(q~i7WJ!=2jz1+r(0$&jZTmj6{vIS>Bi|%mDYtx5j^?Agu2_|UH3>oDrXM}ROW85 zaivvU?bY`LB@>ol#3(mpC}91XyL-9=rwWm}bePneeVg5JCTNiqopv^gtCG!J z!dWqKLpwdYqr379E`^@UN6TAHB0pZyR`g{r%Y&nlIxI9dv78m=*Amw4#k88Yil=L; zTNm8s=;opX^?j3h8#9Wj^f!&(2$B}Q#zAHB6r1#^$a5&a5YFc;t=%1sOCo_F-S5F- z#JS^cl(VhMO;&>s#Z^AnZqyd%ek-J!I3y}yk0kGR%HMH7U*T;qOVp1z!ebGZks`>B z!YR4qh}T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thQ?bGBQGq!*W;z#vrc z6O9y=|2{QE@fnMuK?Ll~k}2T({*W|ONr0^5Qim8sE$N?3h>02-7iaxQ$CPdTW>5)T R3n(%HsVZtJz~rnV{|^j8@Us8_ literal 0 HcmV?d00001 diff --git a/package.json b/package.json index b1492ac0..701ab13a 100644 --- a/package.json +++ b/package.json @@ -30,17 +30,22 @@ "activationEvents": [ "onLanguage:css", "onLanguage:html", + "onLanguage:javascript", + "onLanguage:javascriptreact", "onLanguage:less", "onLanguage:markdown", "onLanguage:postcss", "onLanguage:sass", "onLanguage:scss", + "onLanguage:source.css.styled", "onLanguage:source.markdown.math", + "onLanguage:styled-css", "onLanguage:sugarss", + "onLanguage:typescript", + "onLanguage:typescriptreact", "onLanguage:vue", "onLanguage:vue-html", - "onLanguage:xml", - "workspaceContains:**/node_modules/stylelint-processor-styled-components/package.json" + "onLanguage:xml" ], "main": "index.js", "contributes": {