nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: IduxFE/components
Pull request #191 (2021-02-05 09:18:27)

fix(comp: typography): fix custom class
## PR Checklist

Please check if your PR fulfills the following requirements:

- [x] The commit message follows [our guidelines](https://github.com/IduxFE/components/blob/main/docs/contributing.zh.md#commit)
- [x] Tests for the changes have been added/updated or not needed
- [x] Docs and demo have been added/updated or not needed

## PR Type

What kind of change does this PR introduce?

- [x] Bugfix
- [ ] Feature
- [ ] Component style update
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Application (the showcase website) / infrastructure changes
- [ ] Other... Please describe:

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->

## What is the new behavior?

## Other information



Patch:
diff --git a/packages/components/typography/src/typography.ts b/packages/components/typography/src/typography.ts
index 07d5a574..fa013cad 100644
--- a/packages/components/typography/src/typography.ts
+++ b/packages/components/typography/src/typography.ts
@@ -5,7 +5,7 @@ import { isNil, isString } from '@idux/cdk/utils'
 import { Logger } from '@idux/components/core/logger'
 
 const typography: Directive<HTMLElement, TypographyConfig> = (el, binding) => {
-  const classNames: string[] = ['ix-typography']
+  const classNames: string[] = [...Array.from(el.classList), 'ix-typography']
   const { value } = binding
   const options: TypographyOptions = isString(value) || isNil(value) ? { type: value } : value
 


Test patch:
diff --git a/packages/components/typography/__tests__/typography.spec.ts b/packages/components/typography/__tests__/typography.spec.ts
index d53f9664..4f4ea30b 100644
--- a/packages/components/typography/__tests__/typography.spec.ts
+++ b/packages/components/typography/__tests__/typography.spec.ts
@@ -96,4 +96,21 @@ describe('typography.ts', () => {
     expect(wrapper.classes()).toEqual(['ix-typography'])
     expect(error).toBeCalled()
   })
+
+  test('custom class', async () => {
+    const TestComponent = {
+      props: ['type'],
+      template: `
+      <p v-typography="type">Paragraph</p>
+      `,
+    }
+    const wrapper = typographyMount(TestComponent)
+    expect(wrapper.classes()).toEqual(['ix-typography'])
+
+    await wrapper.setProps({ class: 'custom-paragraph' })
+    expect(wrapper.classes()).toEqual(['custom-paragraph', 'ix-typography'])
+
+    await wrapper.setProps({ type: 'success' })
+    expect(wrapper.classes()).toEqual(['custom-paragraph', 'ix-typography', 'ix-typography-success'])
+  })
 })
Repository: Hacker0x01/react-datepicker
Pull request #4692 (2024-04-15 15:16:13)

fix: #4400 Keyboard accessibility MonthYearPicker
## Description
**Linked issue**: #4400

**Problem**
Focus calender month when the user presses down or up arrow keys in input field. This makes Datepicker accessible when only using keyboard.

## Contribution checklist
- [x] I have followed the [contributing guidelines](https://github.com/Hacker0x01/react-datepicker/blob/main/CONTRIBUTING.md).
- [x] I have added sufficient test coverage for my changes.
- [x] I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.



Patch:
diff --git a/src/index.jsx b/src/index.jsx
index 9f572cf3..627ae4e8 100644
--- a/src/index.jsx
+++ b/src/index.jsx
@@ -838,7 +838,10 @@ export default class DatePicker extends React.Component {
         const selectorString =
           this.props.showWeekPicker && this.props.showWeekNumbers
             ? '.react-datepicker__week-number[tabindex="0"]'
-            : '.react-datepicker__day[tabindex="0"]';
+            : this.props.showFullMonthYearPicker ||
+                this.props.showMonthYearPicker
+              ? '.react-datepicker__month-text[tabindex="0"]'
+              : '.react-datepicker__day[tabindex="0"]';
         const selectedItem =
           this.calendar.componentNode &&
           this.calendar.componentNode.querySelector(selectorString);


Test patch:
diff --git a/test/datepicker_test.test.js b/test/datepicker_test.test.js
index efca1537..5bf1d8af 100644
--- a/test/datepicker_test.test.js
+++ b/test/datepicker_test.test.js
@@ -1285,6 +1285,25 @@ describe("DatePicker", () => {
     fireEvent.keyDown(data.dateInput, getKey("ArrowDown"));
     expect(data.instance.state.open).toBe(true);
   });
+  it("should focus first month when the down arrow key is pressed", async () => {
+    const div = document.createElement("div");
+    document.body.appendChild(div);
+    render(<DatePicker showMonthYearPicker />, {
+      container: div,
+    });
+
+    // user focuses the input field, the calendar opens
+    const dateInput = div.querySelector("input");
+    fireEvent.focus(dateInput);
+    fireEvent.keyDown(dateInput, getKey("ArrowDown"));
+
+    await waitFor(() => {
+      const selectedMonth = div.querySelector(
+        '.react-datepicker__month-text[tabindex="0"]',
+      );
+      expect(document.activeElement).toBe(selectedMonth);
+    });
+  });
   it("should not open the calendar when the left arrow key is pressed", () => {
     const data = getOnInputKeyDownStuff();
     act(() => {
Repository: Hacker0x01/react-datepicker
Pull request #4712 (2024-04-23 08:25:18)

♻️ Refactor date picker header to use semantic <h2> element
## Description
**Linked issue**: #4703

This PR updates the date picker header from a <div> to a semantic <h2> element for improved accessibility. 

## Contribution checklist
- [x] I have followed the [contributing guidelines](https://github.com/Hacker0x01/react-datepicker/blob/main/CONTRIBUTING.md).
- [x] I have added sufficient test coverage for my changes.
- [x] I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.



Patch:
diff --git a/src/calendar.jsx b/src/calendar.jsx
index b12e2ada..b4ddbfd3 100644
--- a/src/calendar.jsx
+++ b/src/calendar.jsx
@@ -687,9 +687,9 @@ export default class Calendar extends React.Component {
       classes.push("react-datepicker__current-month--hasMonthYearDropdown");
     }
     return (
-      <div className={classes.join(" ")}>
+      <h2 className={classes.join(" ")}>
         {formatDate(date, this.props.dateFormat, this.props.locale)}
-      </div>
+      </h2>
     );
   };
 
diff --git a/src/stylesheets/datepicker.scss b/src/stylesheets/datepicker.scss
index 94a882c9..83b2be6a 100644
--- a/src/stylesheets/datepicker.scss
+++ b/src/stylesheets/datepicker.scss
@@ -100,6 +100,11 @@
   font-size: $datepicker__font-size * 1.18;
 }
 
+h2.react-datepicker__current-month {
+  padding: 0;
+  margin: 0;
+}
+
 .react-datepicker-time__header {
   text-overflow: ellipsis;
   white-space: nowrap;


Test patch:
diff --git a/test/calendar_test.test.js b/test/calendar_test.test.js
index 8b70b1fd..3def75f2 100644
--- a/test/calendar_test.test.js
+++ b/test/calendar_test.test.js
@@ -155,6 +155,12 @@ describe("Calendar", () => {
     expect(utils.isSameDay(instance.date, oneMonthFromOpenToDate));
   });
 
+  it("should render month and year as a header of datepicker by default", () => {
+    const { calendar } = getCalendar();
+    const header = calendar.querySelector("h2.react-datepicker__current-month");
+    expect(header).not.toBeNull();
+  });
+
   it("should not show the year dropdown menu by default", () => {
     const { calendar } = getCalendar();
     const yearReadView = calendar.querySelectorAll(
Repository: chimurai/http-proxy-middleware
Pull request #480 (2020-10-27 09:48:52)

Preventing the fail of the 'ETIMEDOUT' code in 500 'Internal server error'
Currently `ETIMEDOUT` code is handled by the `defaultErrorHandler` as a `[500] Internal Server Error`. 
It should be handled as the regular `ECONNRESET` || `ENOTFOUND` || `ECONNREFUSED` || `ETIMEDOUT` codes.

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

Coverage remained the same at 88.301% when pulling **e4961b1d18e95a4e8793a40e393eb4e2f02f1f4c on aremishevsky:master** into **f212a047ef45898ce6053b622cada4b0617b9ddf on chimurai:master**.

aremishevsky: @chimurai could you please review this PR?
aremishevsky: Can someone review and merge this PR?
chimurai: Can you add `ETIMEDOUT` to this unit test with the `504` response?

https://github.com/chimurai/http-proxy-middleware/blob/master/test/unit/handlers.spec.ts#L101
aremishevsky: @chimurai I did that https://github.com/chimurai/http-proxy-middleware/pull/480/files#diff-5dce20e137b0cf4ccabefadbb48baf14ef3c1d68b2dad6aa2b45d4bfbfbdf2e3R107
chimurai: Oops, missed that. 🙈

Patch:
diff --git a/src/handlers.ts b/src/handlers.ts
index 344c7ea..4abd235 100644
--- a/src/handlers.ts
+++ b/src/handlers.ts
@@ -54,6 +54,7 @@ function defaultErrorHandler(err, req, res) {
         case 'ECONNRESET':
         case 'ENOTFOUND':
         case 'ECONNREFUSED':
+        case 'ETIMEDOUT':
           res.writeHead(504);
           break;
         default:


Test patch:
diff --git a/test/unit/handlers.spec.ts b/test/unit/handlers.spec.ts
index 385cc72..b64a850 100644
--- a/test/unit/handlers.spec.ts
+++ b/test/unit/handlers.spec.ts
@@ -104,6 +104,7 @@ describe('default proxy error handler', () => {
     ['ECONNREFUSED', 504],
     ['ENOTFOUND', 504],
     ['ECONNREFUSED', 504],
+    ['ETIMEDOUT', 504],
     ['any', 500],
   ];
Repository: chimurai/http-proxy-middleware
Pull request #517 (2021-04-06 19:19:35)

fix(error handler): re-throw http-proxy missing target error
Background:
With `router` usage and optional `target` (#512); Required `target` for http-proxy can sometimes be empty.

This PR will re-throw the error emitted from `http-proxy`.

`req` and `res` object are empty, so there is no graceful way to handle this error...

In these cases  it recommended to set `target` as fallback.



Patch:
diff --git a/src/handlers.ts b/src/handlers.ts
index 7e2b0e3..e44e5dc 100644
--- a/src/handlers.ts
+++ b/src/handlers.ts
@@ -54,6 +54,11 @@ export function getHandlers(options: Options) {
 }
 
 function defaultErrorHandler(err, req: express.Request, res: express.Response) {
+  // Re-throw error. Not recoverable since req & res are empty.
+  if (!req && !res) {
+    throw err; // "Error: Must provide a proper URL as target"
+  }
+
   const host = req.headers && req.headers.host;
   const code = err.code;
 


Test patch:
diff --git a/test/unit/handlers.spec.ts b/test/unit/handlers.spec.ts
index 792b733..5578927 100644
--- a/test/unit/handlers.spec.ts
+++ b/test/unit/handlers.spec.ts
@@ -133,4 +133,11 @@ describe('default proxy error handler', () => {
     proxyError(mockError, mockReq, mockRes, proxyOptions);
     expect(errorMessage).toBe('Error occured while trying to proxy: localhost:3000/api');
   });
+
+  it('should re-throw error from http-proxy when target is missing', () => {
+    mockRes.headersSent = true;
+    const error = new Error('Must provide a proper URL as target');
+    const fn = () => proxyError(error, undefined, undefined, proxyOptions);
+    expect(fn).toThrowError(error);
+  });
 });
Repository: chimurai/http-proxy-middleware
Pull request #1089 (2025-04-06 09:06:57)

fix(fixRequestBody): prevent multiple .write() calls
Causing this error: `Cannot set headers after they are sent to the client`

pkg-pr-new[bot]: 



```
npm i https://pkg.pr.new/http-proxy-middleware@1089
```


_commit: <a href="https://github.com/chimurai/http-proxy-middleware/runs/40052137868"><code>003b2a2</code></a>_


Patch:
diff --git a/src/handlers/fix-request-body.ts b/src/handlers/fix-request-body.ts
index 1286ce5..6943b27 100644
--- a/src/handlers/fix-request-body.ts
+++ b/src/handlers/fix-request-body.ts
@@ -17,21 +17,23 @@ export function fixRequestBody<TReq = http.IncomingMessage>(
   }
 
   const contentType = proxyReq.getHeader('Content-Type') as string;
+
+  if (!contentType) {
+    return;
+  }
+
   const writeBody = (bodyData: string) => {
-    // deepcode ignore ContentLengthInCode: bodyParser fix
     proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));
     proxyReq.write(bodyData);
   };
 
-  if (contentType && (contentType.includes('application/json') || contentType.includes('+json'))) {
+  // Use if-elseif to prevent multiple writeBody/setHeader calls:
+  // Error: "Cannot set headers after they are sent to the client"
+  if (contentType.includes('application/json') || contentType.includes('+json')) {
     writeBody(JSON.stringify(requestBody));
-  }
-
-  if (contentType && contentType.includes('application/x-www-form-urlencoded')) {
+  } else if (contentType.includes('application/x-www-form-urlencoded')) {
     writeBody(querystring.stringify(requestBody));
-  }
-
-  if (contentType && contentType.includes('multipart/form-data')) {
+  } else if (contentType.includes('multipart/form-data')) {
     writeBody(handlerFormDataBodyData(contentType, requestBody));
   }
 }


Test patch:
diff --git a/test/unit/fix-request-body.spec.ts b/test/unit/fix-request-body.spec.ts
index 2f1b660..0c81546 100644
--- a/test/unit/fix-request-body.spec.ts
+++ b/test/unit/fix-request-body.spec.ts
@@ -154,4 +154,19 @@ describe('fixRequestBody', () => {
     expect(proxyRequest.setHeader).toHaveBeenCalledWith('Content-Length', expectedBody.length);
     expect(proxyRequest.write).toHaveBeenCalledWith(expectedBody);
   });
+
+  it('should parse json and call write() once with incorrect content-type application/x-www-form-urlencoded+json', () => {
+    const proxyRequest = fakeProxyRequest();
+    proxyRequest.setHeader('content-type', 'application/x-www-form-urlencoded+json');
+
+    jest.spyOn(proxyRequest, 'setHeader');
+    jest.spyOn(proxyRequest, 'write');
+
+    fixRequestBody(proxyRequest, createRequestWithBody({ someField: 'some value' }));
+
+    const expectedBody = JSON.stringify({ someField: 'some value' });
+    expect(proxyRequest.setHeader).toHaveBeenCalledWith('Content-Length', expectedBody.length);
+    expect(proxyRequest.write).toHaveBeenCalledTimes(1);
+    expect(proxyRequest.write).toHaveBeenCalledWith(expectedBody);
+  });
 });
Repository: chimurai/http-proxy-middleware
Pull request #1104 (2025-04-16 17:18:18)

fix(types): fix Logger type
## Description

fixes #1100 

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)


pkg-pr-new[bot]: 



```
npm i https://pkg.pr.new/http-proxy-middleware@1104
```


_commit: <a href="https://github.com/chimurai/http-proxy-middleware/runs/40672612107"><code>4d3ad66</code></a>_


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6a56e7e..92fe7b2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## next
+
+- fix(types): fix Logger type
+
 ## [v3.0.5](https://github.com/chimurai/http-proxy-middleware/releases/tag/v3.0.5)
 
 - fix(fixRequestBody): check readableLength ([#1096](https://github.com/chimurai/http-proxy-middleware/pull/1096))
diff --git a/src/types.ts b/src/types.ts
index c4c5e30..31900d3 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -136,5 +136,5 @@ export interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse
    * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/logger.md
    * @since v3.0.0
    */
-  logger?: Logger | any;
+  logger?: Logger;
 }


Test patch:
diff --git a/test/types.spec.ts b/test/types.spec.ts
index a07117a..39e1abc 100644
--- a/test/types.spec.ts
+++ b/test/types.spec.ts
@@ -101,6 +101,33 @@ describe('http-proxy-middleware TypeScript Types', () => {
         options = { logger: console };
         expect(options).toBeDefined();
       });
+
+      it('should allow custom logger option', () => {
+        const customLogger = {
+          info: () => {},
+          warn: () => {},
+          error: () => {},
+        };
+        options = { logger: customLogger };
+        expect(options).toBeDefined();
+      });
+
+      it('should fail when custom logger has missing log function', () => {
+        const customLogger = {
+          info: () => {},
+          // warn: () => {},
+          error: () => {},
+        };
+        // @ts-expect-error explanation: should error when customLogger has a missing log function
+        options = { logger: customLogger };
+        expect(options).toBeDefined();
+      });
+
+      it('should fail when invalid logger is provided', () => {
+        // @ts-expect-error explanation: should error when invalid logger is provided
+        options = { logger: 500 };
+        expect(options).toBeDefined();
+      });
     });
 
     describe('on', () => {
Repository: platers/obsidian-linter
Pull request #15 (2021-09-02 02:37:01)

1.1.3
New version
Ignore non words in capitalization


Patch:
diff --git a/manifest.json b/manifest.json
index c0791ae..bbb7017 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
 {
 	"id": "obsidian-linter",
 	"name": "Linter",
-	"version": "1.1.2",
+	"version": "1.1.3",
 	"minAppVersion": "0.9.7",
 	"description": "Enforces consistent markdown styling.",
 	"author": "Victor Tao",
diff --git a/rules.ts b/rules.ts
index 867c4e5..f830a29 100644
--- a/rules.ts
+++ b/rules.ts
@@ -329,19 +329,19 @@ export const rules: Rule[] = [
 					continue;
 				}
 				if (options["titleCase"] == "true") {
-					const headerWords = lines[i].match(/\w+/g);
+					const headerWords = lines[i].match(/\S+/g);
 					const ignore = ["a", "an", "the", "and", "or", "but", "for", "nor", "so", "yet", "at", "by", "in", "of", "on", "to", "up", "as", "is", "if", "it", "for", "to", "with"];
 					for (let j = 0; j < headerWords.length; j++) {
-						if (ignore.includes(headerWords[j]) && j != 0) { // ignore words that are not capitalized in titles except if they are the first word
-							continue;
+						const ignoreWord = ignore.includes(headerWords[j]) && j != 1; // ignore words that are not capitalized in titles except if they are the first word
+						const isNotWord = headerWords[j].match(/[^A-Z^a-z]/); // ignore non-words
+						if (!ignoreWord && !isNotWord) { 
+							headerWords[j] = headerWords[j].replace(/^./, c => c.toUpperCase());
 						}
-						headerWords[j] = headerWords[j].replace(/^\w/, c => c.toUpperCase());
 					}
 
-					lines[i] = lines[i].replace(headerRegex, `$1${headerWords.join(" ")}`);
-
+					lines[i] = lines[i].replace(headerRegex, `${headerWords.join(" ")}`);
 				} else if (options["allCaps"] == "true") {
-					lines[i] = lines[i].replace(/^#*\s\w.*/, string => string.toUpperCase()) // convert full heading to uppercase
+					lines[i] = lines[i].toUpperCase() // convert full heading to uppercase
 				} else {
 					lines[i] = lines[i].replace(/^#*\s([a-z])/, string => string.toUpperCase()) // capitalize first letter of heading
 				}


Test patch:
diff --git a/test.ts b/test.ts
index a46162d..3da7709 100644
--- a/test.ts
+++ b/test.ts
@@ -105,6 +105,19 @@ describe("Rules tests", () => {
 			expect(rulesDict["header-increment"].apply(before)).toBe(after);
 		});
 	});
+	describe("Capitalize Headings", () => {
+		it("Ignores not words", () => {
+			const before = dedent`
+				# h1
+				## a c++ lang
+				`;
+			const after = dedent`
+				# h1
+				## A c++ Lang
+				`;
+			expect(rulesDict["capitalize-headings"].apply(before, {titleCase: "true"})).toBe(after);
+		});
+	});
 });
 
 describe("Option parsing", () => {
Repository: platers/obsidian-linter
Pull request #21 (2021-09-06 03:53:00)

smarter ignored words logic in capitalize headers


Patch:
diff --git a/rules.ts b/rules.ts
index d8965cf..b943dbb 100644
--- a/rules.ts
+++ b/rules.ts
@@ -332,8 +332,8 @@ export const rules: Rule[] = [
             const headerWords = lines[i].match(/\S+/g);
             const ignore = ['a', 'an', 'the', 'and', 'or', 'but', 'for', 'nor', 'so', 'yet', 'at', 'by', 'in', 'of', 'on', 'to', 'up', 'as', 'is', 'if', 'it', 'for', 'to', 'with'];
             for (let j = 1; j < headerWords.length; j++) {
-              const isNotWord = headerWords[j].match(/[^A-Z^a-z]/); // ignore non-words
-              if (isNotWord) {
+              const isWord = headerWords[j].match(/^[A-Za-z'-]+[\.\?\!]?$/);
+              if (!isWord) {
                 continue;
               }
 


Test patch:
diff --git a/test.ts b/test.ts
index 7a30b5e..5610907 100644
--- a/test.ts
+++ b/test.ts
@@ -109,11 +109,15 @@ describe('Rules tests', () => {
     it('Ignores not words', () => {
       const before = dedent`
         # h1
-        ## a c++ lang
+        ## a c++ lan
+        ## this is a sentence.
+        ## I can't do thisg
         `;
       const after = dedent`
         # h1
-        ## A c++ Lang
+        ## A c++ Lan
+        ## This is a Sentence.
+        ## I Can't Do Thisg
         `;
       expect(rulesDict['capitalize-headings'].apply(before, {titleCase: 'true'})).toBe(after);
     });