-
-
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.
Refactored path resolution into getExports + added 'resolve.root' set…
…ting. (closes #18)
- Loading branch information
Showing
12 changed files
with
86 additions
and
94 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 |
---|---|---|
@@ -1,32 +1,23 @@ | ||
"use strict"; | ||
|
||
var | ||
resolve = require("../resolve"), | ||
getExports = require("../getExports"); | ||
var getExports = require("../getExports"); | ||
|
||
require("array.prototype.find"); | ||
|
||
module.exports = function (context) { | ||
return { | ||
"ImportDeclaration": function (node) { | ||
var path = resolve(node.source.value, context.getFilename()); | ||
if (path == null) { | ||
return; | ||
} | ||
|
||
var defaultSpecifier = node.specifiers.find(function (n) { return n.type === "ImportDefaultSpecifier"; }); | ||
if (!defaultSpecifier) { | ||
return; | ||
} | ||
if (!defaultSpecifier) return; | ||
|
||
var imports = getExports(node.source.value, context); | ||
if (imports == null) return; | ||
|
||
var imports = getExports(path); | ||
if (imports.named.size === 0 && context.options[0] !== "es6-only") { | ||
if (imports.named.size === 0 && context.options[0] !== "es6-only") | ||
return; // ignore for commonjs compatibility | ||
} | ||
|
||
if (!imports.hasDefault) { | ||
if (!imports.hasDefault) | ||
context.report(defaultSpecifier, "No default export found in module."); | ||
} | ||
} | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,20 +1,16 @@ | ||
"use strict"; | ||
|
||
var | ||
resolve = require("../resolve"), | ||
getExports = require("../getExports"); | ||
var getExports = require("../getExports"); | ||
|
||
module.exports = function (context) { | ||
return { | ||
"ImportDeclaration": function (node) { | ||
var path = resolve(node.source.value, context.getFilename()); | ||
if (path == null) { return; } | ||
|
||
var imports = getExports(path); | ||
if (imports.isCommon) { | ||
context.report(node.source, "'" + node.source.value + "' is a CommonJS module."); | ||
} | ||
var imports = getExports(node.source.value, context); | ||
if (imports == null) return; | ||
|
||
if (imports.isCommon) | ||
context.report(node.source, "'" + node.source.value + "' is a CommonJS module."); | ||
} | ||
} | ||
}; | ||
}; |
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 @@ | ||
export const DEEP = "RISING"; |
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