dspace-angular
dspace-angular copied to clipboard
Update ESLint configuration for json5 files
References
- Related to #2306
- Closes #2309
Description
Update the ESLint configuration for json5 files to enforce a certain style that we can automatically verify and enforce for all future commits, pull requests, etc.
Note: after merging this, all i18n JSON5 files will need to be fixed using yarn lint --fix, or it can be done as part of this.
Instructions for Reviewers
List of changes in this PR:
- Use
plugin:jsonc/recommended-with-json5instead ofplugin:jsonc/recommended-with-jsonc - Use
jsonc/no-irregular-whitespaceplugin instead of ESLint'sno-irregular-whitespace - Use
no-multiple-empty-linesplugin to enforce one blank line in between content - Use
comma-spacingplugin to disallow content likethis ,
We need to decide:
- If the proposed configuration for
no-multiple-empty-linesis what we want, ie do we want to enforce one blank line as the standard to maintain human readability? - If I should apply
yarn lint --fixto all i18n JSON5 files as part of this pull request
Checklist
- [x] My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
- [x] My PR passes ESLint validation using
yarn lint - [x] My PR doesn't introduce circular dependencies (verified via
yarn check-circ-deps) - [x] My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
- [x] My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
- [x] If my PR includes new libraries/dependencies (in
package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation. - [x] If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
- [x] If my PR fixes an issue ticket, I've linked them together.
I will restart the discussion on this after DSpace 7.6 gets released. In that time it would be good to think about the irregular space rule and the one blank line rule so we can start enforcing style in CI lint tests.
@alanorth some tests failing but a rebase will probably fix them i imagine. i'll give this a check
Thanks @kshepherd. I've rebased on latest main and the tests are running now. Let's see...
It looks like this JSONC validation behavior was added in #2110 by @alexandrevryghem . So, it'd be good to verify that switching to JSON5 validation should have no side-effects. @alexandrevryghem : your feedback on this PR would be welcome.
@alanorth : I also notice we are still pulling in the eslint-plugin-jsonc plugin in .eslintrc.json here: https://github.com/DSpace/dspace-angular/blob/main/.eslintrc.json#L11 and https://github.com/DSpace/dspace-angular/blob/main/.eslintrc.json#L15 (strangely in two places). Should those be removed in this PR if we are no longer planning to use JSONC?
Finally, in my opinion this must update the current JSON5 files...otherwise the main branch will fail after we merge this. However, you can wait to update those JSON5 files until we agree on the proper rules.
@alanorth : I also notice we are still pulling in the eslint-plugin-jsonc plugin in .eslintrc.json here: main/.eslintrc.json#L11 and main/.eslintrc.json#L15 (strangely in two places). Should those be removed in this PR if we are no longer planning to use JSONC?
Thanks @tdonohue. Well spotted! We need to keep one, as the eslint-plugin-jsonc plugin is still providing the linting for JSON5. I will remove the other.
Finally, in my opinion this must update the current JSON5 files...otherwise the main branch will fail after we merge this. However, you can wait to update those JSON5 files until we agree on the proper rules.
Sounds good to me. The JSON5 validation in the first commit will fix #2309, while the following three propose a more consistent and slightly stricter style with regards to whitespace:
- Use
jsonc/no-irregular-whitespaceplugin instead of ESLint'sno-irregular-whitespaceat the plugin's recommendation - Use
no-multiple-empty-linesplugin to enforce one blank line in between content - Use
comma-spacingplugin to disallow content likethis ,
Those are easily and automatically fixable so I think it's worth being consistent.