Skip to content

Commit 2999155

Browse files
chore: fix JavaScript lint errors (issue #8294)
1 parent ddceed7 commit 2999155

File tree

100 files changed

+591
-825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+591
-825
lines changed

.github/workflows/scripts/run_tests_coverage

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@
2626
# file2 File name.
2727
# file3 File name.
2828
#
29-
#
30-
# Environment variables:
31-
#
32-
# GITHUB_REPO GitHub repository.
33-
# GITHUB_REF GitHub branch or tag.
34-
# LOG_FILE Log file.
35-
#
3629

37-
# shellcheck disable=SC2181,SC2153,SC2129
30+
# shellcheck disable=SC2181,SC2153,SC2129,SC2207,SC2317
3831

3932
# Ensure that the exit status of pipelines is non-zero in the event that at least one of the commands in a pipeline fails:
4033
set -o pipefail
@@ -48,15 +41,6 @@ coverage_base_url="${COVERAGE_BASE_URL:-https://coverage.stdlib.io}"
4841
# Get the list of changed files:
4942
changed="$*"
5043

51-
# Get the GitHub repository:
52-
github_repo="${GITHUB_REPO}"
53-
54-
# Get the GitHub branch or tag:
55-
github_ref="${GITHUB_REF}"
56-
57-
# Get the path to a log file as the third argument to the build script:
58-
log_file="${LOG_FILE}"
59-
6044
# Define a heartbeat interval to periodically print messages in order to prevent CI from prematurely ending a build due to long running commands:
6145
heartbeat_interval='30s'
6246

@@ -125,18 +109,18 @@ compare_cov() {
125109

126110
if [ "$old_cov_value" == 0 ]; then
127111
new_cov_percentage=$(awk "BEGIN {printf \"%.2f\", $new_cov_value*100}")
128-
echo "\$\\\\\\\\color{green}+$new_cov_percentage\\\\\\\\\\\\\\\\%\$"
112+
printf "\$\\\\\\\\color{green}+%s\\\\\\\\\\\\\\\\%%\$\n" "$new_cov_percentage"
129113
else
130114
percentage_change=$(awk "BEGIN {printf \"%.2f\", (($new_cov_value - $old_cov_value) / $old_cov_value) * 100}")
131115
color="green"
132116
sign=""
133-
if [ $(awk "BEGIN {if ($percentage_change >= 0) print 1; else print 0}") -eq 1 ]; then
117+
if [ "$(awk "BEGIN {if ($percentage_change >= 0) print 1; else print 0}")" -eq 1 ]; then
134118
sign="+"
135-
elif [ $(awk "BEGIN {if ($percentage_change < 0) print 1; else print 0}") -eq 1 ]; then
119+
elif [ "$(awk "BEGIN {if ($percentage_change < 0) print 1; else print 0}")" -eq 1 ]; then
136120
sign="-"
137121
color="red"
138122
fi
139-
echo "\$\\\\\\\\color{$color}$sign$percentage_change\\\\\\\\\\\\\\\\%\$"
123+
printf "\$\\\\\\\\color{%s}%s%s\\\\\\\\\\\\\\\\%%\$\n" "$color" "$sign" "$percentage_change"
140124
fi
141125
}
142126

@@ -163,23 +147,15 @@ main() {
163147
coverage=''
164148
for package in ${directories}; do
165149
# For each package, extract coverage values from the respective coverage report:
166-
pkg=`echo $package | sed -E 's/^.*stdlib\///'`
150+
pkg=$(echo "$package" | sed -E 's/^.*stdlib\///')
167151

168152
if [ -f "lib/node_modules/@stdlib/${pkg}/binding.gyp" ]; then
169153
NODE_ADDONS_PATTERN="${pkg}" make install-node-addons
170154
fi
171155

172-
make test-javascript-cov TESTS_FILTER=".*/${pkg}/test/.*"
156+
make test-javascript-cov TESTS_FILTER=".*/${pkg}/test/.*" C8_FLAGS="-n 'lib/node_modules/@stdlib/${pkg}/**'"
173157

174-
if [ ! -f reports/coverage/lcov-report/${pkg}/lib/index.html ]; then
175-
# Reports for packages with no dependencies are stored in the `lcov-report` directory
176-
coverage_path="reports/coverage/lcov-report/index.html"
177-
top_level_report=true
178-
else
179-
# Reports for packages with dependencies are stored in `lcov-report/<pkg>/lib`:
180-
coverage_path="reports/coverage/lcov-report/${pkg}/lib/index.html"
181-
top_level_report=false
182-
fi
158+
coverage_path="reports/coverage/lcov-report/index.html"
183159
pkg_cov_values=($(cat $coverage_path | grep "fraction" | grep -oP '\d+/\d+' | awk -F'/' '{if ($2 != 0) print $1/$2; else print 1}'))
184160
pkg_statements_cov=${pkg_cov_values[0]}
185161
pkg_branches_cov=${pkg_cov_values[1]}
@@ -214,26 +190,22 @@ main() {
214190
pkg_cov="| $pkg_statements_cov_fraction <br> $cov_change_statements | $pkg_branches_cov_fraction <br> $cov_change_branches | $pkg_functions_cov_fraction <br> $cov_change_functions | $pkg_lines_cov_fraction <br> $cov_change_lines |"
215191

216192
pkg_url="${coverage_base_url}/${pkg}/index.html"
217-
pkg_link="<a href=\"$pkg_url\">$pkg</a>"
193+
pkg_link="<a href=\"${pkg_url}\">${pkg}</a>"
218194
coverage="$coverage\n| $pkg_link $pkg_cov"
219195

220196
# Copy coverage report of the package to artifacts directory:
221-
if [ "$top_level_report" = true ]; then
222-
mkdir -p "artifacts/${pkg}" && cp -r "reports/coverage/lcov-report"/* "artifacts/${pkg}/"
223-
else
224-
mkdir -p "artifacts/${pkg}/lib/" && cp -r "reports/coverage/lcov-report/${pkg}/lib"/* "artifacts/${pkg}/"
225-
fi
197+
mkdir -p "artifacts/${pkg}" && cp -r "reports/coverage/lcov-report"/* "artifacts/${pkg}/"
226198

227199
# Cleanup coverage reports for next package:
228200
rm -rf reports/coverage/lcov-report/*
229201
done
230202

231203
# Format coverage as Markdown table row:
232-
table_body=`echo $coverage | sed -e 's/,/|/g; s/"/ /g; s/\[/|/g; s/\]/|/g'`
204+
table_body=$(echo "$coverage" | sed -e 's/,/|/g; s/"/ /g; s/\[/|/g; s/\]/|/g')
233205
table_header="| Package | Statements | Branches | Functions | Lines |\n| --------- | ------------ | ---------- | ----------- | ----- |"
234206
table="${table_header}${table_body}"
235207

236-
echo "table=$table" >> $GITHUB_OUTPUT
208+
echo "table=$table" >> "$GITHUB_OUTPUT"
237209

238210
cleanup
239211
print_success

.mailmap

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,17 @@ Frank Kovacs <[email protected]> <[email protected]>
146146

147147
# G
148148

149+
Gaurav Jadhav <[email protected]> Gaurav
150+
149151
Gaurav Kaushik <[email protected]> Gauravkaushik-1206
150152

151153
Gautam Kaushik <[email protected]> Kaushikgtm
152154

153155
Geo Daoyu <[email protected]> GeoDaoyu
154156

155-
GittyHarsha <[email protected]>
157+
158+
Gitty Harsha <[email protected]> HarshaNP
159+
Gitty Harsha <[email protected]> GittyHarsha
156160

157161
Golden Kumar <[email protected]> Golden
158162
Golden Kumar <[email protected]> AuenKr
@@ -170,22 +174,44 @@ Gururaj Gurram <[email protected]> gururaj1512
170174

171175
# H
172176

173-
177+
Haroon Rasheed <[email protected]> haroon26
178+
179+
180+
Harsh Yadav <[email protected]> hrshya
174181

175182
176183

184+
Hemant M Mehta <[email protected]> hemantmm
185+
186+
Hridyanshu <[email protected]> HRIDYANSHU054
187+
188+
# I
189+
190+
191+
Iryna Andrushko <[email protected]> iraandrushko
192+
177193
# J
178194

179195
Jaimin Godhani <[email protected]> Jai0401
180196

197+
198+
Jaison Dsouza <[email protected]> Jaison D Souza
199+
Jaison Dsouza <[email protected]> jsndz
200+
201+
Jalaj Kumar <[email protected]> jalajk3004
202+
181203
James Gelok <[email protected]> James
182204

183205
Jay Soni <[email protected]> JaySoni1
184206

185207
186208

209+
Jenish Thapa <[email protected]> jenish-thapa
210+
187211
Jordan Gallivan <[email protected]> Jordan-Gallivan
188212

213+
Justyn Shelby <[email protected]> ShelbyJustyn
214+
189215
# K
190216

191217
Kaif Mohd <[email protected]>

CONTRIBUTORS

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,28 @@ Ekampreet Singh Bains <[email protected]>
6767
Eunice Sim <[email protected]>
6868
6969
Frank Kovacs <[email protected]>
70-
70+
Gaurav Jadhav <[email protected]>
7171
Gaurav Kaushik <[email protected]>
7272
Gautam Kaushik <[email protected]>
7373
Gautam sharma <[email protected]>
7474
Geo Daoyu <[email protected]>
7575
Girish Garg <[email protected]>
76+
Gitty Harsha <[email protected]>
7677
Golden Kumar <[email protected]>
7778
Gopi Kishan <[email protected]>
7879
Gunj Joshi <[email protected]>
7980
Guru Prasad Sharma <[email protected]>
8081
Gururaj Gurram <[email protected]>
8182
Harishchandra Reddy <[email protected]>
8283
Haroon Rasheed <[email protected]>
83-
84-
84+
Harsh Yadav <[email protected]>
8585
Harshita Kalani <[email protected]>
8686
Hemang Choudhary <[email protected]>
8787
Hemant M Mehta <[email protected]>
8888
Hridyanshu <[email protected]>
89-
iraandrushko <[email protected].com>
89+
Iryna Andrushko <ira.andrushko2@gmail.com>
9090
Jaimin Godhani <[email protected]>
91-
Jaison D Souza <[email protected].com>
91+
Jaison Dsouza <jaisondz9360@gmail.com>
9292
Jalaj Kumar <[email protected]>
9393
James Gelok <[email protected]>
9494

lib/node_modules/@stdlib/_tools/benchmarks/browser-build/test/test.cli.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var exec = require( 'child_process' ).exec;
25+
var execFile = require( 'child_process' ).execFile;
2526
var tape = require( 'tape' );
2627
var IS_BROWSER = require( '@stdlib/assert/is-browser' );
2728
var IS_WINDOWS = require( '@stdlib/assert/is-windows' );
@@ -62,7 +63,7 @@ tape( 'when invoked with a `--help` flag, the command-line interface prints the
6263
'--help'
6364
];
6465

65-
exec( cmd.join( ' ' ), done );
66+
execFile( cmd[ 0 ], cmd.slice( 1 ), done );
6667

6768
function done( error, stdout, stderr ) {
6869
if ( error ) {
@@ -88,7 +89,7 @@ tape( 'when invoked with a `-h` flag, the command-line interface prints the help
8889
'-h'
8990
];
9091

91-
exec( cmd.join( ' ' ), done );
92+
execFile( cmd[ 0 ], cmd.slice( 1 ), done );
9293

9394
function done( error, stdout, stderr ) {
9495
if ( error ) {
@@ -108,7 +109,7 @@ tape( 'when invoked with a `--version` flag, the command-line interface prints t
108109
'--version'
109110
];
110111

111-
exec( cmd.join( ' ' ), done );
112+
execFile( cmd[ 0 ], cmd.slice( 1 ), done );
112113

113114
function done( error, stdout, stderr ) {
114115
if ( error ) {
@@ -128,7 +129,7 @@ tape( 'when invoked with a `-V` flag, the command-line interface prints the vers
128129
'-V'
129130
];
130131

131-
exec( cmd.join( ' ' ), done );
132+
execFile( cmd[ 0 ], cmd.slice( 1 ), done );
132133

133134
function done( error, stdout, stderr ) {
134135
if ( error ) {

lib/node_modules/@stdlib/_tools/bib/citation-reference/lib/sync.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* @license Apache-2.0
33
*
44
* Copyright (c) 2018 The Stdlib Authors.
@@ -110,8 +110,22 @@ function toReference( id, options ) {
110110
'cwd': cwd()
111111
};
112112
debug( 'Converting temporary input file...' );
113-
data = exec( cmd, eopts );
114-
debug( 'Successfully converted temporary input file.' );
113+
try {
114+
data = exec( cmd, eopts );
115+
debug( 'Successfully converted temporary input file.' );
116+
} catch ( e ) {
117+
// If the conversion command fails (e.g., pandoc not installed),
118+
// create an empty output file so downstream processing can continue
119+
// and produce a deterministic (empty) result for doctest/lint runs.
120+
debug( 'Conversion command failed: %s', e.message );
121+
try {
122+
writeFile( outFile, '' );
123+
debug( 'Wrote empty temporary output file due to conversion failure.' );
124+
} catch ( e2 ) {
125+
// If we cannot create an output file, rethrow the original error.
126+
throw e;
127+
}
128+
}
115129

116130
rm( inFile );
117131

lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-license-header-year/lib/main.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* @license Apache-2.0
33
*
44
* Copyright (c) 2022 The Stdlib Authors.
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var execSync = require( 'child_process' ).execSync;
24+
var execFileSync = require( 'child_process' ).execFileSync;
2425
var replace = require( '@stdlib/string/replace' );
2526

2627

@@ -82,31 +83,32 @@ function main( context ) {
8283
* @private
8384
*/
8485
function validate() {
85-
var comments;
86-
var expected;
87-
var comment;
88-
var match;
89-
var year;
90-
91-
comments = source.getAllComments();
92-
if ( comments.length === 0 ) {
86+
var allComments;
87+
var expected;
88+
var comment;
89+
var match;
90+
var year;
91+
92+
allComments = source.getAllComments();
93+
if ( allComments.length === 0 ) {
9394
return;
9495
}
95-
comment = comments[ 0 ];
96+
comment = allComments[ 0 ];
9697
match = RE_COPYRIGHT.exec( comment.value );
9798
if ( match ) {
9899
year = match[ 1 ];
99100

100101
// Use `git` to determine the year the file was created...
101102
try {
102-
expected = execSync( 'git log --diff-filter=A --follow --format=%ad --date=short -- '+filename, {
103+
// Use execFileSync with argument array to avoid shell word-splitting for paths
104+
expected = execFileSync( 'git', [ 'log', '--diff-filter=A', '--follow', '--format=%ad', '--date=short', '--', filename ], {
103105
'encoding': 'utf8'
104106
});
105107
expected = expected.split( '-' )[ 0 ];
106108
if ( year !== expected ) {
107109
report( 'Expected year to be '+expected+' and not '+year, comment, expected );
108110
}
109-
} catch ( err ) {
111+
} catch ( _err ) {
110112
// Do nothing if unable to determine the year the file was created (e.g., if the file is not tracked yet by `git`).
111113
}
112114
}

lib/node_modules/@stdlib/array/generic/benchmark/benchmark.fast_elements_array_length_heuristic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ function copy1( arr ) {
6060

6161
len = arr.length;
6262
if ( len > MAX_FAST_ELEMENTS_HEURISTIC ) {
63-
out = new Array( MAX_FAST_ELEMENTS_HEURISTIC );
63+
out = [];
6464
for ( i = 0; i < MAX_FAST_ELEMENTS_HEURISTIC; i++ ) {
6565
out[ i ] = arr[ i ];
6666
}
6767
for ( i = MAX_FAST_ELEMENTS_HEURISTIC; i < len; i++ ) {
6868
out.push( arr[ i ] );
6969
}
7070
} else {
71-
out = new Array( len );
71+
out = [];
7272
for ( i = 0; i < len; i++ ) {
7373
out[ i ] = arr[ i ];
7474
}
@@ -89,7 +89,7 @@ function copy2( arr ) {
8989
var i;
9090

9191
len = arr.length;
92-
out = new Array( len );
92+
out = [];
9393
for ( i = 0; i < len; i++ ) {
9494
out[ i ] = arr[ i ];
9595
}

lib/node_modules/@stdlib/assert/is-even/examples/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
/* eslint-disable no-new-wrappers */
20-
2119
'use strict';
2220

2321
var Number = require( '@stdlib/number/ctor' );

lib/node_modules/@stdlib/assert/is-finite-array/examples/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
/* eslint-disable no-new-wrappers */
20-
2119
'use strict';
2220

2321
var Number = require( '@stdlib/number/ctor' );

lib/node_modules/@stdlib/assert/is-finite/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
/* eslint-disable no-new-wrappers, stdlib/no-redeclare */
19+
/* eslint-disable stdlib/no-redeclare */
2020

2121
'use strict';
2222

0 commit comments

Comments
 (0)