-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs, update readme and changelog
Also removed a superfluous test.
- Loading branch information
Showing
5 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# no-import-module-exports | ||
|
||
Reports the use of import declarations with CommonJS exports in any module | ||
except for the [main module](https://docs.npmjs.com/files/package.json#main). | ||
|
||
If you have multiple entry points, or are using `js:next` this rule includes an | ||
`exceptions` option which you can use to exclude those files from the rule. | ||
|
||
## Options | ||
|
||
#### `exceptions` | ||
An array of globs. The rule will be omitted from any file that matches a glob in | ||
the options array. | ||
|
||
For example, the following setting will omit the rule in the `some-file.js` file. | ||
|
||
```json | ||
"import/no-import-module-exports": ["error", { | ||
"exceptions": ['**/*/some-file.js'] | ||
}] | ||
``` | ||
|
||
## Rule Details | ||
|
||
### Fail | ||
|
||
```js | ||
import { stuff } from 'starwars' | ||
module.exports = thing | ||
|
||
import * as allThings from 'starwars' | ||
exports.bar = thing | ||
|
||
import thing from 'other-thing' | ||
exports.foo = bar | ||
|
||
import thing from 'starwars' | ||
const baz = module.exports = thing | ||
console.log(baz) | ||
``` | ||
|
||
### Pass | ||
Given the following package.json: | ||
|
||
```json | ||
{ | ||
"main": "lib/index.js", | ||
} | ||
``` | ||
|
||
```js | ||
import thing from 'other-thing' | ||
export default thing | ||
|
||
const thing = require('thing') | ||
module.exports = thing | ||
|
||
const thing = require('thing') | ||
exports.foo = bar | ||
|
||
import thing from 'otherthing' | ||
console.log(thing.module.exports) | ||
|
||
/* in lib/index.js */ | ||
import foo from 'path'; | ||
module.exports = foo; | ||
|
||
/* in some-file.js */ | ||
/* eslint import/no-import-module-exports: ["error", {"exceptions": ['**/*/some-file.js']}] */ | ||
import foo from 'path'; | ||
module.exports = foo; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,8 @@ module.exports = { | |
const isEntryPoint = entryPoint === fileName | ||
const isIdentifier = |