-
-
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.
- Loading branch information
Showing
5 changed files
with
74 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 `import.meta` meta property (es/no-import-meta) | ||
|
||
This rule reports ES2020 [import.meta](https://github.com/tc39/proposal-import-meta) as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-import-meta: error */ | ||
import.meta | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v3.0.1/lib/rules/no-import-meta.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v3.0.1/tests/lib/rules/no-import-meta.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 `import.meta` meta property.", | ||
category: "ES2020", | ||
recommended: false, | ||
url: | ||
"http://mysticatea.github.io/eslint-plugin-es/rules/no-import-meta.html", | ||
}, | ||
fixable: null, | ||
messages: { | ||
forbidden: "ES2020 'import.meta' meta property is forbidden.", | ||
}, | ||
schema: [], | ||
type: "problem", | ||
}, | ||
create(context) { | ||
return { | ||
"MetaProperty[meta.name='import'][property.name='meta']"(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,26 @@ | ||
/** | ||
* @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-import-meta.js") | ||
|
||
if (!RuleTester.isSupported(2020)) { | ||
//eslint-disable-next-line no-console | ||
console.log("Skip the tests of no-import-meta.") | ||
return | ||
} | ||
|
||
new RuleTester({ | ||
parserOptions: { sourceType: "module" }, | ||
}).run("no-import-meta", rule, { | ||
valid: ["import * as Foo from 'foo'", "import('foo')"], | ||
invalid: [ | ||
{ | ||
code: "import.meta", | ||
errors: ["ES2020 'import.meta' meta property is forbidden."], | ||
}, | ||
], | ||
}) |