Skip to content

eslint-config-airbnb breaks with TIMING=1 env #3045

Closed
@steelbrain

Description

@steelbrain

In /whitespace.js a subprocess is launched to print out the rules in JSON and the JSON response is parsed.

If ESLint is being run with TIMING=1, it prints how much time each rule takes, and because the linked child process invocation is forwarding the env as-is, it's json parsing will fail and the process breaks down.

Here's the patch I'm using internally. Happy to upstream if it looks good to y'all

diff --git a/whitespace.js b/whitespace.js
index dfdf95a18e69f4bba35fe53bb59bad5de3bccbf6..052a4fc2f4d56da3eadbd2cc377131529788840d 100644
--- a/whitespace.js
+++ b/whitespace.js
@@ -51,5 +51,10 @@ if (CLIEngine) {
   const path = require('path');
   const { execSync } = require('child_process');
 
-  module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'))));
+  module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
+    env: {
+      ...process.env,
+      TIMING: undefined,
+    }
+  })));
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions