Skip to content

Commit 4599b9f

Browse files
committed
build: refactor rule to disallow tabs in entire JSDoc comment
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 8514fc9 commit 4599b9f

File tree

3 files changed

+68
-17
lines changed

3 files changed

+68
-17
lines changed

lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-no-tabs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# No Tabs
2222

23-
> [ESLint rule][eslint-rules] forbidding the use of tabs in JSDoc descriptions.
23+
> [ESLint rule][eslint-rules] forbidding the use of tabs in JSDoc comments.
2424
2525
<section class="intro">
2626

@@ -38,7 +38,7 @@ var rule = require( '@stdlib/_tools/eslint/rules/jsdoc-no-tabs' );
3838

3939
#### rule
4040

41-
[ESLint rule][eslint-rules] forbidding the use of tabs in JSDoc descriptions.
41+
[ESLint rule][eslint-rules] forbidding the use of tabs in JSDoc comments.
4242

4343
**Bad**:
4444

lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-no-tabs/lib/main.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
// MODULES //
2222

23-
var parseJSDoc = require( 'doctrine' ).parse;
2423
var remark = require( 'remark' );
2524
var remarkLint = require( 'remark-lint' );
2625
var remarkPlugin = require( 'remark-lint-no-tabs' );
@@ -30,17 +29,13 @@ var findJSDoc = require( '@stdlib/_tools/eslint/utils/find-jsdoc' );
3029

3130
// VARIABLES //
3231

33-
var DOPTS = {
34-
'sloppy': true,
35-
'unwrap': true
36-
};
3732
var rule;
3833

3934

4035
// FUNCTIONS //
4136

4237
/**
43-
* Rule forbidding the use of tabs in JSDoc descriptions.
38+
* Rule forbidding the use of tabs in JSDoc comments.
4439
*
4540
* @param {Object} context - ESLint context
4641
* @returns {Object} validators
@@ -67,24 +62,20 @@ function main( context ) {
6762
};
6863

6964
/**
70-
* Lints JSDoc descriptions.
65+
* Lints entire JSDoc comments for tabs.
7166
*
7267
* @private
7368
* @param {ASTNode} node - AST node
7469
*/
7570
function validate( node ) {
7671
var jsdoc;
7772
var vfile;
78-
var ast;
7973

8074
jsdoc = findJSDoc( source, node );
8175
if ( isObject( jsdoc ) ) {
82-
ast = parseJSDoc( jsdoc.value, DOPTS );
83-
if ( ast.description ) {
84-
vfile = lint( ast.description );
85-
if ( vfile.messages.length ) {
86-
reportErrors( vfile.messages, jsdoc.loc );
87-
}
76+
vfile = lint( jsdoc.value );
77+
if ( vfile.messages.length ) {
78+
reportErrors( vfile.messages, jsdoc.loc );
8879
}
8980
}
9081
}
@@ -154,7 +145,7 @@ function main( context ) {
154145
rule = {
155146
'meta': {
156147
'docs': {
157-
'description': 'forbid the use of tabs in JSDoc descriptions'
148+
'description': 'forbid the use of tabs in JSDoc comments'
158149
},
159150
'schema': []
160151
},

lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-no-tabs/test/fixtures/invalid.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,66 @@ test = {
7070
};
7171
invalid.push( test );
7272

73+
test = {
74+
'code': [
75+
'/**',
76+
'* Beep boop.',
77+
'*',
78+
'* [foo]: http://foo.bar/baz',
79+
'*',
80+
'* @param {string} str - input value',
81+
'* @returns {string} output value',
82+
'*',
83+
'* @example',
84+
'* var out = beep( "boop" );',
85+
'* // returns "beepboop"',
86+
'*/',
87+
'function beep( str ) {',
88+
' return "beep" + str;',
89+
'}'
90+
].join( '\n' ),
91+
'errors': [
92+
{
93+
'message': 'Use spaces instead of tabs',
94+
'type': null
95+
},
96+
{
97+
'message': 'Use spaces instead of tabs',
98+
'type': null
99+
}
100+
]
101+
};
102+
invalid.push( test );
103+
104+
test = {
105+
'code': [
106+
'/**',
107+
'* Beep boop.',
108+
'*',
109+
'* @param {string} str - input value',
110+
'* @returns {string} output value',
111+
'*',
112+
'* @example',
113+
'* var out = beep( "boop" );',
114+
'* // returns "beepboop"',
115+
'*/',
116+
'function beep( str ) {',
117+
' return "beep" + str;',
118+
'}'
119+
].join( '\n' ),
120+
'errors': [
121+
{
122+
'message': 'Use spaces instead of tabs',
123+
'type': null
124+
},
125+
{
126+
'message': 'Use spaces instead of tabs',
127+
'type': null
128+
}
129+
]
130+
};
131+
invalid.push( test );
132+
73133

74134
// EXPORTS //
75135

0 commit comments

Comments
 (0)