File: no-require-tourl.md

package info (click to toggle)
node-eslint-plugin-requirejs 4.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 936 kB
  • sloc: javascript: 4,676; perl: 48; makefile: 31; sh: 1
file content (28 lines) | stat: -rw-r--r-- 839 bytes parent folder | download | duplicates (3)
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)