-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ add
es/no-export-ns-from
rule (#36)
- Loading branch information
Showing
5 changed files
with
83 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow `export * as ns` (es/no-export-ns-from) | ||
|
||
This rule reports ES2020 [`export * as ns`](https://github.com/tc39/proposal-export-ns-from) as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-export-ns-from: error */ | ||
export * as ns from "mod" | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v3.0.1/lib/rules/no-export-ns-from.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v3.0.1/tests/lib/rules/no-export-ns-from.js) |
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,30 @@ | ||
/** | ||
* @author Yosuke Ota <https://github.com/ota-meshi> | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
"use strict" | ||
|
||
module.exports = { | ||
meta: { | ||
docs: { | ||
description: "disallow `export * as ns`.", | ||
category: "ES2020", | ||
recommended: false, | ||
url: | ||
"http://mysticatea.github.io/eslint-plugin-es/rules/no-export-ns-from.html", | ||
}, | ||
fixable: null, | ||
messages: { | ||
forbidden: "ES2020 'export * as ns' are forbidden.", | ||
}, | ||
schema: [], | ||
type: "problem", | ||
}, | ||
create(context) { | ||
return { | ||
"ExportAllDeclaration[exported!=null]"(node) { | ||
context.report({ node, messageId: "forbidden" }) | ||
}, | ||
} | ||
}, | ||
} |
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,35 @@ | ||
/** | ||
* @author Yosuke Ota <https://github.com/ota-meshi> | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
"use strict" | ||
|
||
const RuleTester = require("../../tester") | ||
const rule = require("../../../lib/rules/no-export-ns-from.js") | ||
|
||
if (!RuleTester.isSupported(2020)) { | ||
//eslint-disable-next-line no-console | ||
console.log("Skip the tests of no-export-ns-from.") | ||
return | ||
} | ||
|
||
new RuleTester({ | ||
parserOptions: { sourceType: "module" }, | ||
}).run("no-export-ns-from", rule, { | ||
valid: [ | ||
'export * from "mod"', | ||
"export default foo", | ||
'export {foo} from "mod"', | ||
'export {foo as bar} from "mod"', | ||
'import * as foo from "mod"', | ||
'import foo from "mod"', | ||
'import {foo} from "mod"', | ||
'import {foo as bar} from "mod"', | ||
], | ||
invalid: [ | ||
{ | ||
code: 'export * as ns from "mod"', | ||
errors: ["ES2020 'export * as ns' are forbidden."], | ||
}, | ||
], | ||
}) |