Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.64 KB

valid-package-file-require.md

File metadata and controls

47 lines (37 loc) · 1.64 KB

valid-package-file-require

Ensures required files are in the format that is expected within ResourceLoader package modules.

📋 This rule is enabled in plugin:mediawiki/common.

🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

Rule details

❌ Examples of incorrect code:

var foo = require( './foo' );
var foo = require( '../foo' );
var foo = require( 'foo.js' );
var foo = require( './quux' );
var foo = require( 'quux.json' );

✔️ Examples of correct code:

var foo = require();
var foo = require( './foo.js' );
var foo = require( './quux.json' );
var foo = require( './virtual.json' );
var bar = require( '../valid-package-file-require.js' );
var foo = require( 'foo' );
var bar = require( 'bar' );
var foo = require( '../foo.js' );
var foo = require( './../foo.js' );

🔧 Examples of code fixed by this rule:

var foo = require( './foo' );     /* → */ var foo = require( './foo.js' );
var foo = require( '../foo' );    /* → */ var foo = require( '../foo.js' );
var foo = require( 'foo.js' );    /* → */ var foo = require( './foo.js' );
var foo = require( './quux' );    /* → */ var foo = require( './quux.json' );
var foo = require( 'quux.json' ); /* → */ var foo = require( './quux.json' );

Resources