Skip to content

Commit d9b8d2d

Browse files
committed
Do not flag words with special characters
1 parent 03ebded commit d9b8d2d

File tree

2 files changed

+15
-1
lines changed
  • lib/node_modules/@stdlib/_tools/eslint/rules/capitalized-comments

2 files changed

+15
-1
lines changed

lib/node_modules/@stdlib/_tools/eslint/rules/capitalized-comments/lib/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var DEFAULTS = require( './defaults.json' );
3030
// VARIABLES //
3131

3232
var RE_LETTERS = /^[a-zA-Z]/;
33+
var RE_SPECIAL_CHARS = /[^a-zA-Z]/;
3334
var OPTS = {
3435
'includeComments': true
3536
};
@@ -126,7 +127,11 @@ function main( context ) {
126127
}
127128
if ( scope.set.has( stext ) ) {
128129
found = true;
130+
} else if ( RE_SPECIAL_CHARS.test( stext ) ) {
131+
// Do not flag first word if it contains special characters (e.g., `x-value`):
132+
found = true;
129133
} else {
134+
// Check if the first word is contained in the whitelist (e.g., `ndarray`):
130135
for ( i = 0; i < opts.whitelist.length; i++ ) {
131136
word = opts.whitelist[ i ];
132137
if ( stext === word ) {
@@ -135,7 +140,7 @@ function main( context ) {
135140
}
136141
}
137142
}
138-
// If not in whitelist or current scope, raise an error:
143+
// If word is not in whitelist, has no special characters, and is not found in current scope, raise an error:
139144
if ( !found ) {
140145
report( comment );
141146
}

lib/node_modules/@stdlib/_tools/eslint/rules/capitalized-comments/test/fixtures/valid.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,15 @@ test = {
464464
};
465465
valid.push( test );
466466

467+
test = {
468+
'code': [
469+
'function square( x ) {',
470+
' return x*x; // x-value squared',
471+
'}'
472+
].join( '\n' )
473+
};
474+
valid.push( test );
475+
467476

468477
// EXPORTS //
469478

0 commit comments

Comments
 (0)