-
-
Notifications
You must be signed in to change notification settings - Fork 997
chore: fix JavaScript lint errors (issue #8759) #8766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: fix JavaScript lint errors (issue #8759) #8766
Conversation
This commit fixes lint errors in the aversin-by test file by adding eslint-disable-line comments for intentional sparse array creation using the new Array() constructor. The sparse arrays are needed for testing the function's behavior with arrays containing holes. Ref: stdlib-js#8759 --- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
This commit fixes lint errors by replacing `new Array(5)` with `filled(void 0, 5)` from `@stdlib/array/base/filled` in the aversin-by test files. The `stdlib/no-new-array` rule prohibits using the `new Array()` constructor. The `filled` utility provides the same functionality for creating arrays filled with undefined values to test accessor behavior with missing values. Ref: stdlib-js#8759 --- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
Coverage Report
The above coverage report was generated for the changes in this PR. |
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
kgryte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, the use of the Array constructor was desired in order to intentionally create sparse arrays, so the lint errors were false positives. I went ahead and simply disabled the lint rule for the offending lines.
Resolves #8759.
Description
This pull request:
stdlib/no-new-arraylint errors in@stdlib/math/strided/special/aversin-bytest files by replacingnew Array(5)constructor calls withfilled(void 0, 5)using the@stdlib/array/base/filledutility.Related Issues
This pull request has the following related issues:
Questions
No.
Other
The original lint errors occurred because the
stdlib/no-new-arrayESLint rule prohibits the use of thenew Array()constructor.Initially, I considered using inline
eslint-disable-linecomments to suppress the warnings. However, this approach was not appropriate because:new Array(n)creates sparse arrays with unexpected behaviorThe correct solution uses
@stdlib/array/base/filledutility to create arrays filled withundefinedvalues. This approach:undefinedvalues rather than empty slotsundefinedvaluesChanges made:
test/test.main.js: Addedfilledimport and replacednew Array(5)withfilled(void 0, 5)at lines 78 and 86test/test.ndarray.js: Addedfilledimport and replacednew Array(5)withfilled(void 0, 5)at lines 77 and 85Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
I consulted AI to understand the stdlib codebase conventions and to research the appropriate way to fix the lint errors while following project standards.
@stdlib-js/reviewers