/* eslint-disable-next-line n/no-missing-require */
const { Text } = require( 'ext.CodeMirror.v6.lib' );
const lintSource = require( '../../../resources/modes/mediawiki/codemirror.mediawiki.lint.js' );
require( '../../../resources/workers/mediawiki/worker.min.js' );
const testCases = [
{
title: 'bold text in a section header (bold-header)',
input: '==\'\'\'foo\'\'\'==',
severity: 'info',
actions: [ 'remove' ]
},
{
title: 'unbalanced italic apostrophes in a section header (format-leakage)',
input: '==\'\'foo==',
severity: 'info',
actions: [ 'close' ]
},
{
title: 'content to be moved outside the table (fostered-content)',
input: '{|\nFoo\n|}',
severity: 'warning'
},
{
title: '
(h1)',
input: '=Foo=',
severity: 'warning',
actions: [ 'h2' ]
},
{
title: 'nonzero tabindex (illegal-attr)',
input: '
',
severity: 'warning',
actions: [ 'remove', '0 tabindex' ]
},
{
title: 'invalid attribute name (illegal-attr)',
input: '
',
severity: 'error',
actions: [ 'remove' ]
},
{
title: 'invalid attribute value (illegal-attr)',
input: '
',
severity: 'error'
},
{
title: 'invalid gallery image (invalid-gallery)',
input: 'Template:Foo',
severity: 'error',
actions: [ 'insert a namespace prefix' ]
},
{
title: 'imagemap without an image (invalid-imagemap)',
input: 'foo',
severity: 'error'
},
{
title: 'invalid link in imagemap (invalid-imagemap)',
input: `
File:foo.jpg
bar
`,
severity: 'error',
actions: [ 'remove', 'comment out' ]
},
{
title: 'missing Scribunto module function name (invalid-invoke)',
input: '{{#invoke:foo}}',
severity: 'error'
},
{
title: 'invalid Scribunto module name (invalid-invoke)',
input: '{{#invoke:..|foo}}',
severity: 'error'
},
{
title: 'invalid ISBN (invalid-isbn)',
input: 'ISBN 978-3-16-148410-1',
severity: 'error'
},
{
title: 'lonely "]" (lonely-bracket)',
input: 'https://example.com]',
severity: 'error',
actions: [ 'insert an opening bracket' ]
},
{
title: 'lonely "[" (lonely-bracket)',
input: '[[foo',
severity: 'warning'
},
{
title: 'internal link in an external link (nested-link)',
input: '[https://example.com [[foo]]]',
severity: 'error',
actions: [ 'delink' ]
},
{
title: 'duplicate id attribute (no-duplicate)',
input: '
',
severity: 'error',
actions: [ 'remove' ]
},
{
title: 'duplicate category (no-duplicate)',
input: '[[Category:Foo]] [[Category:Foo]]',
severity: 'warning',
actions: [ 'remove' ]
},
{
title: 'duplicate HTML id (no-duplicate)',
input: '
',
severity: 'warning'
},
{
title: 'conflicting image horizontal-alignment parameter (no-duplicate)',
input: '[[file:foo.jpg|left|none]]',
severity: 'error',
actions: [ 'remove' ]
},
{
title: 'duplicate image framed parameter (no-duplicate)',
input: '[[file:foo.jpg|frame|framed]]',
severity: 'error',
actions: [ 'remove' ]
},
{
title: 'duplicate template parameter (no-duplicate)',
input: '{{foo|bar|1=baz}}',
severity: 'error',
actions: [ 'remove' ]
},
{
title: 'invisible content inside triple braces (no-ignored)',
input: '{{{|foo|bar}}}',
severity: 'error',
actions: [ 'remove', 'escape' ]
},
{
title: 'attributes of a closing tag (no-ignored)',
input: '
',
severity: 'error',
actions: [ 'remove', 'convert to an opening tag' ]
},
{
title: 'invalid conversion flag (no-ignored)',
input: '-{r|foo}-',
severity: 'error',
actions: [ 'convert to uppercase' ]
},
{
title: 'useless fragment (no-ignored)',
input: '{{foo#bar}}',
severity: 'warning',
actions: [ 'remove' ]
},
{
title: 'invalid content in gallery (no-ignored)',
input: '|caption',
severity: 'warning',
actions: [ 'remove', 'comment out' ]
},
{
title: 'useless attribute (no-ignored)',
input: '',
severity: 'warning',
actions: [ 'remove' ]
},
{
title: 'element containing an invalid attribute name (no-ignored)',
input: `{|
!!id="foo"|
|}`,
severity: 'error',
actions: [ 'remove' ]
},
{
title: 'element containing an invalid attribute name (no-ignored)',
input: '
',
severity: 'warning',
actions: [ 'remove' ]
},
{
title: 'useless link text (no-ignored)',
input: '#redirect [[foo|bar]]',
severity: 'warning',
actions: [ 'remove' ]
},
{
title: 'invalid parameter of inputbox (no-ignored)',
input: '[',
severity: 'error',
actions: [ 'remove' ]
},
{
title: 'invalid content in references (no-ignored)',
input: 'foo',
severity: 'error',
actions: [ 'remove', 'comment out' ]
},
{
title: 'obsolete attribute (obsolete-attr)',
input: '
',
severity: 'warning'
},
{
title: 'obsolete HTML tag (obsolete-tag)',
input: 'foo',
severity: 'warning'
},
{
title: 'extension tag in HTML tag attributes (parsing-order)',
input: '
>',
severity: 'error'
},
{
title: 'section header in HTML tag attributes (parsing-order)',
input: `
`,
severity: 'error'
},
{
title: 'HTML tag in table attributes (parsing-order)',
input: `{|
|}`,
actions: [ 'remove' ],
severity: 'error'
},
{
title: 'additional "|" in a table cell (pipe-like)',
input: `{|
|
a || b
|}`,
actions: [ 'insert a newline' ],
severity: 'error'
},
{
title: 'additional "|" in a table cell (pipe-like)',
input: `{|
|
id=a | b
|}`,
actions: [ 'escape' ],
severity: 'warning'
},
{
title: 'additional "|" in the link text (pipe-like)',
input: '[[foo|bar|baz]]',
actions: [ 'escape' ],
severity: 'warning'
},
{
title: 'inconsistent table layout (table-layout)',
input: `{|
| a || b
|-
| c
|}`,
severity: 'info'
},
{
title: 'lonely "<" (tag-like)',
input: '[',
severity: 'error',
actions: [ 'escape' ]
},
{
title: 'lonely "<" (tag-like)',
input: '',
severity: 'warning',
actions: [ 'escape' ]
},
{
title: 'unbalanced "=" in a section header (unbalanced-header)',
input: '==foo===',
actions: [ 'h2', 'h3' ],
severity: 'error'
},
{
title: 'unclosed HTML comment (unclosed-comment)',
input: ']