Skip to content

Commit b543300

Browse files
authored
docs: document the esmodule option for no-dynamic-require rule (#496)
1 parent 7578513 commit b543300

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎docs/rules/no-dynamic-require.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@ The `require` method from CommonJS is used to import modules from different file
66

77
This rule forbids every call to `require()` that uses expressions for the module name argument.
88

9+
## Options
10+
11+
This rule supports the following options:
12+
13+
### `esmodule`
14+
15+
By default, this rule does not report dynamic `import()` expressions.
16+
17+
Given `{ "esmodule": true }`:
18+
19+
<!-- lint disable no-duplicate-headings-in-section -->
20+
21+
### Fail
22+
23+
```js
24+
import(name)
25+
import('../' + name)
26+
import(`../${name}`)
27+
import(name())
28+
```
29+
30+
<!-- lint disable no-duplicate-headings-in-section -->
31+
32+
### Pass
33+
34+
```js
35+
import('foo')
36+
import(`foo`)
37+
import('./foo')
38+
import('@scope/foo')
39+
```
40+
941
## Rule Details
1042

1143
### Fail

0 commit comments

Comments
 (0)