nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: mantoni/eslint_d.js
Pull request #304 (2024-08-01 11:01:55)

fix(resolver): eslint path detection not working on Windows
on Windows machines another path separator is used,
so instead of "/path/to/eslint/lib/eslint.js" we get
"C:\\path\\to\\eslint\\lib\\eslint.js".

Provided fix uses require.resolve of package.json which is
always at top-level and then passthrough it to dirname function,
which will return path to eslint package with correct path separators.


L2jLiga: Sure, but have to manage how to make them pass on my Windows machine 😅 
I have much more failed tests than in CI
L2jLiga: fixed tests using my linux machine 😄 

Patch:
diff --git a/lib/resolver.js b/lib/resolver.js
index e19d2e3..08576c5 100644
--- a/lib/resolver.js
+++ b/lib/resolver.js
@@ -1,4 +1,5 @@
 import { createRequire } from 'node:module';
+import { dirname } from 'node:path';
 
 /**
  * @typedef {Object} Resolver
@@ -16,7 +17,7 @@ export function createResolver() {
   let bundled = false;
   let path;
   try {
-    path = require.resolve('eslint', { paths: [process.cwd()] });
+    path = require.resolve('eslint/package.json', { paths: [process.cwd()] });
   } catch (err) {
     if (local === 'ignore') {
       return 'ignore';
@@ -26,11 +27,11 @@ export function createResolver() {
       return 'fail';
     }
     // Fallback to bundled eslint
-    path = require.resolve('eslint');
+    path = require.resolve('eslint/package.json');
     bundled = true;
   }
   return {
-    base: path.substring(0, path.lastIndexOf('/eslint/') + 7),
+    base: dirname(path),
     bundled,
     require
   };
diff --git a/package-lock.json b/package-lock.json
index b72acbc..7810b46 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -24,6 +24,9 @@
         "mocha": "^10.7.0",
         "prettier": "^3.3.3",
         "typescript": "^5.5.4"
+      },
+      "engines": {
+        "node": ">=18"
       }
     },
     "node_modules/@babel/parser": {


Test patch:
diff --git a/lib/resolver.test.js b/lib/resolver.test.js
index 001d046..0e586a8 100644
--- a/lib/resolver.test.js
+++ b/lib/resolver.test.js
@@ -64,7 +64,7 @@ describe('lib/resolver', () => {
       assert.calledOnceWith(
         console.error,
         match(
-          "eslint_d: Failed to resolve eslint - Error: Cannot find module 'eslint'"
+          "eslint_d: Failed to resolve eslint - Error: Cannot find module 'eslint/package.json'"
         )
       );
     });
Repository: mantoni/eslint_d.js
Pull request #316 (2024-09-26 16:45:41)

fix: config file removed before watcher started


Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c39f403..969b458 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -38,5 +38,4 @@ jobs:
       - name: Test
         run: npm test
       - name: Integration Tests
-        if: matrix.os == 'ubuntu-latest'
         run: npm run test:integration
diff --git a/lib/launcher.js b/lib/launcher.js
index 6383f41..dfe62fd 100644
--- a/lib/launcher.js
+++ b/lib/launcher.js
@@ -48,13 +48,14 @@ export async function launchDaemon(resolver, hash) {
  */
 export async function stopDaemon(resolver, config) {
   try {
-    await platformAwareStopDaemon(config);
+    await Promise.all([
+      waitForConfig(resolver.base),
+      platformAwareStopDaemon(config)
+    ]);
   } catch (err) {
     console.error(`eslint_d: ${err} - removing config`);
     await removeConfig(resolver);
-    return;
   }
-  await waitForConfig(resolver.base);
 }
 
 /**
diff --git a/package.json b/package.json
index 3e8e650..d1eaed2 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
   "scripts": {
     "lint": "eslint .",
     "test": "mocha '**/*.test.js'",
-    "test:integration": "mocha --bail --slow 1000 test/test.integration.js",
+    "test:integration": "mocha --bail --slow 1000 --timeout 5000 test/test.integration.js",
     "test:coverage": "mcr --filter \"{'**/node_modules/**':false,'**/**':true}\" -r v8,console-details mocha '**/*.test.js'",
     "watch": "chokidar '**/*.js' -c 'npm t' --initial --silent",
     "prepare": "husky && sh scripts/install-fixture-deps.sh",


Test patch:
diff --git a/lib/launcher.test.js b/lib/launcher.test.js
index 1e6e008..d28229a 100644
--- a/lib/launcher.test.js
+++ b/lib/launcher.test.js
@@ -245,10 +245,11 @@ describe('lib/launcher', () => {
         assert.calledOnceWith(fs_promises.unlink, `${resolver.base}/.eslint_d`);
       });
 
-      it('does not watch for the config file', () => {
-        stopDaemon(resolver, config);
+      it('does not wait for the config file removal', async () => {
+        const promise = stopDaemon(resolver, config);
 
-        refute.called(fs.watch);
+        assert.calledOnceWith(fs.watch, resolver.base);
+        await assert.resolves(promise, undefined);
       });
     });
   });
@@ -339,10 +340,11 @@ describe('lib/launcher', () => {
         assert.calledOnceWith(fs_promises.unlink, `${resolver.base}/.eslint_d`);
       });
 
-      it('does not watch for the config file', () => {
-        stopDaemon(resolver, config);
+      it('does not wait for the config file removal', async () => {
+        const promise = stopDaemon(resolver, config);
 
-        refute.called(fs.watch);
+        assert.calledOnceWith(fs.watch, resolver.base);
+        await assert.resolves(promise, undefined);
       });
     });
   });