Repository navigation
fix(examples): fix lint failures in npm test and lb-eslint CLI resolution - #11840
Open
pranesh-sridhar wants to merge 4 commits into
Open
pranesh-sridhar wants to merge 4 commits into
pranesh-sridhar wants to merge 4 commits into
Conversation
pranesh-sridhar
requested review from
achrinza,
dhmlau and
raymondfeng
as code owners
October 16, 2026 13:38
dhmlau
approved these changes
Oct 21, 2026
dhmlau
left a comment
Member
There was a problem hiding this comment.
@pranesh-sridhar, thanks for the PR. LGTM.
ESLint 8.57+ restricts subpaths through its package exports map, so
require.resolve('eslint/bin/eslint') threw ERR_PACKAGE_PATH_NOT_EXPORTED and
lb-eslint crashed in every package. Fall back to resolving package.json and
building the absolute path from it.
Signed-off-by: pranesh-sridhar <68075088+pranesh-sridhar@users.noreply.github.com>
The 'this: Mocha.Context' parameter is misread by the mocha plugin as a done callback. Use an arrow function and set the timeout with .timeout() instead. Signed-off-by: pranesh-sridhar <68075088+pranesh-sridhar@users.noreply.github.com>
Typed linting failed to parse .eslintrc.js because it is not included in tsconfig.json, which made posttest lint fail. Signed-off-by: pranesh-sridhar <68075088+pranesh-sridhar@users.noreply.github.com>
Typed linting failed to parse .eslintrc.js because it is not included in tsconfig.json, which made posttest lint fail. Signed-off-by: pranesh-sridhar <68075088+pranesh-sridhar@users.noreply.github.com>
pranesh-sridhar
force-pushed
the
fix/examples-lint-eslint-cli-resolution
branch
from
October 22, 2026 06:50
016068e to
d035608
Compare
This branch has not been deployed
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.
Summary
Ran every project under
examples/through a localnpm test(fresh build, then mocha, thenposttestlint where defined) on Node v26.10.0. All 24 examples pass their mocha tests. Three examples failednpm testonly because of the lint step, andlb-eslintitself was broken in every package. This PR fixes those. (example-rpc-serverhad a fourth lint failure, but it was fixed upstream bya2d1e2deawhile this PR was open, so that change was dropped on rebase.)Findings and fixes
@loopback/buildlb-eslintcrashed in every package withERR_PACKAGE_PATH_NOT_EXPORTED. ESLint 8.57+ does not exposebin/eslintthrough itsexportsmap, sorequire.resolve('eslint/bin/eslint')fails.resolveCLInow falls back to resolving<pkg>/package.jsonand building the absolute path from it (packages/build/bin/utils.js).example-contextmocha/handle-done-callbackmisreadsthis: Mocha.Contextas adonecallback..timeout(5000).example-express-composition.eslintrc.js(not intsconfig.json)..eslintignorethat ignores.eslintrc.js.example-validation-app.eslintrc.jsparse error..eslintrc.jsto the existing.eslintignore.Test results
describe.skipin source)After the fixes:
npm testexits 0 forcontext,express-compositionandvalidation-app(re-verified after rebasing onto the latestmaster).run-eslintoverexamplesandpackages/buildexits 0.packages/buildtests still pass.Not changed (intentionally)
Running
lb-eslintdirectly inside other packages (for exampletodo,webpack,packages/http-server) still reports thethis: Mocha.Contextand.eslintrc.jserrors. The root.eslintrc.jsalready turnsmocha/handle-done-callbackoff for.tsfiles, CI lints from the root, and those packages do not run lint inposttest, sonpm testis unaffected. Making per-package lint match root lint would be a follow-up change to@loopback/eslint-config.Checklist
npm testpasses for every touched example