Adjacent idea to T394964: Allow customization of linting rules in CodeMirror
Background
In-browser linting is great because it is fast. However for JavaScript, CSS, and of course wikitext, MediaWiki has an additional layer of linting for each of these content models. For sanitized-css specifically, violations would prevent the edit from being saved. It'd be great to surface these linting errors to users without requiring them to save or even preview.
In T190114 it was suggested to have the Web Workers poll the server instead of doing clientside processing, but it is believed this might be too slow for some users. Perhaps we could have both clientside and serverside linting.
Potential solutions
- Allow API-powered linters to run in parallel with the existing JS worker linters
- Add preferences to selectively toggle linters on/off
- Add a button and/or keyboard shortcut to do a "full lint" of the code, if the API is too slow to query continuously
Checklist
- T407153: API-powered linting for wikitext using Parsoid
- T407154: API-powered linting for JavaScript using Peast
- API-powered linting for Sanitized CSS
- API-powered linting for Scribunto
For CSS, work needs to be done to have css-sanitizer and/or TemplateStyles return the violations in a structured format. See T190114. So proper server-side linting of sanitized CSS via an API is currently not possible. We can do some things with Stylelint, such as r1190686 which warns about vendor prefixes (which are disallowed in sanitized CSS).