Commit Graph

9 Commits

Author SHA1 Message Date
Sergei Zharinov 7df11ed734 chore(lint): add enforce-ts-extension oxlint rule (#42389)
* refactor(lint): extract custom oxlint rules into separate files

Split `tools/lint/rules.js` into one file per rule under
`tools/lint/rules/`. Also simplify `test-root-describe` with
early-exit guard clauses.

* feat(lint): add `enforce-ts-extension` oxlint rule

Add a custom JS-based oxlint rule that enforces `.ts` extensions on
local imports. The rule catches two problems:

- `.js` extension used instead of `.ts` (auto-fixable)
- missing file extension entirely (report only)

Checked locations:
- static import/export declarations
- dynamic `import()` expressions
- vitest module APIs: `vi.mock`, `vi.doMock`, `vi.unmock`,
  `vi.doUnmock`, `vi.importActual`, `vi.importMock`

Both relative paths (`./`, `../`) and path aliases (`~test/`)
are treated as local. Package imports are ignored.

Also fixes 26 pre-existing violations across 18 spec files.

* Update tools/lint/rules/enforce-ts-extension.js

Co-authored-by: Anne Stellingwerf <1637358+astellingwerf@users.noreply.github.com>

---------

Co-authored-by: Anne Stellingwerf <1637358+astellingwerf@users.noreply.github.com>
2026-04-07 15:36:16 +00:00
Michael Kriese e438887dfb build: lazy load and initialize logger (#41425)
* build: lazy load initialization modules

* build: lazy load and initialize logger

* chore: lint fix

* Update lib/constants/error-messages.ts

Co-authored-by: Jamie Tanna <jamie.tanna@mend.io>

* Apply suggestion

Co-authored-by: Jamie Tanna <jamie.tanna@mend.io>

---------

Co-authored-by: Jamie Tanna <jamie.tanna@mend.io>
2026-03-10 16:57:29 +00:00
Jamie Tanna 388e4f1151 test(logger): remove outdated comment (#41352)
Which should've been removed in
938829d5f4.
2026-02-21 11:19:19 +00:00
Jamie Tanna 938829d5f4 feat(logger): take function parameters into account for deduplication (#41333)
* feat(logger): take function parameters into account for deduplication

Previously, the `log.once` call would only take into account the "call
site" of the file + line number.

However, we have areas in the codebase (currently, and as part of future
changes) where we need to be able to call the `logger.once` functions
from the same line, but with different parameters.

We then need to make sure that the parameters are correctly passed in to
our `logOnceFn`, so we can then use them.

We use `safe-stable-stringify` to provide a more performant means to
stringify, and then hash the result to avoid large keys.

Because the `logger.once` should only be used with our logger, we can
also make the parameters required, and update tests accordingly.

Co-authored-by: Claude Sonnet 4.5 <jamie.tanna+github-copilot@mend.io>

* refactor: use explicit node import

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>

---------

Co-authored-by: Claude Sonnet 4.5 <jamie.tanna+github-copilot@mend.io>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2026-02-20 10:54:54 +00:00
Jamie Tanna ad6dc288e9 test(logger): clarify that logger.once doesn't use function parameters (#41331)
As part of future changes, we'll be looking at making so `logger.once`
can be called with different parameters, and each distinct set of
parameters will be used to check if we have already been called.

Before we do this, we should add a test to capture the current
behaviour, where the parameters are ignored.
2026-02-19 16:59:03 +00:00
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00
Trim21 6e5731b554 test: migrate from jest to vitest (#34499) 2025-02-26 14:18:38 +00:00
Michael Kriese 997c23502e test: migrate to vitest (#34475)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2025-02-26 09:35:54 +00:00
Sergei Zharinov 49cdaf2ac2 feat: Support for logging once per repo (#20168) 2023-02-03 07:00:58 +00:00