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

feat(sage-monorepo): validate and format JSON files with ESLint-Prettier #2791

Closed

Conversation

tschaffter
Copy link
Member

@tschaffter tschaffter commented Sep 4, 2024

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

  • Update VS Code settings to validate and format JSON, JSONC and JSON5 files with ESLint
  • Configure ESLint to validate JSON, JSONC and JSON5 files with Prettier
  • Remove .eslintignore (deprecated)

References

Notes

The root .eslintrc.json has the following line:

"ignorePatterns": ["**/*"],

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:

{
  "extends": ["../../../.eslintrc.json"],
  "ignorePatterns": ["!**/*"],

This change enable to include the root folder but nothing else (see this comment):

{
  "root": true,
  "ignorePatterns": ["**/*", "!/*"],

@tschaffter
Copy link
Member Author

Replaced by #2793

@tschaffter tschaffter closed this Sep 9, 2024
@tschaffter tschaffter deleted the sage-monorepo/review-eslint branch September 9, 2024 23:14
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.

[Story] Check ESLint consistency between IDE and CLI output
1 participant