Page MenuHomePhabricator

Allow extensions to add lint errors
Open, MediumPublic

Description

In a Mastodon post, @ssastry said:

Related but tangentially, for a while now, I have been thinking that perhaps most of the Linter (analysis) code in Parsoid should actually be move out of core Parsoid. There is really nothing special about what Parsoid does in the Linting analysis. It just analyzes the DOM. Except for some types of lints that need information from tokenizing, these code be done in an extension or an external tool.
But, there are probably some product features and reasons why certain kinds of lints would need to be done synchronously (Parsoid or an extensions) rather than by an external tool. Ex: DiscussionTools.
However, it should be possible for external tools to analyze pages and post lints to the linter api which opens the possibility for bots and other tools to add more project-specific linting abilities.

I replied:

yes!! I was actually going to file a bug about 1) allowing extensions to add Lint errors during parse so it doesn't all need to be in Parsoid

  1. after that, allowing Lua modules to add Lint errors (e.g. T304309).

I worry about having truly external tools add lint errors just because the update frequency may not be what editors want...but I think that if extensions + Lua could do it, most of the use-case would be addressed

It may make sense to block this task on T330725: Merge Linter extension into MediaWiki core or not, mostly depends on whether this functionality is going to be in Parsoid or MediaWiki core.

Event Timeline

Has consideration also been given to allowing Extensions (as opposed to Lua Modules) to create/raise specfic LintErrors on subpages in respect of the specialised syntax those extensions use?

Some example use cases:-

*<section> and <pages> tags (Extension:Proofread Page, Extension:Labeled_Section_Transclusion). As these are not HTML tags, there are not necessarily seen by the linter, but absent, mismatched tags create tiresome issues when peforming transclusion on Wikisource.
*TEx syntax errors (generated from Extension:Math) could be reported via a MathErrors subpage as opposed to the current 'error' category approach.
*<ref> and <reflist> tags (Extension:Cite) - Examples being follow tags without a named ref, no references list for a group and so on, which are currently handled by an error category approach.

Change 908671 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] Lint away format being used in gallery media options

https://gerrit.wikimedia.org/r/908671

Change 908671 abandoned by Arlolra:

[mediawiki/services/parsoid@master] Adds a method to the extension API to record lint errors

Reason:

https://gerrit.wikimedia.org/r/908671

Arlolra triaged this task as Medium priority.Aug 21 2023, 8:59 PM
Arlolra moved this task from Backlog to General / Tech Debt on the MediaWiki-extensions-Linter board.

CCing myself on this as I'm investigating add'l lints meant for editing microtasks :D

(cf T344378 for mobile editing microtasks missing alt text planning, we're doing a test spike using linter)