Skip to content

Commit

Permalink
New: rule - added support for 'export * from' and 'export { stuff } f…
Browse files Browse the repository at this point in the history
…rom ', revised docs
  • Loading branch information
rfermann committed Aug 19, 2018
1 parent d47ccdf commit 06a0976
Show file tree
Hide file tree
Showing 7 changed files with 580 additions and 140 deletions.
29 changes: 25 additions & 4 deletions docs/rules/no-unused-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ Reports:
- modules without any or
- individual exports not being used within other modules

Note: dynamic imports are currently not supported.

## Rule Details


### Options

This rule takes the following option:

- `src`: an array with files/paths to be analyzed. It only for applies for unused exports
- `src`: an array with files/paths to be analyzed. It only for applies for unused exports. Defaults to `process.cwd()`, if not provided
- `ignore`: an array with files/paths to be ignored. It only for applies for unused exports
- `missingExports`: if `true`, files without any exports are reported
- `unusedExports`: if `true`, exports without any usage are reported
- `unusedExports`: if `true`, exports without any usage within other modules are reported.


### Example for missing exports
Expand All @@ -41,12 +43,31 @@ export { foo as bar }
```

### Example for unused exports
given file-c:
given file-f:
```js
import { e } from 'file-a'
import { f } from 'file-b'
import * from 'file-c'
export * from 'file-d'
export { default, i0 } from 'file-e' // both will be reported

export default 7 // will be reported
export const j = 99 // will be reported
```
and file-e:
```js
export const i0 = 9 // will not be reported
export const i1 = 9 // will be reported
export default () => {} // will not be reported
```
and file-d:
```js
export const h = 8 // will not be reported
export default () => {} // will be reported, as export * only considers named exports and ignores default exports
```
and file-c:
```js
export const g = 7 // will not be reported
export default () => {} // will not be reported
```
and file-b:
```js
Expand Down

0 comments on commit 06a0976

Please sign in to comment.