Skip to content

docs: use relative require path in evalpoly-compile example#12372

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

docs: use relative require path in evalpoly-compile example#12372
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-lint-evalpoly-compile-examples-2026-05-30

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

@Planeshifter Planeshifter commented May 30, 2026

Resolves #12359.

Description

What is the purpose of this pull request?

This pull request:

  • Replaces the unnecessary tryRequire-based package loading in
    @stdlib/math/base/tools/evalpoly-compile/examples/index.js with
    a direct require( './../lib' ) call, fixing the
    stdlib/require-last-path-relative lint violation that caused the
    automated JavaScript lint workflow to fail on develop.

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

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

Root cause: The example used the tryRequire pattern (intended for
packages with optional native addons that may fail to compile). The
evalpoly-compile package is pure JavaScript: its lib/ directory
contains only index.js, main.js, and templates/; it has no
native source, no native dependencies, and no build artifacts. The
tryRequire guard was therefore both unnecessary and counter-productive
— it made the last visible require() a non-relative path, triggering
the lint rule. The tryRequire( resolve( __dirname, '..', 'lib' ) )
call is not a require() call per the rule's AST check, so it does not
reset the "last require" pointer.

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

This matches example in README.md.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Validation: The fix was reviewed by three independent agents prior to
commit. Reviewer C (style/conventions) caught that the initial draft used
require( '..' ), which does not satisfy isRelativePath (the rule
checks for './' or '../' prefix). The fix was corrected to
require( './../lib' ) — consistent with sibling packages and
unambiguously a relative path — before the commit was staged.

The evalrational-compile package 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 (separate failure
event) but warrants a follow-up.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of 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

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

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


@stdlib-js/reviewers


Generated by Claude Code

The automated JavaScript lint workflow on develop (run 26668990373)
reported a `stdlib/require-last-path-relative` violation at line 23
in `@stdlib/math/base/tools/evalpoly-compile/examples/index.js`. The
last `require()` call was `require('@stdlib/utils/try-require')`, a
non-relative path.

The file used the `tryRequire` pattern intended for packages with
optional native addons. `evalpoly-compile` is pure JavaScript with
no native dependencies, making the guard unnecessary. This commit
replaces `tryRequire`-based loading with `require('./../lib')` and
removes the unneeded `path` and `@stdlib/utils/try-require` imports,
matching the pattern in sibling packages (e.g., `evalpoly`).

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 30, 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.

@Planeshifter Planeshifter marked this pull request as ready for review May 30, 2026 15:39
@Planeshifter Planeshifter requested review from a team and kgryte May 30, 2026 15:39
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label May 30, 2026
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.

This PR is not desired. The tryRequire logic is intentional. Take a look at the implementation. How is this implementation supposed to run natively in a web browser? It cannot. Closing...

@kgryte kgryte closed this May 30, 2026
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label May 30, 2026
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