feat(sage-monorepo): validate and format JSON files with ESLint-Prettier #2791
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2789
Description
Currently, JSON files are formatted on save in VS Code using the Prettier extension for VS Code. However, we currently don't have a solution to format these files using a CLI. This is required if we want to validate these files via git hooks and the CI/CD workflow.
The solution explored in this PR is to validate and format JSON, JSONC and JSON5 files with ESLint, which delegate the validation and formatting to Prettier. The solution should also work well in VS Code with live validation and formatting on save.
Changelog
.eslintignore
(deprecated)References
Notes
The root
.eslintrc.json
has the following line:This prevents ESLint from linting files in the root folder. This instruction needs to be inversed in an
.eslintrc.json
of a folder so that ESLint validate its content (recursively).E.g.,
libs/agora/services/.eslintrc.json
starts with:This change enable to include the root folder but nothing else (see this comment):