Skip to content

Commit

Permalink
fix: handle exceptions from parse-package-name
Browse files Browse the repository at this point in the history
  • Loading branch information
azz committed Dec 14, 2017
1 parent 58cd916 commit 592a7e1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/rules/no-internal-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const create = context => {
const packages = getPackages(process.cwd());

return moduleVisitor(node => {
const { name, path: internalPath } = parse(node.value);
const { name, path: internalPath } = tryParse(node.value);
if (internalPath && packages.find(pkg => pkg.name === name)) {
context.report({
node,
Expand All @@ -22,3 +22,11 @@ export const create = context => {
}
}, moduleUtilOptions);
};

const tryParse = text => {
try {
return parse(text);
} catch (error) {
return { path: text, name: '' };
}
};

0 comments on commit 592a7e1

Please sign in to comment.