Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LF-3085: Add a linter for translations files #3020

Merged
merged 3 commits into from
Dec 7, 2023

Conversation

SayakaOno
Copy link
Collaborator

@SayakaOno SayakaOno commented Nov 30, 2023

Description

I found that some checks are already running against json files in pre-commit. I assumed asking translators to do npm install to run pre-commit would not be a good idea and decided to add a github workflow so that we will not be able to merge PRs that have invalid JSON files.

  • install eslint-plugin-json
  • update .eslintrc.json to use eslint-plugin-json
  • create a github workflow

Jira link: https://lite-farm.atlassian.net/browse/LF-3085

Type of change

  • Bug fix (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)
  • This change requires a documentation update

How Has This Been Tested?

Created PRs with:

  • trailing comma
{
  ...,
  {
    "TEST": "test",
  }
  ...
}
  • double commas
{
  ...,
  {
    "TEST": "test",,
    "TEST2": "test"
  }
  ...
}
  • invalid characters (E2809C)
{
  ...,
  {
    "TEST": “test”
  }
  ...
}

Screenshot 2023-11-30 at 4 54 46 PM

Screenshot 2023-11-30 at 4 55 35 PM

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

@SayakaOno SayakaOno force-pushed the LF-3085/Add_a_linter_for_translations_files branch 22 times, most recently from 1441653 to 2ffd003 Compare December 1, 2023 00:18
@SayakaOno SayakaOno force-pushed the LF-3085/Add_a_linter_for_translations_files branch from 63ce6b7 to 0ec9f95 Compare December 1, 2023 00:32
@SayakaOno SayakaOno force-pushed the LF-3085/Add_a_linter_for_translations_files branch from 0ec9f95 to 69db8b7 Compare December 1, 2023 00:38
@SayakaOno SayakaOno self-assigned this Dec 1, 2023
@SayakaOno SayakaOno added the enhancement New feature or request label Dec 1, 2023
@SayakaOno SayakaOno force-pushed the LF-3085/Add_a_linter_for_translations_files branch from 49f32ab to 69db8b7 Compare December 1, 2023 00:56
@SayakaOno SayakaOno marked this pull request as ready for review December 1, 2023 00:58
@SayakaOno SayakaOno requested review from a team as code owners December 1, 2023 00:58
@SayakaOno SayakaOno requested review from antsgar and kathyavini and removed request for a team December 1, 2023 00:58
@SayakaOno
Copy link
Collaborator Author

Tested from a forked repo, and it worked as expected:
Screenshot 2023-12-04 at 9 46 04 AM

Copy link
Collaborator

@kathyavini kathyavini left a comment

Choose a reason for hiding this comment

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

Ohhh okay I totally missed the most important part of what you were saying this morning about how it shows a bunch of errors 😄 I didn't catch that it lists all the errors and there is no subsequent auto-fixing capability for this package!

Well it's a great improvement in terms of safety and that's awesome that it works for forks! I'm still curious if it can be bypassed by using the GitHub editor UI, but I think we could also resolve to never do that for translation files in the future 😁

@SayakaOno
Copy link
Collaborator Author

Thank you @kathyavini!
I just tried adding invalid JSON from GitHub UI. All checks ran, and the issue was caught if that's what you were wondering!

@kathyavini
Copy link
Collaborator

@SayakaOno I was thinking specifically the merge conflict editor -- although I didn't write that very clearly at all! -- because I wasn't sure if hitting submit on that triggers a pull_request action workflow. Is that what you did your editor test on?

@SayakaOno
Copy link
Collaborator Author

I suggested a change against my PR, committed the change and it triggered the checks... When you resolve conflicts, you make a commit (I think...), so I'm assuming the same thing will happen...🤞

Copy link
Collaborator

@navDhammu navDhammu left a comment

Choose a reason for hiding this comment

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

Looks good!

@kathyavini kathyavini merged commit 8d74662 into integration Dec 7, 2023
5 of 6 checks passed
kathyavini added a commit that referenced this pull request Dec 8, 2023
Conflicts were generated when PR #3020 was merged, which installed eslint-plugin-json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants