nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: sveltejs/kit
Pull request #5931 (2022-08-16 15:28:12)

use LayoutLoad inside +layout.js files
fixes a migration bug

changeset-bot[bot]: ###  🦋  Changeset detected

Latest commit: a0cf65adadf83886ad7ef28ffb112d805bbba2d5

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

  | Name           | Type  |
| -------------- | ----- |
| svelte-migrate | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/sveltejs/kit/new/migrate-layout-load?filename=.changeset/grumpy-fans-sing.md&value=---%0A%22svelte-migrate%22%3A%20patch%0A---%0A%0Ause%20LayoutLoad%20inside%20%2Blayout.js%20files%0A)



Patch:
diff --git a/.changeset/rare-spiders-ring.md b/.changeset/rare-spiders-ring.md
new file mode 100644
index 000000000..45de42c65
--- /dev/null
+++ b/.changeset/rare-spiders-ring.md
@@ -0,0 +1,5 @@
+---
+'svelte-migrate': patch
+---
+
+Use LayoutLoad inside +layout.js files
diff --git a/packages/migrate/migrations/routes/migrate_page_js/index.js b/packages/migrate/migrations/routes/migrate_page_js/index.js
index 5f60b7d49..308a9b9d0 100644
--- a/packages/migrate/migrations/routes/migrate_page_js/index.js
+++ b/packages/migrate/migrations/routes/migrate_page_js/index.js
@@ -37,8 +37,8 @@ export function migrate_page(content, filename) {
 		return content;
 	}
 
-	const match = /\+(?:(page)|(layout(?:-([^.@]+))?))/.exec(filename);
-	const load_name = match?.[3] ? `LayoutLoad.${match[3]}` : match?.[2] ? `LayoutLoad` : 'PageLoad';
+	const match = /__layout(?:-([^.@]+))?/.exec(filename);
+	const load_name = match?.[1] ? `LayoutLoad.${match[1]}` : match ? `LayoutLoad` : 'PageLoad';
 
 	for (const statement of file.ast.statements) {
 		const fn = name ? get_function_node(statement, name) : undefined;


Test patch:
diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js
index 4326213bc..f759e94c6 100644
--- a/packages/kit/test/apps/basics/test/client.test.js
+++ b/packages/kit/test/apps/basics/test/client.test.js
@@ -535,7 +535,7 @@ test.describe('Routing', () => {
 		await clicknav('a[href="/routing/a"]');
 		expect(await page.textContent('h1')).toBe('a');
 
-		expect(requests).toEqual([]);
+		expect(requests.filter((url) => !url.endsWith('/favicon.png'))).toEqual([]);
 	});
 
 	test('navigates programmatically', async ({ page, app }) => {
@@ -563,7 +563,7 @@ test.describe('Routing', () => {
 		const urls = [];
 
 		const { port, close } = await start_server((req, res) => {
-			urls.push(req.url);
+			if (req.url !== '/favicon.ico') urls.push(req.url);
 			res.end('ok');
 		});
Repository: calmm-js/partial.lenses
Pull request #11 (2016-03-14 12:46:25)

Added `L.pick`


Patch:
diff --git a/README.md b/README.md
index 889b694..c13860f 100644
--- a/README.md
+++ b/README.md
@@ -375,6 +375,19 @@ The main use case for `normalize` is to make it easy to determine whether, after
 a change, the data has actually changed.  By keeping the data normalized, a
 simple `R.equals` comparison will do.
 
+#### [`L.pick({p1: l1, ...pls})`](#lpickp1-l1-pls "L.pick :: {p1 :: PLens s a1, ...pls} -> PLens s {p1 :: a1, ...pls}")
+
+`L.pick({p1: l1, ...pls})` creates a lens out of the given object template of
+lenses.  When viewed, an object is created, whose properties are obtained by
+viewing through the lenses of the template.  When set with an object, the
+properties of the object are set to the context via the lenses of the template.
+`undefined` is treated as the equivalent of empty or non-existent in both
+directions.
+
+Note that, when set, `L.pick` simply ignores any properties that the given
+template doesn't mention.  Note that the underlying data structure need not be
+an object.
+
 #### [`L.prop(string)`](#lpropstring "L.prop :: (p :: a) -> PLens {p :: a, ...ps} a")
 
 `L.prop(string)` or `L(string)` is similar to `R.lensProp(string)` (see
diff --git a/src/partial.lenses.js b/src/partial.lenses.js
index a61cd1f..becb336 100644
--- a/src/partial.lenses.js
+++ b/src/partial.lenses.js
@@ -154,4 +154,24 @@ L.augment = template => R.lens(
     return z
   }))
 
+L.pick = template => L.lens(
+  c => {
+    let r
+    for (const k in template) {
+      const v = L.view(template[k], c)
+      if (v !== undefined) {
+        if (r === undefined)
+          r = {}
+        r[k] = v
+      }
+    }
+    return r
+  },
+  (o = {}, cIn) => {
+    let c = cIn
+    for (const k in template)
+      c = L.set(template[k], o[k], c)
+    return c
+  })
+
 export default L


Test patch:
diff --git a/test/tests.js b/test/tests.js
index 7ac526d..ef7386d 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -139,3 +139,13 @@ describe("L.augment", () => {
   testEq('L.set(L.augment({y: c => c.x+1}), {x: 2, y: 1}, {x: 0, y: -1})', {x: 2, y: -1})
   testEq('L.delete(L(L.augment({y: () => 1}), "x"), {x:0})', undefined)
 })
+
+describe("L.pick", () => {
+  testEq('L.view(L.pick({x: "c"}), {a: [2], b: 1})', undefined)
+  testEq('L.set(L(L.pick({x: "c"}), "x"), 4, {a: [2], b: 1})', {a: [2], b: 1, c: 4})
+  testEq('L.view(L.pick({x: "b", y: "a"}), {a: [2], b: 1})', {x: 1, y: [2]})
+  testEq('L.set(L(L.pick({x: "b", y: "a"}), "x"), 3, {a: [2], b: 1})', {a: [2], b: 3})
+  testEq('L.delete(L(L.pick({x: "b", y: "a"}), "y"), {a: [2], b: 1})', {b: 1})
+  testEq('L.delete(L(L.pick({x: "b"}), "x"), {a: [2], b: 1})', {a: [2]})
+  testEq('L.deleteAll(L(L.pick({x: "b", y: "a"}), L.firstOf("y", "x")), {a: [2], b: 1})', undefined)
+})
Repository: calmm-js/partial.lenses
Pull request #31 (2016-06-06 21:42:04)

Traversal over optional element.


Patch:
diff --git a/README.md b/README.md
index 6f1ab15..10cdcd7 100644
--- a/README.md
+++ b/README.md
@@ -905,6 +905,29 @@ L.collect(P("xs", L.sequence, "x"), {xs: [{x: 1}, {x: 2}]})
 // [ 1, 2 ]
 ```
 
+#### <a name="optional"></a>[`L.optional`](#optional "L.optional :: PTraversal a a")
+
+**`L.optional` is experimental and might be removed, renamed or changed
+semantically before next major release.**
+
+`L.optional` is a traversal (rather than a lens) over an optional element.  When
+the focus of `L.optional` is undefined, the traversal is empty.  Otherwise the
+traversal is over the focused element.
+
+As an example, consider the difference between:
+
+```js
+L.set(P(L.sequence, "x"), 3, [{x: 1}, {y: 2}])
+// [ { x: 3 }, { x: 3, y: 2 } ]
+```
+
+and:
+
+```js
+L.set(P(L.sequence, "x", L.optional), 3, [{x: 1}, {y: 2}])
+// [ { x: 3 }, { y: 2 } ]
+```
+
 #### <a name="sequence"></a>[`L.sequence`](#sequence "L.sequence :: PTraversal [a] a")
 
 **`L.sequence` is experimental and might be removed, renamed or changed
diff --git a/src/partial.lenses.js b/src/partial.lenses.js
index 92de7b5..0ec4e2b 100644
--- a/src/partial.lenses.js
+++ b/src/partial.lenses.js
@@ -289,6 +289,11 @@ export const sequence = constructor => inner => target =>
   R.traverse(constructor, inner, mkArray(target))
   .map(filtered)
 
+export const optional =
+  compose(lensI(toPartial(x => [x]),
+                toPartial(([x]) => x)),
+          sequence)
+
 export const fromRamda = l => _constructor => l
 export const toRamda = l =>
   lift(l)(() => {throw new Error("Sorry, `toRamda` is only fantasy!")})


Test patch:
diff --git a/test/tests.js b/test/tests.js
index 4a3b5e8..11531cd 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -258,6 +258,15 @@ describe("L.sequence", () => {
   testEq('L.modify(P(L.sequence, "x", L.sequence), R.add(1), [{x: [1]}, {y: "keep"}, {x: [], z: "these"}, {x: [2, 3]}])', [{x: [2]}, {y: "keep"}, {z: "these"}, {x: [3, 4]}])
 })
 
+describe("L.optional", () => {
+  testEq('L.collect(L.optional, undefined)', [])
+  testEq('L.collect(L.optional, 0)', [ 0 ])
+  testEq('L.collect(P(L.sequence, "x", L.optional), [{x: 1}, {y: 2}, {x: 3, z: 1}])', [1, 3])
+  testEq('L.modify(P(L.sequence, "x", L.optional), R.add(1), [{x: 1}, {y: 2}, {x: 3, z: 1}])', [{x: 2}, {y: 2}, {x: 4, z: 1}])
+  testEq('L.collect(P(L.sequence, "x", L.optional, L.sequence), [{x: [1, 2]}, {y: 2}, {x: [3], z: 1}])', [1, 2, 3])
+  testEq('L.modify(P(L.sequence, "x", L.optional, L.sequence), x => x < 2 ? undefined : x-1, [{x: [1, 2]}, {y: 2}, {x: [3], z: 1}])', [{x: [1]}, {y: 2}, {x: [2], z: 1}])
+})
+
 describe("L.collect", () => {
   testEq('L.collect(P("xs", L.sequence, "x", L.sequence), {xs: [{x:[3,1]},{x:[4,1]},{x:[5,9,2]}]})', [3,1,4,1,5,9,2])
   testEq('L.collect(P(L.sequence, "x", L.sequence), [{x: [1]}, {}, {x: []}, {x: [2, 3]}])', [1, 2, 3])
Repository: suitcss/preprocessor
Pull request #56 (2016-10-20 07:58:47)

Don't reorder core plugins


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3947d0..745bbbd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
 ### HEAD
 
+* Pin core plugins order:
+
+  `postcss-easy-import`
+  [ user plugins ]
+  [ encapsulation plugins ]
+  `autoprefixer`
+  `postcss-reporter`
+* Add experimental `encapsulate` option/feature
 * CLI flags override config file options
 * Input file is now linted (previously only imported files were passed through
   the linting tools)
diff --git a/lib/index.js b/lib/index.js
index 5c52b84..da08051 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -133,9 +133,14 @@ function mergeOptions(options) {
   // but remove any duplicates so that it respects the new order
   if (!isEmpty(options.use)) {
     var plugins = difference(mergedOpts.use, options.use);
-    mergedOpts.use = plugins.concat(options.use);
+    // Remove core plugins. Can't reorder them
+    var userPlugins = difference(options.use, [
+      'postcss-easy-import',
+      'autoprefixer',
+      'postcss-reporter'
+    ]);
+    mergedOpts.use = plugins.concat(userPlugins);
   }
-
   return mergedOpts;
 }
 


Test patch:
diff --git a/test/options.js b/test/options.js
index a3e115f..44840ff 100644
--- a/test/options.js
+++ b/test/options.js
@@ -63,7 +63,7 @@ describe('re-ordering the `use` array of postcss plugins', function() {
 
   it('should allow reordering of use array and remove duplicates', function() {
     var opts = mergeOptions({
-      use: ['postcss-at2x', 'postcss-calc']
+      use: ['postcss-at2x', 'postcss-easy-import', 'postcss-calc']
     });
 
     expect(opts.use).to.eql([
Repository: suitcss/preprocessor
Pull request #66 (2016-11-28 12:23:51)

Allow config file to be arbitrarily named
this is a stab at #65 - if you guys should choose to change the behaviour

simonsmith: Just re-running the windows build
simonsmith: I think we could squash this into one commit and just reference the issue in the description. Are you happy to do that @casio?
casio: @simonsmith yup, here you go

Patch:
diff --git a/bin/suitcss b/bin/suitcss
index 85c4be1..6208c77 100755
--- a/bin/suitcss
+++ b/bin/suitcss
@@ -63,9 +63,16 @@ program.parse(process.argv);
  * Settings.
  */
 
+function requireOrParse(configFile) {
+  var configPath = resolve(configFile);
+  var ext = path.extname(configPath);
+  var readFn = /js|json/.test(ext) ? require : fs.readJsonSync;
+  return readFn(configPath);
+}
+
 var input = program.args[0] ? resolve(program.args[0]) : null;
 var output = program.args[1] ? resolve(program.args[1]) : null;
-var config = program.config ? require(resolve(program.config)) : null;
+var config = program.config ? requireOrParse(program.config) : {};
 var verbose = program.verbose;
 var regen = program.watch && input && output;
 


Test patch:
diff --git a/test/cli.js b/test/cli.js
index 29aea4b..3de6f79 100644
--- a/test/cli.js
+++ b/test/cli.js
@@ -76,7 +76,7 @@ describe('cli', function() {
     });
   });
 
-  it('should allow a config file to be passed', function(done) {
+  it('should allow a config module to be passed', function(done) {
     exec('node bin/suitcss -i test/fixtures -c test/config/test.js test/fixtures/config.css test/fixtures/cli/output.css', function(err) {
       if (err) return done(err);
       var res = util.read('fixtures/cli/output');
@@ -86,6 +86,16 @@ describe('cli', function() {
     });
   });
 
+  it('should allow an arbitrarily named json config file to be passed', function(done) {
+    exec('node bin/suitcss -i test/fixtures -c test/config/test.config test/fixtures/config.css test/fixtures/cli/output.css', function(err) {
+      if (err) return done(err);
+      var res = util.read('fixtures/cli/output');
+      var expected = util.read('fixtures/config.out');
+      expect(res).to.equal(expected);
+      done();
+    });
+  });
+
   it('should allow to override config options via cli flags', function(done) {
     exec('node bin/suitcss -m -c test/config/test.js test/fixtures/import.css test/fixtures/cli/output.css', function(err) {
       if (err) return done(err);
diff --git a/test/config/test.config b/test/config/test.config
new file mode 100644
index 0000000..c0677c7
--- /dev/null
+++ b/test/config/test.config
@@ -0,0 +1,11 @@
+{
+  "lint": true,
+  "minify": false,
+  "use": [
+    "postcss-property-lookup"
+  ],
+  "autoprefixer": {
+    "add": false,
+    "remove": false
+  }
+}
Repository: robsontenorio/vue-api-query
Pull request #115 (2020-06-22 18:49:13)

check if id is not null
When an entity is being saved, nulls are considered as existing entities, so it tries to update and not insert

robsontenorio: @Keilost Thanks for PR. Please, could you included into PR the tests where that scenario would fail?
Keilost: @robsontenorio hello, done!

Patch:
diff --git a/src/Model.js b/src/Model.js
index 8ac1ad2..560c581 100644
--- a/src/Model.js
+++ b/src/Model.js
@@ -138,7 +138,7 @@ export default class Model extends StaticModel {
   }
 
   isValidId(id) {
-    return id !== undefined && id !== 0 && id !== ''
+    return id !== undefined && id !== 0 && id !== '' && id !== null
   }
 
   endpoint() {


Test patch:
diff --git a/tests/model.test.js b/tests/model.test.js
index 29a59c2..59fccb3 100644
--- a/tests/model.test.js
+++ b/tests/model.test.js
@@ -320,6 +320,22 @@ describe('Model methods', () => {
     comment.save()
   })
 
+  test('save() method makes a POST request when ID of object is null', async () => {
+    let post
+
+    axiosMock.onAny().reply((config) => {
+      expect(config.method).toEqual('post')
+      expect(config.data).toEqual(JSON.stringify(post))
+      expect(config.url).toEqual('http://localhost/posts')
+
+      return [200, {}]
+    })
+
+    post = new Post({ id: null, title: 'Cool!' })
+    await post.save()
+
+  })
+
   test('a request from delete() method hits the right resource', async () => {
 
     axiosMock.onAny().reply((config) => {
Repository: robsontenorio/vue-api-query
Pull request #139 (2020-11-01 15:16:23)

v1.7.1


Patch:
diff --git a/docs/content/en/api/query-builder-methods.md b/docs/content/en/api/query-builder-methods.md
index b9e3015..e254337 100644
--- a/docs/content/en/api/query-builder-methods.md
+++ b/docs/content/en/api/query-builder-methods.md
@@ -22,7 +22,7 @@ await Model.include('user', 'category')
 Append attributes.
 
 ```js
-await Model.include('likes')
+await Model.append('likes')
 ```
 
 ## `select`
diff --git a/src/Model.js b/src/Model.js
index 28e75c3..1510716 100644
--- a/src/Model.js
+++ b/src/Model.js
@@ -107,12 +107,12 @@ export default class Model extends StaticModel {
     let url = `${this.baseURL()}`;
 
     args.forEach(object => {
-      if (object instanceof Model === false) {
+      if (!(object instanceof Model)) {
         throw new Error('The object referenced on for() method is not a valid Model.')
       }
 
       if (!this.isValidId(object.getPrimaryKey())) {
-        throw new Error('The object referenced on for() method has a invalid id.')
+        throw new Error('The object referenced on for() method has an invalid id.')
       }
 
       url += `/${object.resource()}/${object.getPrimaryKey()}`
@@ -139,7 +139,7 @@ export default class Model extends StaticModel {
   }
 
   isValidId(id) {
-    return id !== undefined && id !== 0 && id !== '' && id !== null
+    return !!id
   }
 
   endpoint() {


Test patch:
diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml
index b3def74..a3f39af 100644
--- a/.github/workflows/test-and-release.yml
+++ b/.github/workflows/test-and-release.yml
@@ -12,7 +12,7 @@ on:
 
 jobs:
   test:
-    name: Build & Test
+    name: Test
 
     runs-on: ${{ matrix.os }}
 
@@ -77,8 +77,8 @@ jobs:
         if: steps.cache-modules.outputs.cache-hit != 'true'
         run: yarn install
 
-      - name: Test
-        run: yarn test
+      - name: Build
+        run: yarn build
 
       - name: Upload Coverage to Codecov
         uses: codecov/codecov-action@v1
diff --git a/tests/model.test.js b/tests/model.test.js
index 8040c5b..9183dbf 100644
--- a/tests/model.test.js
+++ b/tests/model.test.js
@@ -671,7 +671,7 @@ describe('Model methods', () => {
       const post = new Post({ text: 'Hello' }).for(user)
     }
 
-    expect(errorModel).toThrow('The object referenced on for() method has a invalid id.')
+    expect(errorModel).toThrow('The object referenced on for() method has an invalid id.')
   })
 
   test('it throws a error when a custom() parameter is not a valid Model or a string', () => {
Repository: robsontenorio/vue-api-query
Pull request #154 (2020-11-27 16:53:01)

fix(builder): multiple nested filters were not working
Bug reported by @dionysiosarvanitis https://github.com/robsontenorio/vue-api-query/pull/141#issuecomment-734864160


Patch:
diff --git a/src/Builder.js b/src/Builder.js
index af127cc..af93056 100644
--- a/src/Builder.js
+++ b/src/Builder.js
@@ -109,7 +109,7 @@ export default class Builder {
     if (Array.isArray(key)) {
       const [_key, _value] = this._nestedFilter(key, value)
 
-      this.filters[_key] = _value
+      this.filters[_key] = { ...this.filters[_key], ..._value }
     } else {
       this.filters[key] = value
     }
@@ -125,7 +125,7 @@ export default class Builder {
     if (Array.isArray(key)) {
       const [_key, _value] = this._nestedFilter(key, array.join(','))
 
-      this.filters[_key] = _value
+      this.filters[_key] = { ...this.filters[_key], ..._value }
     } else {
       this.filters[key] = array.join(',')
     }


Test patch:
diff --git a/tests/builder.test.js b/tests/builder.test.js
index c100662..6355910 100644
--- a/tests/builder.test.js
+++ b/tests/builder.test.js
@@ -121,6 +121,13 @@ describe('Query builder', () => {
 
     expect(post._builder.filters).toEqual({ user: { status: 'active' } })
     expect(post._builder.query()).toEqual('?filter[user][status]=active')
+
+    post = Post
+      .where(['schedule', 'start'], '2020-11-27')
+      .where(['schedule', 'end'], '2020-11-28')
+
+    expect(post._builder.filters).toEqual({ schedule: { start: '2020-11-27', end: '2020-11-28' } })
+    expect(post._builder.query()).toEqual('?filter[schedule][start]=2020-11-27&filter[schedule][end]=2020-11-28')
   })
 
   test('where() throws a exception when doest not have params or only first param', () => {
@@ -152,7 +159,15 @@ describe('Query builder', () => {
 
     post = Post.whereIn(['user', 'status'], ['active', 'inactive'])
 
+    expect(post._builder.filters).toEqual({ user: { status: 'active,inactive'  } })
     expect(post._builder.query()).toEqual('?filter[user][status]=active,inactive')
+
+    post = Post
+      .whereIn(['schedule', 'start'], ['2020-11-27', '2020-11-28'])
+      .whereIn(['schedule', 'end'], ['2020-11-28', '2020-11-29'])
+
+    expect(post._builder.filters).toEqual({ schedule: { start: '2020-11-27,2020-11-28', end: '2020-11-28,2020-11-29' } })
+    expect(post._builder.query()).toEqual('?filter[schedule][start]=2020-11-27,2020-11-28&filter[schedule][end]=2020-11-28,2020-11-29')
   })
 
   test('whereIn() throws a exception when second parameter is not a array', () => {