Skip to content

Commit 1949f69

Browse files
committed
wrap the execSync call in a try-catch block in whitespace.js to handle errors gracefully:
1 parent bc5d390 commit 1949f69

2 files changed

Lines changed: 24 additions & 14 deletions

File tree

packages/eslint-config-airbnb-base/whitespace.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ if (CLIEngine) {
5151
const path = require('path');
5252
const { execSync } = require('child_process');
5353

54-
// NOTE: ESLint adds runtime statistics to the output (so it's no longer JSON) if TIMING is set
55-
module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
56-
env: {
57-
...process.env,
58-
TIMING: undefined,
59-
}
60-
})));
54+
try {
55+
// NOTE: ESLint adds runtime statistics to the output (so it's no longer JSON) if TIMING is set
56+
module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
57+
env: {
58+
...process.env,
59+
TIMING: undefined,
60+
}
61+
})));
62+
} catch (error) {
63+
console.error('Error loading whitespace config:', error.message);
64+
process.exit(1);
65+
}
6166
}

packages/eslint-config-airbnb/whitespace.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ if (CLIEngine) {
5151
const path = require('path');
5252
const { execSync } = require('child_process');
5353

54-
// NOTE: ESLint adds runtime statistics to the output (so it's no longer JSON) if TIMING is set
55-
module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
56-
env: {
57-
...process.env,
58-
TIMING: undefined,
59-
}
60-
})));
54+
try {
55+
// NOTE: ESLint adds runtime statistics to the output (so it's no longer JSON) if TIMING is set
56+
module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
57+
env: {
58+
...process.env,
59+
TIMING: undefined,
60+
}
61+
})));
62+
} catch (error) {
63+
console.error('Error loading whitespace config:', error.message);
64+
process.exit(1);
65+
}
6166
}

0 commit comments

Comments
 (0)