JavaScript gadget – show LintErrors analysis (Parsoid messages) live.

Purpose

Problems in wikitext detected by Parsoid and managed via Special:LintErrors for entire namespaces may be retrieved for a particular page view, and wikitext sequences may be checked interactively.

The Linter Extension is structured by error type only and may be filtered by namespace.

When visiting a particular page, this gadget can inform about all current error types immediately, and users interested in syntax improvement are encouraged to remedy right now.

Usage

mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&maxage=86400&ctype=text/javascript" );

Default behaviour

In wiki main space (e.g. Wikipedia articles) on regular view or during source text editing of a page a yellow button is offered in top right corner, that triggers an analysis.

If problems were detected a large yellow box is inserted in top region of the page.

The yellow box contains a table of errors.

If pages are not used for viewing nor editing, but e.g. history, info etc., no action is taken. Note that only wikitext pages may be subject to investigation.

On Special:ExpandTemplates the facility is always offered.

Error table

If any, the table looks as follows:

lint +
category title DIV

There are detectable error types which are not yet in Linter categories. Choose later option to include them into table.

Limitations

LintHint does not expand transclusions that start with slash. For example, if on page Portal:Myportal the wikitext includes ((/Box-header)), this really means ((Portal:Myportal/Box-header)), but lintHint does not make this conversion. To force lintHint to analyze such transcluded pages, insert the full page name (Portal:Myportal in this example) before the slash in transclusion calls that start with slash. You can do this in an edit session to discover the identity and location of lint errors, possibly in other templates, fix the lint errors there, and not save the edit session where you inserted the full page names.

LintHint sometimes shows two or more errors in the same location on the page when there is only one problem to fix. To work around this limitation, fix as many problems as you can find, then run LintHint again. Repeat the process until LintHint shows no more errors.

Control page

On a virtual page some version information is shown, if gadget is active.

Two interactive ways are offered for individual investigation:

  1. Input any wikitext sequence and check out.
  2. Enter a page name and get result of analysis, without a need to visit that page itself. Might be followed by a revision ID (“oldid”).

The result appears on the same page like on a regular page. Page names entered are reflected by clickable links and would be opened in a new window.

Quick interactive customization

Some options can be set interactively on Special:Blankpage as soon as the script has been loaded. On pages where the analysis report box appears, a button is offered in the top right corner, which opens such User:Gadgets in a new browser tab or window. The same goes for the control page.

When reloading a text page the preferences declared here come into effect.

Anonymous users can use this mode, too; options will be stored in browser profile rather than on wiki server.

This initial assignment may be overridden later on page by programmatic JavaScript. However, it is not recommended to mix both practises during initialization since a race condition would decide upon the final effect.

Configuration by JavaScript

Individual desire may be passed to the gadget at any time, best before loading if interactive costumization is not used.

The raw JavaScript code looks as follows:

// create a user defined object
var myLintHints = { };

// specify some object component
myLintHints.rooms = "-";

// communicate user defined object
mw.hook( "lintHint.config" ).fire( myLintHints );

// finally, load gadget
mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&maxage=86400&ctype=text/javascript" );

Currently the following options are available:

Name Type Default Meaning
rooms Array
string
[ 0 ]
  • Array with namespace numbers, where analysis should be available.
  • "*" – all namespaces
  • "-" – no page analysis, but individual requests on control page.
oldid boolean false
  • Analyze previous revisions, too.
  • Otherwise only current page version will support analysis.
(later) boolean false Show also error types not yet in Linter categories. Needed only when encountered the first time, then memorized and not longer unknown.
launch boolean false Run analysis automatically in rooms rather than manual triggering by button.
layer boolean MediaWiki default Converted source edit links on LintErrors special page into ParserMigration edit.

Since ParserMigration is not active any longer, this option is pointless until any ParserMigration will be established again.

lazy boolean false Suppress small label if no error detected.

Further options will be considered when lint system grows.

Multiple calls of mw.hook("lintHint.config") will not influence other components that were set before, if not explicitly changed.

LintErrors special page

Special:LintErrors categories will make tables sortable, until Mediawiki provides this feature (see phab:T151282).

As with all pages, currently there is no table sorting on mobile.

Links to text pages might be chosen to start either common action=edit or parsermigration explicitly.

Wikisource

On wikisource projects the two namespaces Page: and Index: get specific support:

The remaining form fields are rather tiny. If a problem is hiding tenacious from your eyes you may drop it into control page wikitext input.

New categories

At a quite early stage of execution the gadget needs to know which error types may occur, since the explaining system messages are to be retrieved.

Compatibility

The following tools are recognized and supported:

Version 3 as of May 2018

Some major changes:

Internationalization

Not really required for gadget itself, but support on control page by a few lines.

Suggestions on foreign languages may be offered, as well as a translation of this page.

Codes

Source code
ResourceLoader
Namespaces
Cookies localStorage
mw.libs lintHint
mw.hook
MediaWiki 1.30

A test page tells how to check for proper functionality.