bench: fix RuleTester and custom-rule tests#10951
Closed
Planeshifter wants to merge 2 commits intodevelopfrom
Closed
bench: fix RuleTester and custom-rule tests#10951Planeshifter wants to merge 2 commits intodevelopfrom
Planeshifter wants to merge 2 commits intodevelopfrom
Conversation
Replace deprecated ESLint rule APIs with their modern equivalents to prepare for the ESLint v9 migration (see [1][2]): - `context.getSourceCode()` → `context.sourceCode` (100 files) - `context.getScope()` → `sourceCode.getScope(node)` (4 files) The `context.getSourceCode()` method was deprecated in ESLint v8.40.0 in favor of the `context.sourceCode` property. The `context.getScope()` method was deprecated in ESLint v8.38.0 in favor of `sourceCode.getScope(node)`, which takes an explicit node argument rather than relying on implicit traversal state. For `no-builtin-big-int`, the scope acquisition was moved from the `create` function (which previously captured the global scope once) into the `CallExpression` visitor, and `isImportedBigInt` was updated to walk up the scope chain to find `BigInt` declarations in outer scopes. Also fixes pre-existing lint violations in touched files: - Move `copyLocationInfo`, `locationInfo`, `checkComment`, `extractPackagePath`, `getAlias`, and `sortExpressions` from nested functions to module scope - Replace `.toUpperCase()`, `.toLowerCase()`, `.trim()` with stdlib equivalents - Fix variable declaration ordering No other deprecated APIs (`context.getAncestors`, `context.getDeclaredVariables`, `context.markVariableAsUsed`, deprecated comment/token access patterns) were found in the codebase. All rules with `context.options` already have proper `meta.schema`. [1]: https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/ [2]: https://eslint.org/docs/latest/use/migrate-to-9.0.0 Ref: stdlib-js/metr-issue-tracker#54 --- 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: na - 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 ---
Fix 9 pre-existing test failures across custom ESLint rules to ensure all 123 rule tests pass cleanly on ESLint v8: Rule fixes: - `doctest-marker`: replace `acorn-walk` with ESLint `sourceCode` APIs (`getTokenBefore`, `getNodeByRangeIndex`) to avoid deprecated `node.start`/`node.end` property access; add line-proximity check for orphaned annotation detection - `jsdoc-require-throws-tags`: replace `node.start`/`node.end` with `node.range[0]`/`node.range[1]` - `jsdoc-no-space-aligned-asterisks`: fix autofix regex replacement that incorrectly turned trailing whitespace into asterisks (use `$1` back-reference instead of literal `*`) Test fixture fixes: - `no-redeclare`: add `ecmaVersion: 2015` for `sourceType: 'module'` test case - `namespace-index-order`: reorder fixture entries to match alphabetical package path order - `require-last-path-relative`: match error message backtick quoting - `jsdoc-ordered-list-marker-value`: expect 4 errors (not 3) for newer `remark-lint-ordered-list-marker-value` - `jsdoc-doctest-marker`: remove undefined `stdlib/require-globals` from `eslint-disable-line` comments - `doctest-marker`: remove undefined `stdlib/no-builtin-math` from `eslint-disable-line` comments - `jsdoc-no-blockquote-without-marker`: use lazy continuation pattern and update error message for `remark-lint` v2 Ref: stdlib-js/metr-issue-tracker#54 --- 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: 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Progresses stdlib-js/metr-issue-tracker#54.
Description
This pull request:
acorn-walkwith ESLintsourceCodeAPIs indoctest-markerto avoid deprecatednode.start/node.endaccess.node.start/node.endwithnode.range[0]/node.range[1]injsdoc-require-throws-tags.jsdoc-no-space-aligned-asterisksthat incorrectly turned trailing whitespace into asterisks.ecmaVersion, corrects error messages, adjusts expected error counts for newer remark-lint, removes references to undefined stdlib rules ineslint-disable-linecomments, and updates patterns for remark-lint v2.Related Issues
This pull request has the following related issues:
Questions
No.
Other
Depends on #10950. All 123 custom rule tests now pass (0 failures).
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code. Each failing test was individually investigated, root-caused, and fixed.
@stdlib-js/reviewers