Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
steelbrain opened this issue Oct 1, 2024 · 3 comments · Fixed by #3047
Closed

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

steelbrain opened this issue Oct 1, 2024 · 3 comments · Fixed by #3047

Comments

@steelbrain
Copy link
Contributor

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,
+    }
+  })));
 }
@ljharb
Copy link
Collaborator

ljharb commented Oct 1, 2024

Seems good - a PR that fixes it in both packages would be great.

are there any other env vars eslint respects?

@steelbrain
Copy link
Contributor Author

are there any other env vars eslint respects?

Based on a code search of the ESLint repository TIMING seems to be the only relevant one.

Seems good - a PR that fixes it in both packages would be great.

Great, thanks! I'll put up a PR and ping you

@steelbrain
Copy link
Contributor Author

A PR is up in #3047 -- Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants