Update ESLint configuration for json5 files#2317
Conversation
|
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. |
553419c to
1208385
Compare
dbcd5d0 to
7d8bb75
Compare
|
@alanorth some tests failing but a rebase will probably fix them i imagine. i'll give this a check |
7d8bb75 to
9508498
Compare
|
Thanks @kshepherd. I've rebased on latest |
a4302aa to
55c9ca5
Compare
|
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 Finally, in my opinion this must update the current JSON5 files...otherwise the |
Thanks @tdonohue. Well spotted! We need to keep one, as the
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:
Those are easily and automatically fixable so I think it's worth being consistent. |
bb615a3 to
85a4628
Compare
|
I think the stricter empty lines checks are causing the language files (including those newly updated by i18n-sync) to fail the new check, right? So if we want this PR to pass all the checks we might have to include refactored *.json5 files as part of it, or as a separate PR to merge first? |
The eslint-plugin-jsonc has a recommended configuration for json5. See: https://ota-meshi.github.io/eslint-plugin-jsonc/user-guide/#usage
The eslint-plugin-jsonc documentation recommends turning ESLint's own no-irregular-whitespace plugin off for JSON files in favor of its own jsonc/no-irregular-whitespace plugin. See: https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-irregular-whitespace.html
This seems to have been added twice at some point.
|
Hey @kshepherd. Yes, the tests were failing because of the stricter rules. Perhaps I shouldn't have introduced the comma and whitespace rules, as those are out of the scope. The main issue I want to solve here is that we are mixing and matching tooling for JSONC and JSON5, which causes the bug in #2309. I will re-work this to focus on that. |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin dspace-7_x
git worktree add -d .worktree/backport-2317-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-2317-to-dspace-7_x
git switch --create backport-2317-to-dspace-7_x
git cherry-pick -x 3a057332569cbc7fd5032eb20b0309bd8e66eccd 5e8571de80b071b2e331e217d2d07a4f9c42f425 9896eab6ac096849ac576fdd75802f3b1821ac9d |
|
Successfully created backport PR for |
|
@alanorth : The backport to 8.x went smoothly, but the backport to 7.x failed (likely just a small code conflict, as the code in 7.x looks similar). If you have time, feel free to create a 7.x version of this PR & I'll get it merged. |
References
Description
Update the ESLint configuration for json5 files.
Instructions for Reviewers
List of changes in this PR:
plugin:jsonc/recommended-with-json5instead ofplugin:jsonc/recommended-with-jsoncjsonc/no-irregular-whitespaceplugin instead of ESLint'sno-irregular-whitespaceChecklist
npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.