Skip to content

Commit e946b75

Browse files
committed
Convert ESLint config and add Prettier
1 parent eb00e23 commit e946b75

File tree

6 files changed

+75
-115
lines changed

6 files changed

+75
-115
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ charset = utf-8
55
indent_style = space
66
indent_size = 4
77
insert_final_newline = true
8+
trim_trailing_whitespace = true
89

910
[*.{json,yaml,yml,code-workspace}]
1011
indent_size = 2

.eslintrc.json

Lines changed: 0 additions & 75 deletions
This file was deleted.

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
modules/
3+
out/

eslint.config.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import eslint from "@eslint/js";
2+
import eslintConfigPrettier from "eslint-config-prettier/flat";
3+
import tseslint from "typescript-eslint";
4+
5+
export default tseslint.config(
6+
eslint.configs.recommended,
7+
tseslint.configs.strictTypeChecked,
8+
tseslint.configs.stylisticTypeChecked,
9+
eslintConfigPrettier,
10+
{
11+
languageOptions: {
12+
parserOptions: {
13+
projectService: true,
14+
tsconfigRootDir: import.meta.dirname,
15+
},
16+
},
17+
rules: {
18+
"@typescript-eslint/explicit-function-return-type": "error",
19+
"@typescript-eslint/no-empty-object-type": "off",
20+
"@typescript-eslint/no-floating-promises": [
21+
"error",
22+
{
23+
ignoreVoid: true,
24+
},
25+
],
26+
"@typescript-eslint/no-non-null-assertion": "off",
27+
"@typescript-eslint/no-require-imports": "off",
28+
"@typescript-eslint/no-unused-vars": [
29+
"error",
30+
{
31+
argsIgnorePattern: "^_",
32+
},
33+
],
34+
"@typescript-eslint/no-unsafe-argument": "off",
35+
"@typescript-eslint/no-unsafe-assignment": "off",
36+
"@typescript-eslint/no-unsafe-call": "off",
37+
"@typescript-eslint/no-unsafe-member-access": "off",
38+
"@typescript-eslint/no-unsafe-return": "off",
39+
"@typescript-eslint/restrict-template-expressions": "off",
40+
"@typescript-eslint/prefer-nullish-coalescing": [
41+
"error",
42+
{
43+
ignoreConditionalTests: true,
44+
ignoreMixedLogicalExpressions: true,
45+
},
46+
],
47+
},
48+
},
49+
);

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@
109109
"pretest": "npm run compile",
110110
"test": "vscode-test"
111111
},
112+
"prettier": {
113+
"plugins": ["prettier-plugin-organize-imports"]
114+
},
112115
"contributes": {
113116
"breakpoints": [
114117
{

pwsh-extension-dev.code-workspace

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"path": "../PowerShellEditorServices"
1010
}
1111
],
12-
1312
"extensions": {
1413
"recommendations": [
1514
"davidanson.vscode-markdownlint",
@@ -18,17 +17,22 @@
1817
"esbenp.prettier-vscode",
1918
"ms-dotnettools.csharp",
2019
"ms-vscode.powershell",
21-
"hbenl.vscode-mocha-test-adapter",
22-
"connor4312.esbuild-problem-matchers"
20+
"connor4312.esbuild-problem-matchers",
21+
"ms-vscode.extension-test-runner"
2322
]
2423
},
2524
"settings": {
2625
"window.title": "PowerShell VS Code Extension Development",
2726
"debug.onTaskErrors": "prompt",
28-
"editor.tabSize": 4,
29-
"editor.insertSpaces": true,
30-
"files.trimTrailingWhitespace": true,
31-
"files.insertFinalNewline": true,
27+
"editor.codeActionsOnSave": {
28+
"source.fixAll": "explicit",
29+
},
30+
"[typescript][javascript][json]": {
31+
"editor.defaultFormatter": "esbenp.prettier-vscode",
32+
"editor.formatOnPaste": true,
33+
"editor.formatOnSave": true,
34+
"editor.formatOnSaveMode": "modificationsIfAvailable",
35+
},
3236
"files.associations": {
3337
"**/snippets/*.json": "jsonc", // Use JSONC instead of JSON because that's how VS Code interprets snippet files, and it enables better source documentation.
3438
},
@@ -46,25 +50,8 @@
4650
"powershell.codeFormatting.whitespaceBetweenParameters": true,
4751
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
4852
"typescript.tsdk": "Client/node_modules/typescript/lib", // Lock the TypeScript SDK path to the version we use
49-
"typescript.format.semicolons": "insert", // Code actions like "organize imports" ignore ESLint, so we need this here
50-
"eslint.format.enable": true, // Enable ESLint as defaut formatter so quick fixes can be applied directly
51-
"[typescript]": {
52-
"editor.defaultFormatter": "esbenp.prettier-vscode",
53-
"editor.formatOnPaste": true,
54-
"editor.formatOnSave": true,
55-
"editor.formatOnSaveMode": "modificationsIfAvailable"
56-
},
57-
"mochaExplorer.configFile": ".mocharc.json",
58-
"mochaExplorer.launcherScript": "test/runTests",
59-
"mochaExplorer.autoload": false, // The test instance pops up every time discovery or run is done, this could be annoying on startup.
60-
"mochaExplorer.debuggerPort": 59229, // Matches the launch config, we dont want to use the default port as we are launching a duplicate instance of vscode and it might conflict.
61-
"mochaExplorer.ipcRole": "server",
62-
"mochaExplorer.ipcTimeout": 30000, // 30 seconds
53+
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
6354
"testExplorer.useNativeTesting": true,
64-
"mochaExplorer.env": {
65-
"VSCODE_VERSION": "insiders",
66-
"ELECTRON_RUN_AS_NODE": null
67-
}
6855
},
6956
"tasks": {
7057
"version": "2.0.0",
@@ -95,7 +82,7 @@
9582
"osx": {
9683
"options": {
9784
"shell": {
98-
"executable": "/usr/local/bin/pwsh",
85+
"executable": "pwsh",
9986
"args": [
10087
"-NoProfile",
10188
"-Command"
@@ -324,15 +311,13 @@
324311
"sourceMaps": true,
325312
// This speeds up source map detection and makes smartStep work correctly
326313
"outFiles": [
327-
"${workspaceFolder:Client}/**/*.js",
328-
"!**/node_modules/**",
329-
"!**/.vscode-test/**"
314+
"${workspaceFolder:Client}/dist/*.js"
330315
],
331316
"skipFiles": [
332317
"<node_internals>/**",
333318
"**/node_modules/**",
334319
"**/.vscode-test/**",
335-
"**/app/out/vs/**" //Skips Extension Host internals
320+
"**/app/out/vs/**" // Skips Extension Host internals
336321
],
337322
"presentation": {
338323
"hidden": true
@@ -356,9 +341,7 @@
356341
"sourceMaps": true,
357342
// This speeds up source map detection and makes smartStep work correctly
358343
"outFiles": [
359-
"${workspaceFolder:Client}/**/*.js",
360-
"!**/node_modules/**",
361-
"!**/.vscode-test/**"
344+
"${workspaceFolder:Client}/dist/*.js"
362345
],
363346
"skipFiles": [
364347
"<node_internals>/**",
@@ -388,15 +371,13 @@
388371
"sourceMaps": true,
389372
// This speeds up source map detection and makes smartStep work correctly
390373
"outFiles": [
391-
"${workspaceFolder:Client}/**/*.js",
392-
"!**/node_modules/**",
393-
"!**/.vscode-test/**",
374+
"${workspaceFolder:Client}/dist/*.js"
394375
],
395376
"skipFiles": [
396377
"<node_internals>/**",
397378
"**/node_modules/**",
398379
"**/.vscode-test/**",
399-
"**/app/out/vs/**" //Skips Extension Host internals
380+
"**/app/out/vs/**" // Skips Extension Host internals
400381
],
401382
"presentation": {
402383
"hidden": true
@@ -460,9 +441,7 @@
460441
"sourceMaps": true,
461442
// This speeds up source map detection and makes smartStep work correctly
462443
"outFiles": [
463-
"${workspaceFolder:Client}/**/*.js",
464-
"!**/node_modules/**",
465-
"!**/.vscode-test/**"
444+
"${workspaceFolder:Client}/dist/*.js"
466445
],
467446
"skipFiles": [
468447
"<node_internals>/**",

0 commit comments

Comments
 (0)