Skip to content

Commit

Permalink
add try-catch and fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorHom committed Jun 12, 2017
1 parent 68cb462 commit 55bc9e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/user-guide/configuring.md
Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion lib/ignored-paths.js
Expand Up @@ -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 => {
Expand Down

0 comments on commit 55bc9e8

Please sign in to comment.