Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/node_modules/@stdlib/_tools/eslint/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ var eslint = rules;
- <span class="signature">[`jsdoc-no-unused-definitions`][@stdlib/_tools/eslint/rules/jsdoc-no-unused-definitions]</span><span class="delimiter">: </span><span class="description">ESLint rule to prevent unused Markdown definitions in JSDoc descriptions.</span>
- <span class="signature">[`jsdoc-ordered-list-marker-style`][@stdlib/_tools/eslint/rules/jsdoc-ordered-list-marker-style]</span><span class="delimiter">: </span><span class="description">ESLint rule to enforce a specified Markdown ordered list marker style in JSDoc descriptions.</span>
- <span class="signature">[`jsdoc-ordered-list-marker-value`][@stdlib/_tools/eslint/rules/jsdoc-ordered-list-marker-value]</span><span class="delimiter">: </span><span class="description">ESLint rule to enforce a specified Markdown ordered list marker style in JSDoc descriptions.</span>
- <span class="signature">[`jsdoc-param-hyphen-spacing`][@stdlib/_tools/eslint/rules/jsdoc-param-hyphen-spacing]</span><span class="delimiter">: </span><span class="description">ESLint rule to enforce hyphen spacing in JSDoc @param tags.</span>
- <span class="signature">[`jsdoc-private-annotation`][@stdlib/_tools/eslint/rules/jsdoc-private-annotation]</span><span class="delimiter">: </span><span class="description">ESLint rule enforcing that JSDoc comments of unassigned function declarations have a `@private` tag.</span>
- <span class="signature">[`jsdoc-require-throws-tags`][@stdlib/_tools/eslint/rules/jsdoc-require-throws-tags]</span><span class="delimiter">: </span><span class="description">ESLint rule enforcing that JSDoc comments of functions are not missing `@throws` tags.</span>
- <span class="signature">[`jsdoc-rule-style`][@stdlib/_tools/eslint/rules/jsdoc-rule-style]</span><span class="delimiter">: </span><span class="description">ESLint rule to enforce a specified Markdown style for horizontal rules in JSDoc descriptions.</span>
Expand Down Expand Up @@ -352,6 +353,8 @@ console.log( getKeys( rules ) );

[@stdlib/_tools/eslint/rules/jsdoc-ordered-list-marker-value]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/_tools/eslint/rules/jsdoc-ordered-list-marker-value

[@stdlib/_tools/eslint/rules/jsdoc-param-hyphen-spacing]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/_tools/eslint/rules/jsdoc-param-hyphen-spacing

[@stdlib/_tools/eslint/rules/jsdoc-private-annotation]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/_tools/eslint/rules/jsdoc-private-annotation

[@stdlib/_tools/eslint/rules/jsdoc-require-throws-tags]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/_tools/eslint/rules/jsdoc-require-throws-tags
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<!--

@license Apache-2.0

Copyright (c) 2026 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-param-hyphen-spacing

> [ESLint rule][eslint-rules] to enforce hyphen spacing in JSDoc `@param` tags.

<section class="intro">

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-param-hyphen-spacing' );
```

#### rule

[ESLint rule][eslint-rules] to enforce hyphen spacing in JSDoc `@param` tags.

**Bad**:

```javascript
/**
* Squares a number.
*
* @param {number} x - input number
* @returns {number} x squared
*/
function square( x ) {
return x * x;
}
```

**Good**:

```javascript
/**
* Squares a number.
*
* @param {number} x - input number
* @returns {number} x squared
*/
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-param-hyphen-spacing' );

var linter = new Linter();
var result;
var code;

code = [
'/**',
'* Squares a number.',
'*',
'* @param {number} x - input number',
'* @returns {number} x squared',
'*/',
'function square( x ) {',
' return x*x;',
'}'
].join( '\n' );

linter.defineRule( 'jsdoc-param-hyphen-spacing', rule );

result = linter.verify( code, {
'rules': {
'jsdoc-param-hyphen-spacing': 'error'
}
});
console.log( result );
/* =>
[
{
'ruleId': 'jsdoc-param-hyphen-spacing',
'severity': 2,
'message': 'hyphen should be preceded by only one space',
'line': 4,
'column': 1,
'nodeType': null,
'source': '* @param {number} x - input number',
'endLine': 4,
'endColumn': 43
},
{
'ruleId': 'jsdoc-param-hyphen-spacing',
'severity': 2,
'message': 'hyphen should be followed by only one space',
'line': 4,
'column': 1,
'nodeType': null,
'source': '* @param {number} x - input number',
'endLine': 4,
'endColumn': 43
}
]
*/
```

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[eslint-rules]: https://eslint.org/docs/developer-guide/working-with-rules

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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.
*/

'use strict';

var Linter = require( 'eslint' ).Linter;
var rule = require( './../lib' );

var linter = new Linter();
var result;
var code;

code = [
'/**',
'* Squares a number.',
'*',
'* @param {number} x - input number',
'* @returns {number} x squared',
'*/',
'function square( x ) {',
' return x*x;',
'}'
].join( '\n' );

linter.defineRule( 'jsdoc-param-hyphen-spacing', rule );

result = linter.verify( code, {
'rules': {
'jsdoc-param-hyphen-spacing': 'error'
}
});
console.log( result );
/* =>
[
{
'ruleId': 'jsdoc-param-hyphen-spacing',
'severity': 2,
'message': 'hyphen should be preceded by only one space',
'line': 4,
'column': 1,
'nodeType': null,
'source': '* @param {number} x - input number',
'endLine': 4,
'endColumn': 43
},
{
'ruleId': 'jsdoc-param-hyphen-spacing',
'severity': 2,
'message': 'hyphen should be followed by only one space',
'line': 4,
'column': 1,
'nodeType': null,
'source': '* @param {number} x - input number',
'endLine': 4,
'endColumn': 43
}
]
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"before": true,
"after": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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.
*/

'use strict';

/**
* ESLint rule to enforce hyphen spacing in JSDoc `@param` tags.
*
* @module @stdlib/_tools/eslint/rules/jsdoc-param-hyphen-spacing
*
* @example
* var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-param-hyphen-spacing' );
*
* console.log( rule );
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
Loading