1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
# 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](https://github.com/jrburke/almond), do not support the use of these functions.
## Rule Details
The following patterns are considered warnings:
```js
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
* [RequireJS Module Notes](http://requirejs.org/docs/api.html#modulenotes)
* [Almond Restrictions](https://github.com/jrburke/almond#restrictions)
|