From a775ee7c9b1dba5ef4f3c1e45c824dc5526f3dfb Mon Sep 17 00:00:00 2001 From: Greg Cochard Date: Fri, 5 Jun 2015 12:43:30 -0700 Subject: [PATCH] Update: Add markers to spaced-comment (fixes #2588) --- docs/rules/spaced-comment.md | 23 +++++++++++++-- lib/rules/spaced-comment.js | 48 +++++++++++++++++++++++++++---- tests/lib/rules/spaced-comment.js | 33 +++++++++++++++++++++ 3 files changed, 96 insertions(+), 8 deletions(-) diff --git a/docs/rules/spaced-comment.md b/docs/rules/spaced-comment.md index 4d2b5e3ba329..ea62fd5c1100 100644 --- a/docs/rules/spaced-comment.md +++ b/docs/rules/spaced-comment.md @@ -13,12 +13,16 @@ This rule takes two arguments. If the first is `"always"` then the `//` or `/*` If `"never"` then there should be no whitespace following. The default is `"always"`. -The second argument is an object with one key, `"exceptions"`. -The value is an array of string patterns which are considered exceptions to the rule. +The second argument is an object with two keys, `"exceptions"` and `"markers"`. +The `"exceptions"` value is an array of string patterns which are considered exceptions to the rule. It is important to note that the exceptions are ignored if the first argument is `"never"`. Exceptions cannot be mixed. From the collection of exceptions provided only one of them can be used inside the comment. Mixing of more than one is not valid. +The `"markers"` value is an array of string patterns which are considered markers for docblock-style comments, +such as an additional `/`, used to denote documentation read by doxygen, vsdoc, etc. which must have additional characters. +The `"markers"` array will apply regardless of the value of the first argument, e.g. `"always"` or `"never"`. + The following patterns are considered warnings: ```js @@ -55,6 +59,11 @@ var foo = 5; //------++++++++ ``` +```js +// When ["always",{"markers":["/"]}] +///This is a comment with a marker but without whitespace +``` + ```js // When ["always",{"exceptions":["-","+"]}] /*------++++++++*/ @@ -109,3 +118,13 @@ var foo = 5; // Comment block /*-+-+-+-+-+-+-+*/ ``` + +```js +// When ["always",{"markers":["/"]}] +/// This is a comment with a marker +``` + +```js +// When ["never",{"markers":["!<"]}] +//!