Skip to content

feat: added a JSON handler/fixer - #165

Merged
Berkmann18 merged 15 commits into
masterfrom
json-fixer
May 20, 2019
Merged

Berkmann18 merged 15 commits into
masterfrom
json-fixer

Conversation

@Berkmann18

@Berkmann18 Berkmann18 commented Feb 7, 2019 •

Copy link
Copy Markdown
Member

What:
Adds a JSON file handler that includes a fixer (not advanced but good so far).

Why:
To help in resolving all-contributors/app#102 (TL; DR: malformed configuration file error logging + auto-fix).

How:
Harnesses jsonlint to do the following process:

  1. Check the JSON data
  2. If step 1 succeeds then return the parsed data then go to step 5
  3. If step 1 fails, do the following:
    3.a. Output an informative error
    3.b. Remove the problematic character then go to step 4
  4. Do step 1 then output a "The JSON data was fixed!" or "There's still an error!" with respectively the parsed JSON data returned or the error message thrown
  5. Go to the next task

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

Added a module that will check JSON files and give a good level of details for errors while
attempting to fix it

re all-contributors/app#102
@Berkmann18 Berkmann18 added type: feature A new feature or capability status: in progress Someone is working on this priority: medium Normal priority labels Feb 7, 2019
Made the fixer a bit more concise and added the fields to allow for an auto-update of the config
file (if it was changed)
@Berkmann18

Berkmann18 commented Feb 7, 2019 •

Copy link
Copy Markdown
Member Author

Note (as of the d5f769 commit): the CLI, when given an argument (say check) goes to the prompt menu as if it didn't receive any options after fixing the malformed .all-contributorsrc file.
I haven't tested this scenario when not passing any arguments or using other commands yet tho.

Update: using add (e.g: add Berkmann18 code on a test repo) lead to the same behaviour. However, when no arguments are provided, it works as intended where it will indicate what the error is and if it was fixed or not then ask the "What do you want to do?" question.

@Berkmann18

Berkmann18 commented Mar 1, 2019 •

Copy link
Copy Markdown
Member Author

Note: using JSON5 might make it easier to work with invalid JSON files.
@jakebolam @sinchang Thoughts?

@Berkmann18 Berkmann18 changed the title feat: added a JSON handler/fixer [WIP] feat: added a JSON handler/fixer Mar 21, 2019
@Berkmann18
Berkmann18 requested a review from a team May 19, 2019 19:00
@Berkmann18 Berkmann18 added status: review needed and removed status: in progress Someone is working on this labels May 19, 2019
@Berkmann18 Berkmann18 added status: accepting prs Accepted and ready to be worked on and removed status: review needed labels May 20, 2019
@Berkmann18
Berkmann18 merged commit ebff1e8 into master May 20, 2019
@Berkmann18
Berkmann18 deleted the json-fixer branch May 20, 2019 08:47
@all-contributors-release-bot

Copy link
Copy Markdown
Member

🎉 This PR is included in version 6.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: medium Normal priority status: accepting prs Accepted and ready to be worked on type: feature A new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants