Skip to content

Commit 8c30bbd

Browse files
authored
Reorganize our ESlint and prettier configurations (#3648)
* Reorganize our ESlint and prettier configurations * Auto-format files * Fix type checking errors
1 parent 261554c commit 8c30bbd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1516
-6106
lines changed

vscode/.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"tabWidth": 2,
3+
"printWidth": 120,
4+
"semi": true,
5+
"singleQuote": false,
6+
"bracketSpacing": true
7+
}

vscode/eslint.config.mjs

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,65 @@
1-
import shopifyPlugin from "@shopify/eslint-plugin";
1+
// @ts-check
22

3-
const config = [
4-
...shopifyPlugin.configs.core,
5-
...shopifyPlugin.configs.typescript,
6-
...shopifyPlugin.configs.prettier,
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
import eslintPluginPrettier from "eslint-plugin-prettier";
6+
7+
export default tseslint.config(
8+
eslint.configs.recommended,
9+
tseslint.configs.recommended,
10+
tseslint.configs.recommendedTypeChecked,
11+
{
12+
plugins: {
13+
prettier: eslintPluginPrettier,
14+
},
15+
rules: {
16+
"prettier/prettier": "warn",
17+
},
18+
},
719
{
820
languageOptions: {
921
parserOptions: {
1022
projectService: true,
1123
tsconfigRootDir: import.meta.dirname,
1224
},
1325
},
14-
15-
"rules": {
16-
"@typescript-eslint/no-floating-promises": "error",
26+
},
27+
{
28+
ignores: [
29+
"**/.vscode-test/**",
30+
"eslint.config.mjs",
31+
"**/out/",
32+
"src/test/suite/fakeTestServer.js",
33+
],
34+
},
35+
{
36+
rules: {
37+
"@typescript-eslint/no-explicit-any": "off",
38+
"@typescript-eslint/no-unsafe-member-access": "off",
39+
"@typescript-eslint/no-unsafe-return": "off",
40+
"@typescript-eslint/no-unsafe-argument": "off",
41+
"@typescript-eslint/no-unsafe-assignment": "off",
42+
"@typescript-eslint/no-unused-vars": [
43+
"error",
44+
{
45+
argsIgnorePattern: "^_",
46+
varsIgnorePattern: "^_",
47+
caughtErrorsIgnorePattern: "^_",
48+
},
49+
],
1750
"consistent-return": "off",
1851
"no-warning-comments": "off",
1952
"no-console": "warn",
20-
"@shopify/no-debugger": "warn",
2153
"no-template-curly-in-string": "warn",
2254
"eqeqeq": "error",
2355
"no-invalid-this": "error",
24-
"no-lonely-if": "error",
25-
"max-len": [
26-
"error",
27-
{
28-
"code": 120
29-
}
30-
]
56+
"no-lonely-if": "error"
3157
}
3258
},
3359
{
34-
ignores: [
35-
".vscode-test/*",
36-
],
60+
files: ["**/*.test.ts"],
61+
rules: {
62+
"@typescript-eslint/no-unsafe-call": "off",
63+
}
3764
}
38-
]
39-
40-
export default config;
65+
);

vscode/package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@
802802
"compile": "tsc -p ./",
803803
"watch": "tsc -watch -p ./",
804804
"pretest": "yarn run compile",
805-
"format": "eslint '**/*.ts' --fix && prettier '**/*.{json,md,yaml,yml}' --write",
806-
"lint": "eslint '**/*.ts' --max-warnings=0 && prettier '**/*.{json,md,yaml,yml}' --check",
805+
"format": "eslint . --fix && prettier '**/*.{ts,json,md,yaml,yml}' --write",
806+
"lint": "eslint . && prettier '**/*.{ts,json,md,yaml,yml}' --check",
807807
"test": "node ./out/test/runTest.js"
808808
},
809809
"resolutions": {
@@ -813,30 +813,24 @@
813813
},
814814
"devDependencies": {
815815
"@babel/core": "^7.28.0",
816-
"@eslint/eslintrc": "^3.3.1",
817816
"@eslint/js": "^9.30.1",
818-
"@shopify/eslint-plugin": "^48.0.2",
819-
"@shopify/prettier-config": "^1.1.4",
820817
"@types/glob": "^8.1.0",
821818
"@types/mocha": "^10.0.10",
822819
"@types/node": "24.x",
823820
"@types/sinon": "^17.0.4",
824821
"@types/vscode": "^1.91.0",
825-
"@typescript-eslint/eslint-plugin": "^7.18.0",
826-
"@typescript-eslint/parser": "^7.18.0",
827822
"@vscode/test-electron": "^2.5.2",
828823
"@vscode/vsce": "^3.6.0",
829824
"esbuild": "^0.25.5",
830-
"eslint": "^8.57.0",
831-
"eslint-import-resolver-typescript": "^4.4.4",
825+
"eslint": "^9.30.1",
832826
"eslint-plugin-prettier": "^5.5.1",
833827
"glob": "^11.0.3",
834828
"mocha": "^11.7.1",
835829
"ovsx": "^0.10.4",
836830
"prettier": "^3.6.2",
837831
"sinon": "^21.0.0",
838832
"typescript": "^5.8.3",
839-
"typescript-eslint": "8",
833+
"typescript-eslint": "^8.35.1",
840834
"vscode-oniguruma": "^2.0.1",
841835
"vscode-textmate": "^9.2.0"
842836
},

vscode/src/chatAgent.ts

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,8 @@ export class ChatAgent implements vscode.Disposable {
3535
private readonly agent: vscode.ChatParticipant;
3636
private readonly showWorkspacePick: () => Promise<Workspace | undefined>;
3737

38-
constructor(
39-
context: vscode.ExtensionContext,
40-
showWorkspacePick: () => Promise<Workspace | undefined>,
41-
) {
42-
this.agent = vscode.chat.createChatParticipant(
43-
CHAT_AGENT_ID,
44-
this.handler.bind(this),
45-
);
38+
constructor(context: vscode.ExtensionContext, showWorkspacePick: () => Promise<Workspace | undefined>) {
39+
this.agent = vscode.chat.createChatParticipant(CHAT_AGENT_ID, this.handler.bind(this));
4640
this.agent.iconPath = vscode.Uri.joinPath(context.extensionUri, "icon.png");
4741
this.showWorkspacePick = showWorkspacePick;
4842
}
@@ -62,9 +56,7 @@ export class ChatAgent implements vscode.Disposable {
6256
return this.runDesignCommand(request, context, stream, token);
6357
}
6458

65-
stream.markdown(
66-
"Please indicate which command you would like to use for our chat.",
67-
);
59+
stream.markdown("Please indicate which command you would like to use for our chat.");
6860
return { metadata: { command: "" } };
6961
}
7062

@@ -79,9 +71,7 @@ export class ChatAgent implements vscode.Disposable {
7971
const messages = [
8072
vscode.LanguageModelChatMessage.User(`User prompt: ${request.prompt}`),
8173
vscode.LanguageModelChatMessage.User(DESIGN_PROMPT),
82-
vscode.LanguageModelChatMessage.User(
83-
`Previous interactions with the user: ${previousInteractions}`,
84-
),
74+
vscode.LanguageModelChatMessage.User(`Previous interactions with the user: ${previousInteractions}`),
8575
];
8676
const workspace = await this.showWorkspacePick();
8777

@@ -91,11 +81,7 @@ export class ChatAgent implements vscode.Disposable {
9181
const schema = await this.schema(workspace);
9282

9383
if (schema) {
94-
messages.push(
95-
vscode.LanguageModelChatMessage.User(
96-
`Existing application schema: ${schema}`,
97-
),
98-
);
84+
messages.push(vscode.LanguageModelChatMessage.User(`Existing application schema: ${schema}`));
9985
}
10086
}
10187

@@ -153,7 +139,7 @@ export class ChatAgent implements vscode.Disposable {
153139
vscode.Uri.joinPath(workspace.workspaceFolder.uri, "db/schema.rb"),
154140
);
155141
return content.toString();
156-
} catch (error) {
142+
} catch (_error) {
157143
// db/schema.rb doesn't exist
158144
}
159145

@@ -162,7 +148,7 @@ export class ChatAgent implements vscode.Disposable {
162148
vscode.Uri.joinPath(workspace.workspaceFolder.uri, "db/structure.sql"),
163149
);
164150
return content.toString();
165-
} catch (error) {
151+
} catch (_error) {
166152
// db/structure.sql doesn't exist
167153
}
168154

@@ -171,32 +157,19 @@ export class ChatAgent implements vscode.Disposable {
171157

172158
// Returns `true` if the current or any previous interactions with the chat match the given `command`. Useful for
173159
// ensuring that the user can continue chatting without having to re-type the desired command multiple times
174-
private withinConversation(
175-
command: string,
176-
request: vscode.ChatRequest,
177-
context: vscode.ChatContext,
178-
) {
160+
private withinConversation(command: string, request: vscode.ChatRequest, context: vscode.ChatContext) {
179161
return (
180162
request.command === command ||
181163
(!request.command &&
182-
context.history.some(
183-
(entry) =>
184-
entry instanceof vscode.ChatRequestTurn &&
185-
entry.command === command,
186-
))
164+
context.history.some((entry) => entry instanceof vscode.ChatRequestTurn && entry.command === command))
187165
);
188166
}
189167

190168
// Default error handling
191169
private handleError(err: any, stream: vscode.ChatResponseStream) {
192170
if (err instanceof vscode.LanguageModelError) {
193-
if (
194-
err.cause instanceof Error &&
195-
err.cause.message.includes("off_topic")
196-
) {
197-
stream.markdown(
198-
"Sorry, I can only help you with Ruby related questions",
199-
);
171+
if (err.cause instanceof Error && err.cause.message.includes("off_topic")) {
172+
stream.markdown("Sorry, I can only help you with Ruby related questions");
200173
}
201174
} else {
202175
throw err;

0 commit comments

Comments
 (0)