Skip to content

docs(@stdlib/math/base/tools/evalpoly-compile): use relative require path in example#12401

Closed
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-lint-evalpoly-compile-examples-2026-05-31
Closed

docs(@stdlib/math/base/tools/evalpoly-compile): use relative require path in example#12401
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-lint-evalpoly-compile-examples-2026-05-31

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

Resolves #12359.

Description

This pull request:

  • Replaces the unnecessary tryRequire-based loading pattern in
    @stdlib/math/base/tools/evalpoly-compile/examples/index.js with
    a direct require( './../lib' ), resolving the
    stdlib/require-last-path-relative ESLint violation that causes
    the lint_random_files workflow to fail on develop.

Failing run: https://github.com/stdlib-js/stdlib/actions/runs/26668990373
(2026-05-30T00:34 UTC)

Symptom: stdlib/require-last-path-relative error at
examples/index.js:23 — the last require() call in AST order was
require('@stdlib/utils/try-require'), a non-relative path.

Root cause: The example used the tryRequire guard pattern, which
is intended for packages with optional native addons that may fail to
compile. evalpoly-compile is pure JavaScript: its lib/ directory
contains only index.js, main.js, and templates/; it has no
binding.gyp, no native source, and empty dependencies and
devDependencies. The guard is therefore both unnecessary and
counter-productive — the tryRequire( resolve( __dirname, '..', 'lib' ) )
call is not a require() call per the rule's AST traversal, so it
does not reset the "last require" pointer, leaving
require('@stdlib/utils/try-require') as the final flagged path.

Fix: Remove path, @stdlib/utils/try-require, the error guard,
and the main() wrapper. Load the package with require( './../lib' ),
which is both the correct relative-path form and the convention used
by sibling packages such as @stdlib/math/base/tools/evalpoly.

Related Issues

This pull request has the following related issues:

Questions

No.

Other

Validation: Fix reviewed by three independent agents prior to commit.

  • Reviewer A (correctness, Opus): approve — confirmed require('./../lib') resolves correctly, tryRequire is genuinely unnecessary for a pure-JS package, and observable example output is preserved.
  • Reviewer B (regression scope, Opus): approve — only examples/index.js changed; tests do not import examples; no platform-specific behavior change; diff is minimal.
  • Reviewer C (style + conventions, Sonnet): approve'./../lib' satisfies the lint rule (starts with ./); copyright header preserved; spacing, var declarations, and comment style match stdlib conventions and sibling example.

Note: @stdlib/math/base/tools/evalrational-compile has an
identical tryRequire pattern in its example file and will trigger
the same lint rule in a future automated run. That file is out of
scope for this PR (no open failure event) but warrants a follow-up.

Checklist

AI Assistance

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was authored by Claude Code as part of an automated CI-failure
triage routine. Root-cause analysis, fix, three-agent validation, and
commit were produced by the agent; the diff was reviewed against the
ESLint rule implementation and sibling package examples before being
staged.


@stdlib-js/reviewers


Generated by Claude Code

…path in example

The `lint_random_files` workflow (develop, 2026-05-30T00:34 UTC, run
26668990373) flagged `stdlib/require-last-path-relative` at line 23 of
`evalpoly-compile/examples/index.js`. The last `require()` call in AST
order was `require('@stdlib/utils/try-require')`, a non-relative path.

The `evalpoly-compile` package is pure JavaScript: no `binding.gyp`, no
native source, and empty `dependencies`/`devDependencies`. The
`tryRequire` guard was included by analogy with native addon packages
but is unnecessary here. Replacing it with a direct
`require('./../lib')` aligns the example with the sibling `evalpoly`
package and satisfies the lint rule.

Ref: https://github.com/stdlib-js/stdlib/actions/runs/26668990373
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Good First PR A pull request resolving a Good First Issue. labels May 31, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/tools/evalpoly-compile $\color{green}210/210$
$\color{green}+100.00\%$
$\color{red}41/42$
$\color{green}+97.62\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}210/210$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

Copy link
Copy Markdown
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already rejected this change in a separate PR. See it for explanation.

@kgryte kgryte closed this May 31, 2026
@kgryte kgryte deleted the philipp/ci-fix-lint-evalpoly-compile-examples-2026-05-31 branch May 31, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Math Issue or pull request specific to math functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix JavaScript lint errors

4 participants