eslint-plugin-jsdoc
Advanced tools
Comparing version 4.5.0 to 4.6.0
@@ -18,3 +18,5 @@ "use strict"; | ||
report = _ref.report, | ||
context = _ref.context, | ||
jsdocNode = _ref.jsdocNode; | ||
var always; | ||
@@ -25,6 +27,24 @@ var jsdocTags = _lodash.default.filter(jsdoc.tags, { | ||
if (_lodash.default.has(context.options, 0)) { | ||
always = context.options[0] === 'always'; | ||
} else { | ||
always = true; | ||
} | ||
_lodash.default.forEach(jsdocTags, function (jsdocTag) { | ||
if (jsdocTag.description && !_lodash.default.startsWith(jsdocTag.description, '-')) { | ||
report('There must be a hyphen before @param description.', function (fixer) { | ||
var replacement = sourceCode.getText(jsdocNode).replace(jsdocTag.description, '- ' + jsdocTag.description); | ||
if (!jsdocTag.description) { | ||
return; | ||
} | ||
if (always) { | ||
if (!_lodash.default.startsWith(jsdocTag.description, '-')) { | ||
report('There must be a hyphen before @param description.', function (fixer) { | ||
var replacement = sourceCode.getText(jsdocNode).replace(jsdocTag.description, '- ' + jsdocTag.description); | ||
return fixer.replaceText(jsdocNode, replacement); | ||
}, jsdocTag); | ||
} | ||
} else if (_lodash.default.startsWith(jsdocTag.description, '-')) { | ||
report('There must be no hyphen before @param description.', function (fixer) { | ||
var reg = new RegExp(/(?<=-\s*)\w.*/); | ||
var replacement = sourceCode.getText(jsdocNode).replace(jsdocTag.description, jsdocTag.description.match(reg)); | ||
return fixer.replaceText(jsdocNode, replacement); | ||
@@ -31,0 +51,0 @@ }, jsdocTag); |
@@ -63,3 +63,3 @@ { | ||
}, | ||
"version": "4.5.0" | ||
"version": "4.6.0" | ||
} |
@@ -846,3 +846,3 @@ <a name="eslint-plugin-jsdoc"></a> | ||
/** | ||
/** | ||
* @abstract | ||
@@ -935,5 +935,5 @@ * @access | ||
Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`. | ||
Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`. | ||
Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do. | ||
Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do. | ||
@@ -1622,2 +1622,4 @@ So in a sense, there two types of strings in Javascript; `{string}` literals, also called primitives and `{String}` Objects. We use the primitives because it's easier to write and uses less memory. `{String}` and `{string}` are technically both valid, but they are not the same. | ||
This rule takes one argument. If it is `"always"` then a problem is raised when there is no hyphen before the description. If it is `"never"` then a problem is raised when there is a hyphen before the description. The default value is `"always"`. | ||
||| | ||
@@ -1637,3 +1639,13 @@ |---|---| | ||
} | ||
// Options: ["always"] | ||
// Message: There must be a hyphen before @param description. | ||
/** | ||
* @param foo - Foo. | ||
*/ | ||
function quux () { | ||
} | ||
// Options: ["never"] | ||
// Message: There must be no hyphen before @param description. | ||
```` | ||
@@ -1650,2 +1662,11 @@ | ||
} | ||
// Options: ["always"] | ||
/** | ||
* @param foo Foo. | ||
*/ | ||
function quux () { | ||
} | ||
// Options: ["never"] | ||
```` | ||
@@ -2311,3 +2332,3 @@ | ||
/** | ||
/** | ||
* @returns {Promise<void>} | ||
@@ -2317,3 +2338,3 @@ */ | ||
/** | ||
/** | ||
* @returns {Promise<void>} | ||
@@ -2320,0 +2341,0 @@ */ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212393
1373
2489