<!--
@license Apache-2.0
Copyright (c) 2018 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
   http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
# jsdoc-doctest-marker
> [ESLint rule][eslint-rules] to enforce marker style conventions for return annotations in example code.
<section class="intro">
</section>
<!-- /.intro -->
<section class="usage">
## Usage
```javascript
var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-doctest-marker' );
```
#### rule
[ESLint rule][eslint-rules] to enforce marker style conventions for return annotations in example code. Return annotations may start with `returns`, `throws`, or `=>`. `returns` may only follow variable declarations or assignment expressions, whereas `=>` may only follow `console.log` calls.
**Bad**:
<!-- eslint-disable stdlib/jsdoc-doctest-marker -->
```javascript
/**
* Squares a number.
*
* @param {number} x - input value
* @returns {number} x*x
*
* @example
* var y = square( 3.0 );
* // => 9.0
*
* console.log( square( 2.0 ) );
* // returns 4.0
*
* // => 3.0
*/
function square( x ) {
    return x*x;
}
```
**Good**:
```javascript
/**
* Squares a number.
*
* @param {number} x - input value
* @returns {number} x*x
*
* @example
* var y = square( 3.0 );
* // returns 9.0
*
* console.log( square( 2.0 ) );
* // => 4.0
*/
function square( x ) {
    return x*x;
}
```
</section>
<!-- /.usage -->
<section class="examples">
## Examples
<!-- eslint no-undef: "error" -->
```javascript
var Linter = require( 'eslint' ).Linter;
var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-doctest-marker' );
var linter = new Linter();
var result;
var code;
code = [
    '/**',
    '* Squares a number.',
    '*',
    '* @param {number} x - input value',
    '* @returns {number} x*x',
    '*',
    '* @example',
    '* var y = square( 3.0 );',
    '* // => 9.0',
    '*',
    '* console.log( square( 2.0 ) );',
    '* // returns 4.0',
    '*/',
    'function square( x ) {',
    '  return x*x;',
    '}'
].join( '\n' );
linter.defineRule( 'jsdoc-doctest-marker', rule );
result = linter.verify( code, {
    'rules': {
        'jsdoc-doctest-marker': 'error'
    }
});
/* returns
    [
        {
            'ruleId': 'jsdoc-doctest-marker',
            'severity': 2,
            'message': 'Only include `// returns` after variable declarations or assignment expressions (use `=>` after `console.log`)',
            'line': 13,
            'column': 1,
            'nodeType': FunctionDeclaration,
            'source': 'function square( x ) {',
            'endLine': 15,
            'endColumn': 2
        }
    ]
*/
```
</section>
<!-- /.examples -->
<section class="links">
[eslint-rules]: https://eslint.org/docs/developer-guide/working-with-rules
</section>
<!-- /.links -->