Skip to content

feat(cli): add --output-prefix option to customize compiled file headers#2377

Merged
andrii-bodnar merged 9 commits intolingui:mainfrom
Gamote:main
Dec 10, 2025
Merged

feat(cli): add --output-prefix option to customize compiled file headers#2377
andrii-bodnar merged 9 commits intolingui:mainfrom
Gamote:main

Conversation

@Gamote
Copy link
Contributor

@Gamote Gamote commented Dec 5, 2025

Description

This PR adds support for customizing the output prefix (header) in compiled message catalogs through a new --output-prefix CLI option.

Currently, Lingui hardcodes /*eslint-disable*/ at the top of compiled files. This change allows projects to specify custom prefixes for generated files, making it easier to integrate with different tools like linters, coverage tools, or formatters that rely on header directives.

Usage:

# Use default (/*eslint-disable*/)
lingui compile

# Use custom prefix for Oxlint
lingui compile --output-prefix "/*oxlint-disable*/"

# Use custom prefix for Biome
lingui compile --output-prefix "/*biome-ignore lint: auto-generated*/"

# No prefix at all
lingui compile --output-prefix ""

Changes:

  • Added outputPrefix option to CreateCompileCatalogOptions type
  • Updated createCompiledCatalog function to accept and use the custom prefix with default value '/*eslint-disable*/'
  • Added CLI option --output-prefix <prefix>
  • Passed the option through the compilation pipeline from CLI to the final output
  • Updated documentation to reflect the new option name and usage

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Checklist

@vercel
Copy link

vercel bot commented Dec 5, 2025

@Gamote is attempting to deploy a commit to the Crowdin Team on Vercel.

A member of the Team first needs to authorize it.

@Gamote Gamote changed the title feat(cli): add --file-header-directive option to customize compiled file headers feat(cli): add --lint-directive option to customize compiled file headers Dec 5, 2025
@vercel
Copy link

vercel bot commented Dec 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
js-lingui Ready Ready Preview Dec 5, 2025 2:52pm

Copy link
Contributor

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution, @Gamote! It looks useful!

Could you also please update the documentation? It would be great to include value examples for popular linters like Oxlint in your case or Biome.

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.35%. Comparing base (6bb8983) to head (a3ecda5).
⚠️ Report is 239 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2377      +/-   ##
==========================================
- Coverage   77.05%   76.35%   -0.70%     
==========================================
  Files          84      100      +16     
  Lines        2157     2660     +503     
  Branches      555      695     +140     
==========================================
+ Hits         1662     2031     +369     
- Misses        382      505     +123     
- Partials      113      124      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Gamote Gamote requested a review from andrii-bodnar December 5, 2025 14:56
@Gamote
Copy link
Contributor Author

Gamote commented Dec 5, 2025

Thank you for the contribution, @Gamote! It looks useful!

Could you also please update the documentation? It would be great to include value examples for popular linters like Oxlint in your case or Biome.

@andrii-bodnar Sure thing, good call. I just pushed clear documentation and working examples.
I have also pushed unit and integration tests for the new --lint-directive.

@timofei-iatsenko
Copy link
Collaborator

IMO, looks a bit overcoupled to the usage. Would it be better to just have "prefix / suffix" ? Than it is not coupled and user could do whatever and don't break the semantics.

@andrii-bodnar
Copy link
Contributor

IMO, looks a bit overcoupled to the usage. Would it be better to just have "prefix / suffix" ? Than it is not coupled and user could do whatever and don't break the semantics.

If think about a more generic solution, do some other use-case is possible except lint directive? Is there any use-case for having a suffix there as well?

@timofei-iatsenko
Copy link
Collaborator

Ignoring by prettier, which is semantically not a linter. Instanbul coverage ignoring and so on.

Not sure about "suffix", but something like header or prefix would be definetily more semantically correct solution then narrowing it to the --lint-directive

@Gamote
Copy link
Contributor Author

Gamote commented Dec 8, 2025

Ignoring by prettier, which is semantically not a linter. Instanbul coverage ignoring and so on.

Not sure about "suffix", but something like header or prefix would be definetily more semantically correct solution then narrowing it to the --lint-directive

I can see how that can be useful, also the suffix could be of help if there are tools that need to mark the start and end.

How about --output-prefix and --output-suffix? With --output-prefix default being /*eslint-ignore*/ to preserve the current behaviour. (@andrii-bodnar @timofei-iatsenko)

If this is something you want I can updated the code, tests and docs.

@andrii-bodnar
Copy link
Contributor

For now, I would suggest adding only the prefix. We can introduce a suffix later if necessary.

@Gamote
Copy link
Contributor Author

Gamote commented Dec 9, 2025

@andrii-bodnar I have pushed the refactoring, updated the docs, the tests and the PR title and description.

Can you please review the changes?

@Gamote Gamote changed the title feat(cli): add --lint-directive option to customize compiled file headers feat(cli): add --output-prefix option to customize compiled file headers Dec 9, 2025
@timofei-iatsenko
Copy link
Collaborator

@andrii-bodnar @Gamote LGTM

Copy link
Contributor

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

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

Looks also good to me, @Gamote thank you!

@andrii-bodnar andrii-bodnar merged commit ef77310 into lingui:main Dec 10, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants