Skip to content

Conversation

@guan404ming
Copy link
Member

@guan404ming guan404ming commented Jun 20, 2025

Related Issue

#51735
cc @pierrejeambrun @bbovenzi

Why

The original perfectionist can't handle json files properly in public folder.

How

  • add eslint-plugin-jsonc to handle translation related json files lint
  • remove unused rules in i18n
image

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Jun 20, 2025
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

We recently added jsonc-eslint-parser and chose to use this lib to enable parsing of json for eslint. Can you try to use it as well or maybe move everything to eslint-plugin-jsonc if not possible. (jsonc-eslint-parser was around for a longer period of time and seems more flexible, but no strong opinion here)

Also I'm surprised, it means that all our translation files are properly sorted by key, what's enforcing that ? (prettier maybe ?)

@guan404ming
Copy link
Member Author

guan404ming commented Jun 20, 2025

It looks like:

  • jsonc-eslint-parser is a parser for JSON, JSONC, and JSON5, meant to be used with ESLint plugins.
  • eslint-plugin-jsonc is an ESLint plugin specifically for handling JSON, JSONC, and JSON5 files.

So, if an ESLint plugin needs to parse our JSON files, we should be using a JSON parser like jsonc-eslint-parser like how we use in i18nRules. Let me know if I'm mistaken, thanks!

Also I'm surprised, it means that all our translation files are properly sorted by key, what's enforcing that ? (prettier maybe ?)

It’s ESLint. We used the perfectionist plugin at that time but it doesn't work when files are in public folder

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

yes I think we should use jsonc-eslint-parser everywhere if possible. If not then eslint-plugin-jsonc.

@potiuk
Copy link
Member

potiuk commented Jun 21, 2025

yes I think we should use jsonc-eslint-parser everywhere if possible. If not then eslint-plugin-jsonc.

agree

@guan404ming
Copy link
Member Author

guan404ming commented Jun 22, 2025

I've decided to keep both since:

  • jsonc-eslint-parser is used by our custom plugin to check translation completeness via ESLint.
  • eslint-plugin-jsonc helps enforce translation key sorting and has auto-fix function built in.

We could consider implementing custom logic for sorting keys ourselves, which would allow us to rely solely on the parser. However, that would likely introduce additional complexity to the workflow. Let me know if you think it's worth consolidating or if I mistaken anything, but for now I feel keeping both is the more practical choice.

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

Thanks

@pierrejeambrun
Copy link
Member

pierrejeambrun commented Jun 23, 2025

I've decided to keep both since:
jsonc-eslint-parser is used by our custom plugin to check translation completeness via ESLint.
eslint-plugin-jsonc helps enforce translation key sorting and has auto-fix function built in.

Also after some more research it appears we need both. Thanks

@pierrejeambrun pierrejeambrun merged commit bd1883d into apache:main Jun 23, 2025
50 checks passed
@guan404ming
Copy link
Member Author

guan404ming commented Jun 23, 2025

Also after some more research it appears we need both. Thanks

Thanks for the review and research.

@guan404ming guan404ming deleted the json-key-sort branch June 23, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants