From 55bc9e856110430b531b530a0e14ecbaefb62862 Mon Sep 17 00:00:00 2001 From: Victor Hom Date: Sun, 11 Jun 2017 20:21:04 -0400 Subject: [PATCH] add try-catch and fix docs --- docs/user-guide/configuring.md | 2 +- lib/ignored-paths.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/configuring.md b/docs/user-guide/configuring.md index 29b72ff24893..86469a5af4f2 100644 --- a/docs/user-guide/configuring.md +++ b/docs/user-guide/configuring.md @@ -777,7 +777,7 @@ Any file that follows the standard ignore file format can be used. Keep in mind ### Using eslintIgnore in package.json -If an .eslintIgnore file is not found and an alternate file is not specified, eslint will look in package.json for an eslintIgnore key to check for files to ignore. +If an `.eslintignore` file is not found and an alternate file is not specified, eslint will look in package.json for an `eslintIgnore` key to check for files to ignore. { "name": "mypackage", diff --git a/lib/ignored-paths.js b/lib/ignored-paths.js index f5e76bc37698..da9d2737164c 100644 --- a/lib/ignored-paths.js +++ b/lib/ignored-paths.js @@ -180,7 +180,13 @@ class IgnoredPaths { const packageJSONPath = findPackageJSONFile(options.cwd); if (packageJSONPath) { - const packageJSONOptions = JSON.parse(fs.readFileSync(packageJSONPath, "utf8")); + let packageJSONOptions; + + try { + packageJSONOptions = JSON.parse(fs.readFileSync(packageJSONPath, "utf8")); + } catch (e) { + debug("Could not read package.json file to check eslintIgnore property"); + } if (packageJSONOptions.eslintIgnore && Array.isArray(packageJSONOptions.eslintIgnore)) { packageJSONOptions.eslintIgnore.forEach(pattern => {