nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: depcheck/depcheck
Pull request #657 (2021-07-23 05:50:08)

feat: detect deps used with -r in package.json
I noticed depcheck wasn't detecting ts-node being used in one of my package.json scripts, such as:

`"test": "mocha -r ts-node/register test/**/*.ts"`

Looked like it was already detecting `--require`, but not `-r`, so I figured it made sense to add it. I found it was briefly mentioned in this issue too: https://github.com/depcheck/depcheck/issues/461


Patch:
diff --git a/src/special/bin.js b/src/special/bin.js
index 30ec637..423ef38 100644
--- a/src/special/bin.js
+++ b/src/special/bin.js
@@ -30,6 +30,8 @@ function getBinaryFeatures(dep, [key, value]) {
     key,
     `--require ${key}`,
     `--require ${key}/register`,
+    `-r ${key}`,
+    `-r ${key}/register`,
     `$(npm bin)/${key}`,
     `node_modules/.bin/${key}`,
     `./node_modules/.bin/${key}`,


Test patch:
diff --git a/test/special/bin.js b/test/special/bin.js
index 70d27ec..fac1a8e 100644
--- a/test/special/bin.js
+++ b/test/special/bin.js
@@ -95,6 +95,18 @@ const testCases = [
     dependencies: ['binary-package'],
     expected: ['binary-package'],
   },
+  {
+    name: 'detect packages used with -r and /register',
+    script: 'module -r binary-entry/register',
+    dependencies: ['binary-package'],
+    expected: ['binary-package'],
+  },
+  {
+    name: 'detect packages used with -r',
+    script: 'module -r binary-entry',
+    dependencies: ['binary-package'],
+    expected: ['binary-package'],
+  },
   {
     name: 'detect packages with single binary',
     script: 'single-binary-package --argument',
Repository: depcheck/depcheck
Pull request #756 (2022-10-13 16:28:51)

feat: ignore url imports
ES Modules allows for absolute URL imports, but this currently does not work with depcheck - it will say that a file depends on the `https:`/`http:` module, which is obviously incorrect.

This PR ensures that imports that has an `http://` or `https://` prefix (case insensitive) will be ignored.



Patch:
diff --git a/src/detector/extract.js b/src/detector/extract.js
index 3663b22..1f0a16b 100644
--- a/src/detector/extract.js
+++ b/src/detector/extract.js
@@ -3,7 +3,9 @@
 export function extractInlineWebpack(value) {
   const parts = value.split('!');
   if (parts.length === 1) {
-    return [value]; // ['module-name'] or ['path/to/file']
+    return /^https?:\/\//i.test(value)
+      ? [] // ignore URLs (https://foo.bar/file.js)
+      : [value]; // ['module-name'] or ['path/to/file']
   }
   if (parts[0] === '') {
     // ['', 'something-loader', 'path/to/file']


Test patch:
diff --git a/test/fake_modules/url_import/index.js b/test/fake_modules/url_import/index.js
new file mode 100644
index 0000000..9afc643
--- /dev/null
+++ b/test/fake_modules/url_import/index.js
@@ -0,0 +1,8 @@
+/* eslint-env browser */
+import confetti from 'https://cdn.skypack.dev/canvas-confetti';
+import unsafeConfetti from 'hTtP://cdn.skypack.dev/canvas-confetti';
+
+document.addEventListener('DOMContentLoaded', () => {
+  confetti();
+  setTimeout(() => unsafeConfetti(), 1000);
+});
diff --git a/test/fake_modules/url_import/package.json b/test/fake_modules/url_import/package.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/test/fake_modules/url_import/package.json
@@ -0,0 +1,1 @@
+{}
diff --git a/test/spec.js b/test/spec.js
index 9ab3c5f..461ae57 100755
--- a/test/spec.js
+++ b/test/spec.js
@@ -888,4 +888,16 @@ export default [
     },
     expectedErrorCode: -1,
   },
+  {
+    name: 'allows url imports',
+    module: 'url_import',
+    options: {},
+    expected: {
+      dependencies: [],
+      devDependencies: [],
+      missing: {},
+      using: {},
+    },
+    expectedErrorCode: 0,
+  },
 ];
Repository: depcheck/depcheck
Pull request #810 (2023-06-20 15:23:57)

Fix dynamic import with a template literal #779
Depcheck doesn't catch this

```js
import(`whatever`)
```

But with this PR, it now will catch that import.


Patch:
diff --git a/.eslintignore b/.eslintignore
index ab1137c..f82a21e 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -7,4 +7,5 @@ test/fake_modules/node_modules/eslint-config-foo-bar/
 test/fake_modules/eslint_config_js/
 test/fake_modules/import_function/
 test/fake_modules/import_function_missing/
+test/fake_modules/import_function_template_literal/
 test/fake_modules/import_function_webpack/
diff --git a/src/detector/importCallExpression.js b/src/detector/importCallExpression.js
index 4417918..b30fe19 100644
--- a/src/detector/importCallExpression.js
+++ b/src/detector/importCallExpression.js
@@ -1,7 +1,8 @@
 import lodash from 'lodash';
 
 export default function importCallExpression(node) {
-  return node.type === 'CallExpression' &&
+  if (
+    node.type === 'CallExpression' &&
     node.callee &&
     ((node.callee.type === 'Identifier' && node.callee.name === 'import') ||
       node.callee.type === 'Import' ||
@@ -10,8 +11,18 @@ export default function importCallExpression(node) {
         node.callee.object.name === 'System' &&
         node.callee.property &&
         node.callee.property.name === 'import')) &&
-    node.arguments[0] &&
-    lodash.isString(node.arguments[0].value)
-    ? [node.arguments[0].value]
-    : [];
+    node.arguments[0]
+  ) {
+    if (lodash.isString(node.arguments[0].value)) {
+      return [node.arguments[0].value];
+    }
+    if (
+      node.arguments[0].type === 'TemplateLiteral' &&
+      node.arguments[0].quasis.length === 1 &&
+      lodash.isString(node.arguments[0].quasis[0].value.raw)
+    ) {
+      return [node.arguments[0].quasis[0].value.raw];
+    }
+  }
+  return [];
 }


Test patch:
diff --git a/test/fake_modules/import_function_template_literal/index.js b/test/fake_modules/import_function_template_literal/index.js
new file mode 100644
index 0000000..898e647
--- /dev/null
+++ b/test/fake_modules/import_function_template_literal/index.js
@@ -0,0 +1,1 @@
+import(`optimist`);
diff --git a/test/fake_modules/import_function_template_literal/package.json b/test/fake_modules/import_function_template_literal/package.json
new file mode 100644
index 0000000..b347062
--- /dev/null
+++ b/test/fake_modules/import_function_template_literal/package.json
@@ -0,0 +1,5 @@
+{
+  "dependencies": {
+    "optimist": "~0.6.0"
+  }
+}
diff --git a/test/spec.js b/test/spec.js
index 8b08cca..560aeb9 100755
--- a/test/spec.js
+++ b/test/spec.js
@@ -33,6 +33,20 @@ export default [
     },
     expectedErrorCode: 0,
   },
+  {
+    name: 'find module for dynamic import(`template-literal`) when present',
+    module: 'import_function_template_literal',
+    options: {},
+    expected: {
+      dependencies: [],
+      devDependencies: [],
+      missing: {},
+      using: {
+        optimist: ['index.js'],
+      },
+    },
+    expectedErrorCode: 0,
+  },
   {
     name: 'find module for dynamic import() with magic Webpack comment',
     module: 'import_function_webpack',
Repository: depcheck/depcheck
Pull request #820 (2023-07-18 14:12:01)

feat(jest): add support for jest.config.mjs and jest.config.ts

miluoshi: Probably required checks should be updated to not contain unsupported Node versions (10.x - 14.x)?

Patch:
diff --git a/src/special/jest.js b/src/special/jest.js
index aa8775b..53d0e70 100644
--- a/src/special/jest.js
+++ b/src/special/jest.js
@@ -4,7 +4,7 @@ import { getContent } from '../utils/file';
 
 const _ = lodash;
 
-const jestConfigRegex = /^jest.([^.]+\.)?conf(ig|).(cjs|js(on|))$/;
+const jestConfigRegex = /^jest.([^.]+\.)?conf(ig|)\.(cjs|mjs|js|json|ts)$/;
 const supportedProperties = [
   'dependencyExtractor',
   'preset',
@@ -102,7 +102,10 @@ export default async function parseJest(filename, deps, rootDir) {
   if (jestConfigRegex.test(basename)) {
     try {
       // eslint-disable-next-line global-require
-      const options = require(filename) || {};
+      const config = require(filename) ?? {};
+      const options =
+        path.extname(filename) === '.ts' ? config.default : config;
+
       return checkOptions(deps, options);
     } catch (error) {
       return [];


Test patch:
diff --git a/test/special/jest.js b/test/special/jest.js
index dcc164b..0b0619e 100644
--- a/test/special/jest.js
+++ b/test/special/jest.js
@@ -8,13 +8,17 @@ const testParser = getTestParserWithTempFile(parser);
 
 const configFileNames = [
   'jest.config.js',
+  'jest.config.json',
   'jest.config.cjs',
+  'jest.config.mjs',
+  'jest.config.ts',
   'jest.conf.js',
-  'jest.conf.cjs',
-  'jest.config.json',
   'jest.conf.json',
+  'jest.conf.cjs',
+  'jest.conf.mjs',
   'jest.it.config.js',
   'jest.it.config.cjs',
+  'jest.it.config.mjs',
 ];
 
 const testCases = [
@@ -207,10 +211,15 @@ describe('jest special parser', () => {
     testCases.forEach((testCase) =>
       it(`should ${testCase.name} in config file ${fileName}`, async () => {
         const config = JSON.stringify(testCase.content);
+        const extension = fileName.split('.').pop();
         let content = config;
-        if (['js', 'cjs'].includes(fileName.split('.').pop())) {
+
+        if (['js', 'cjs'].includes(extension)) {
           content = `module.exports = ${config}`;
         }
+        if (['mjs', 'ts'].includes(extension)) {
+          content = `export default ${config}`;
+        }
         return testJest(content, testCase.deps, testCase.deps, fileName);
       }),
     ),
Repository: depcheck/depcheck
Pull request #825 (2023-08-22 09:36:42)

fix(storybook): parse package names out of addons array
`addons` array can contain not only package names directly, but also nested paths to addon files within a package. Running the addons array through requirePackageName fixes that


Patch:
diff --git a/src/parser/storybook.js b/src/parser/storybook.js
index 90ec311..1333e26 100644
--- a/src/parser/storybook.js
+++ b/src/parser/storybook.js
@@ -4,13 +4,13 @@ const { tryRequire } = require('../utils');
 export default function storybookParser(filePath) {
   const foundDeps = [];
   const config = tryRequire(filePath);
-  const { addons, core, framework, typescript } = config;
+  const { addons = [], core, framework, typescript } = config;
   if (typeof framework === 'string') {
     foundDeps.push(framework);
   }
-  if (Array.isArray(addons)) {
-    foundDeps.push(...addons);
-  }
+
+  foundDeps.push(...addons.map(requirePackageName));
+
   if (core) {
     const { builder } = core;
     if (builder === 'webpack5') {


Test patch:
diff --git a/test/fake_modules/storybook/.storybook/main.js b/test/fake_modules/storybook/.storybook/main.js
index 071e806..ad0b393 100644
--- a/test/fake_modules/storybook/.storybook/main.js
+++ b/test/fake_modules/storybook/.storybook/main.js
@@ -5,7 +5,11 @@ module.exports = {
     '../packages/**/src/**/*.stories.@(js|ts|jsx|tsx|mdx)',
   ],
   features: {},
-  addons: ['@storybook/addon-essentials', '@storybook/addon-links'],
+  addons: [
+    '@storybook/addon-essentials',
+    '@storybook/addon-links',
+    '@nx/react/plugins/storybook',
+  ],
   typescript: {
     check: false,
     checkOptions: {},
diff --git a/test/fake_modules/storybook/package.json b/test/fake_modules/storybook/package.json
index ab3c3e2..6b52f6c 100644
--- a/test/fake_modules/storybook/package.json
+++ b/test/fake_modules/storybook/package.json
@@ -1,6 +1,7 @@
 {
   "name": "storybook",
   "devDependencies": {
+    "@nx/react": "*",
     "@storybook/react": "*",
     "@storybook/addon-essentials": "*",
     "@storybook/addon-unused": "*",
diff --git a/test/spec.js b/test/spec.js
index 560aeb9..080be0a 100755
--- a/test/spec.js
+++ b/test/spec.js
@@ -952,6 +952,7 @@ export default [
         '@storybook/manager-webpack5': ['.storybook/main.js'],
       },
       using: {
+        '@nx/react': ['.storybook/main.js'],
         '@storybook/addon-essentials': ['.storybook/main.js'],
         '@storybook/addon-links': ['.storybook/main.js'],
         '@storybook/builder-webpack5': ['.storybook/main.js'],
Repository: depcheck/depcheck
Pull request #830 (2023-08-28 19:55:19)

Handle scoped package bin with default name
When a scoped package specifies a "bin" key with a string instead of an object, the name of the bin script is taken as the package name without the scope.

For example, given a package.json like:

```
{
"name": "@foo/bar",
"bin": "./bin/cli.js"
}
```

Running `yarn run bar` would run `./bin/cli.js` from that package.

Prior to this change, `depcheck` was calculating the name of the bin script to the fully scoped package name `@foo/bar`, which is not correct.



Patch:
diff --git a/src/special/bin.js b/src/special/bin.js
index 423ef38..25c82bd 100644
--- a/src/special/bin.js
+++ b/src/special/bin.js
@@ -17,7 +17,9 @@ function getBinaries(dep, dir) {
   const binMetadata = getCacheOrLoad(dep, dir);
 
   if (typeof binMetadata === 'string') {
-    return [[dep, binMetadata]];
+    // Use path.basename to discard any scope
+    // e.g. a package named "@foo/bar" creates a command named "bar"
+    return [[path.basename(dep), binMetadata]];
   }
 
   return lodash.toPairs(binMetadata);


Test patch:
diff --git a/test/special/bin.js b/test/special/bin.js
index 9099928..1e2e7f0 100644
--- a/test/special/bin.js
+++ b/test/special/bin.js
@@ -108,11 +108,23 @@ const testCases = [
     expected: ['binary-package'],
   },
   {
-    name: 'detect packages with single binary',
+    name: 'detect packages with single binary with default name',
     script: 'single-binary-package --argument',
     dependencies: ['single-binary-package'],
     expected: ['single-binary-package'],
   },
+  {
+    name: 'detect scoped packages with single binary with default name',
+    script: 'scoped-single-binary-package --argument',
+    dependencies: ['@scoped/scoped-single-binary-package'],
+    expected: ['@scoped/scoped-single-binary-package'],
+  },
+  {
+    name: 'detect scoped packages with named binary',
+    script: 'scoped-binary-entry --argument',
+    dependencies: ['@scoped/scoped-binary-package'],
+    expected: ['@scoped/scoped-binary-package'],
+  },
   {
     name: 'esm',
     script: 'esm',
diff --git a/test/special/node_modules/@scoped/scoped-binary-package/package.json b/test/special/node_modules/@scoped/scoped-binary-package/package.json
new file mode 100644
index 0000000..5e4f40d
--- /dev/null
+++ b/test/special/node_modules/@scoped/scoped-binary-package/package.json
@@ -0,0 +1,5 @@
+{
+  "bin": {
+    "scoped-binary-entry": "./bin/binary-exe"
+  }
+}
diff --git a/test/special/node_modules/@scoped/scoped-single-binary-package/package.json b/test/special/node_modules/@scoped/scoped-single-binary-package/package.json
new file mode 100644
index 0000000..a704288
--- /dev/null
+++ b/test/special/node_modules/@scoped/scoped-single-binary-package/package.json
@@ -0,0 +1,3 @@
+{
+  "bin": "./bin/binary-exe"
+}
Repository: depcheck/depcheck
Pull request #831 (2023-08-28 23:31:56)

Support projects field in jest configuration


Patch:
diff --git a/src/special/jest.js b/src/special/jest.js
index 53d0e70..3363f0c 100644
--- a/src/special/jest.js
+++ b/src/special/jest.js
@@ -94,7 +94,14 @@ function filter(deps, options) {
 
 function checkOptions(deps, options = {}) {
   const pickedOptions = lodash(options).pick(supportedProperties).value();
-  return filter(deps, pickedOptions);
+  const baseFoundDeps = filter(deps, pickedOptions);
+  if (options.projects) {
+    const projectDeps = options.projects.map((projectConfig) =>
+      checkOptions(deps, projectConfig),
+    );
+    return baseFoundDeps.concat(...projectDeps);
+  }
+  return baseFoundDeps;
 }
 
 export default async function parseJest(filename, deps, rootDir) {


Test patch:
diff --git a/test/special/jest.js b/test/special/jest.js
index 0b0619e..6ed11e2 100644
--- a/test/special/jest.js
+++ b/test/special/jest.js
@@ -136,6 +136,26 @@ const testCases = [
       snapshotSerializers: ['jest-serializer-vue'],
     },
   },
+  {
+    name: 'recognize projects',
+    deps: ['babel-jest', 'vue-jest'],
+    content: {
+      projects: [
+        {
+          name: 'vue',
+          transform: {
+            '^.+\\.vue$': 'vue-jest',
+          },
+        },
+        {
+          name: 'babel',
+          transform: {
+            '^.+\\.js$': '<rootDir>/node_modules/babel-jest',
+          },
+        },
+      ],
+    },
+  },
 ];
 
 async function testJest(content, deps, expectedDeps, _filename) {
Repository: gregnb/mui-datatables
Pull request #590 (2019-05-03 07:33:20)

Added collaboration info
Added on README file the info for start to collaborate.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/23165753/badge)](https://coveralls.io/builds/23165753)

Coverage remained the same at 74.674% when pulling **f8517047bd971f0a8dbbefc4c09aab366d5b7ba2 on matteo1976:Collaboration-info** into **c434f2b8948dffde492b43cb1d7dc26f13327134 on gregnb:master**.

gabrielliwerant: This looks good to me! It should help people new to the project to get started, and we can add additional instructions as needed.

Patch:
diff --git a/README.md b/README.md
index 05aab14..5c963ef 100644
--- a/README.md
+++ b/README.md
@@ -363,10 +363,22 @@ const options = {
 }
 ```
 
+## Contributing
+Thanks for taking an interest in the library and the github community!
+
+The following commands should get you started:
+
+```sh
+npm i
+npm run dev
+```
+open  http://localhost:5050/ in browser
+
+After you make your changes locally, you can run the test suite with `npm test`. 
+
 ## License
 The files included in this repository are licensed under the MIT license.
 
-
 ## Thanks
 
 [<img src="https://www.browserstack.com/images/mail/browserstack-logo-footer.png" width="120">](https://www.browserstack.com/)
diff --git a/src/MUIDataTable.js b/src/MUIDataTable.js
index ba3dee8..7573a33 100644
--- a/src/MUIDataTable.js
+++ b/src/MUIDataTable.js
@@ -190,7 +190,7 @@ class MUIDataTable extends React.Component {
 
   componentDidUpdate(prevProps) {
     if (this.props.data !== prevProps.data || this.props.columns !== prevProps.columns) {
-      this.setTableData(prevProps, TABLE_LOAD.INITIAL);
+      this.setTableData(this.props, TABLE_LOAD.INITIAL);
     }
 
     if (this.options.resizableColumns) {


Test patch:
diff --git a/test/MUIDataTable.test.js b/test/MUIDataTable.test.js
index 0bea639..49607d5 100644
--- a/test/MUIDataTable.test.js
+++ b/test/MUIDataTable.test.js
@@ -170,6 +170,21 @@ describe('<MUIDataTable />', function() {
     assert.deepEqual(JSON.stringify(state.displayData), displayData);
   });
 
+  it('should correctly re-build display after xhr with serverSide=true', done => {
+    const fullWrapper = mount(<MUIDataTable columns={columns} data={[]} options={{ serverSide: true }} />);
+    assert.strictEqual(fullWrapper.find('tbody tr').length, 1);
+
+    // simulate xhr and test number of displayed rows
+    new Promise((resolve, reject) => {
+      setTimeout(() => {
+        fullWrapper.setProps({ data });
+        fullWrapper.update();
+        assert.strictEqual(fullWrapper.find('tbody tr').length, 4);
+        done();
+      }, 10);
+    });
+  });
+
   it('should correctly re-build internal table data and displayData structure with prop change', () => {
     const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
     let state = shallowWrapper.dive().state();
Repository: gregnb/mui-datatables
Pull request #766 (2019-07-12 04:19:21)

Bugfix/issue 764 select click ignoring is selectable
Fixes https://github.com/gregnb/mui-datatables/issues/764.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24522175/badge)](https://coveralls.io/builds/24522175)

Coverage increased (+0.2%) to 75.935% when pulling **bf236e3a7ff1536091243594d3447d30b82d1474 on bugfix/issue-764-select-click-ignoring-is-selectable** into **d09ed0c73257b9b4846b5ac6fb6c0da469b766fe on master**.


Patch:
diff --git a/src/components/TableBody.js b/src/components/TableBody.js
index eee66db..d6202f3 100644
--- a/src/components/TableBody.js
+++ b/src/components/TableBody.js
@@ -122,7 +122,7 @@ class TableBody extends React.Component {
     }
 
     // Check if we should toggle row select when row is clicked anywhere
-    if (this.props.options.selectableRowsOnClick && this.props.options.selectableRows !== 'none') {
+    if (this.props.options.selectableRowsOnClick && this.props.options.selectableRows !== 'none' && this.isRowSelectable(data.dataIndex)) {
       const selectRow = { index: data.rowIndex, dataIndex: data.dataIndex };
       this.handleRowSelect(selectRow);
     }


Test patch:
diff --git a/test/MUIDataTableBody.test.js b/test/MUIDataTableBody.test.js
index 2fb80ac..af6f3e2 100644
--- a/test/MUIDataTableBody.test.js
+++ b/test/MUIDataTableBody.test.js
@@ -235,6 +235,38 @@ describe('<TableBody />', function() {
     assert.strictEqual(toggleExpandRow.callCount, 0);
   });
 
+  it('should not gather selected row data when clicking row with selectableRowsOnClick=true when it is disabled with isRowSelectable.', () => {
+    let selectedRowData;
+    const options = { selectableRows: true, selectableRowsOnClick: true, isRowSelectable: dataIndex => dataIndex === 2 ? false : true };
+    const selectRowUpdate = (type, data) => (selectedRowData = data);
+    const toggleExpandRow = spy();
+
+    const mountWrapper = mount(
+      <TableBody
+        data={displayData}
+        count={displayData.length}
+        columns={columns}
+        page={0}
+        rowsPerPage={10}
+        selectedRows={[]}
+        selectRowUpdate={selectRowUpdate}
+        expandedRows={[]}
+        toggleExpandRow={toggleExpandRow}
+        options={options}
+        searchText={''}
+        filterList={[]}
+      />,
+    );
+
+    mountWrapper
+      .find('#MUIDataTableBodyRow-2')
+      .first()
+      .simulate('click');
+
+    assert.isUndefined(selectedRowData);
+    assert.strictEqual(toggleExpandRow.callCount, 0);
+  });
+
   it('should gather expanded row data when clicking row with expandableRows=true and expandableRowsOnClick=true.', () => {
     let expandedRowData;
     const options = { selectableRows: true, expandableRows: true, expandableRowsOnClick: true };