Skip to content

Commit 4b60eca

Browse files
fix(mcp): return correct lines on typescript errors
1 parent 878386a commit 4b60eca

File tree

6 files changed

+80
-0
lines changed

6 files changed

+80
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1
2+
FROM debian:bookworm-slim AS stainless
3+
4+
RUN apt-get update && apt-get install -y \
5+
nodejs \
6+
npm \
7+
yarnpkg \
8+
&& apt-get clean autoclean
9+
10+
# Ensure UTF-8 encoding
11+
ENV LANG=C.UTF-8
12+
ENV LC_ALL=C.UTF-8
13+
14+
# Yarn
15+
RUN ln -sf /usr/bin/yarnpkg /usr/bin/yarn
16+
17+
WORKDIR /workspace
18+
19+
COPY package.json yarn.lock /workspace/
20+
21+
RUN yarn install
22+
23+
COPY . /workspace

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
plugins: ['@typescript-eslint', 'unused-imports', 'prettier'],
4+
rules: {
5+
'no-unused-vars': 'off',
6+
'prettier/prettier': 'error',
7+
'unused-imports/no-unused-imports': 'error',
8+
},
9+
root: true,
10+
};

jest.setup.ts

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* This file polyfills the global `File` object for you if it's not already defined
3+
* when running on Node.js
4+
*
5+
* This is only needed on Node.js v18 & v19. Newer versions already define `File`
6+
* as a global.
7+
*/
8+
9+
// @ts-ignore
10+
type nodeBuffer = typeof import('node:buffer');
11+
declare const File: typeof globalThis extends { File: unknown } ? (typeof globalThis)['File']
12+
: nodeBuffer extends { File: unknown } ? nodeBuffer['File']
13+
: any;
14+
export {};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* This file polyfills the global `File` object for you if it's not already defined
3+
* when running on Node.js
4+
*
5+
* This is only needed on Node.js v18 & v19. Newer versions already define `File`
6+
* as a global.
7+
*/
8+
9+
import './file.node.js';

tests/responses.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { createResponseHeaders } from '@gitpod/sdk/internal/headers';
2+
3+
describe('response parsing', () => {
4+
// TODO: test unicode characters
5+
test('headers are case agnostic', async () => {
6+
const headers = createResponseHeaders(new Headers({ 'Content-Type': 'foo', Accept: 'text/plain' }));
7+
expect(headers['content-type']).toEqual('foo');
8+
expect(headers['Content-type']).toEqual('foo');
9+
expect(headers['Content-Type']).toEqual('foo');
10+
expect(headers['accept']).toEqual('text/plain');
11+
expect(headers['Accept']).toEqual('text/plain');
12+
expect(headers['Hello-World']).toBeUndefined();
13+
});
14+
15+
test('duplicate headers are concatenated', () => {
16+
const headers = createResponseHeaders(
17+
new Headers([
18+
['Content-Type', 'text/xml'],
19+
['Content-Type', 'application/json'],
20+
]),
21+
);
22+
expect(headers['content-type']).toBe('text/xml, application/json');
23+
});
24+
});

0 commit comments

Comments
 (0)