Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 839 Bytes

no-require-tourl.md

File metadata and controls

28 lines (19 loc) · 839 Bytes

Disallow use of require.toUrl and require.nameToUrl (no-require-tourl)

RequireJS provides these methods as a way to generate a url that is relative to a module. Some third-party module loaders such as Almond, do not support the use of these functions.

Rule Details

The following patterns are considered warnings:

define(['require'], function (require) {
    var cssUrl = require.toUrl('./style.css');
    /* ... */
});

define(['require'], function (require) {
    var idUrl = require.nameToUrl('id');
    /* ... */
});

When Not To Use It

If you are not using Almond, then it is safe to disable this rule.

Further Reading