├── .gitignore
├── images
├── icon.png
├── _banner.png
├── _logo.png
├── _logo.tsp
├── _featured.png
└── _logo.svg
├── .vscodeignore
├── .vscode
├── extensions.json
├── tasks.json
├── launch.json
└── settings.json
├── tsconfig.json
├── .editorconfig
├── CHANGELOG.md
├── src
├── test
│ ├── suite
│ │ ├── extension.test.ts
│ │ └── index.ts
│ └── runTest.ts
└── extension.ts
├── README.md
├── .eslintrc.json
├── LICENSE
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | out
2 | dist
3 | node_modules
4 | .vscode
5 | .vscode-test/
6 | *.vsix
7 |
--------------------------------------------------------------------------------
/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kentcdodds/vscode-auto-restart-typescript-eslint-servers/HEAD/images/icon.png
--------------------------------------------------------------------------------
/images/_banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kentcdodds/vscode-auto-restart-typescript-eslint-servers/HEAD/images/_banner.png
--------------------------------------------------------------------------------
/images/_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kentcdodds/vscode-auto-restart-typescript-eslint-servers/HEAD/images/_logo.png
--------------------------------------------------------------------------------
/images/_logo.tsp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kentcdodds/vscode-auto-restart-typescript-eslint-servers/HEAD/images/_logo.tsp
--------------------------------------------------------------------------------
/images/_featured.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kentcdodds/vscode-auto-restart-typescript-eslint-servers/HEAD/images/_featured.png
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | src/**
4 | .gitignore
5 | .yarnrc
6 | vsc-extension-quickstart.md
7 | **/tsconfig.json
8 | **/.eslintrc.json
9 | **/*.map
10 | **/*.ts
11 | images/_*
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846
3 | // for the documentation about the extensions.json format
4 | "recommendations": [
5 | "dbaeumer.vscode-eslint"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "ESNext",
5 | "outDir": "out",
6 | "lib": [
7 | "ESNext"
8 | ],
9 | "sourceMap": true,
10 | "rootDir": "src",
11 | "strict": true,
12 | "resolveJsonModule": true
13 | }
14 | }
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # https://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | end_of_line = lf
7 | indent_size = 2
8 | indent_style = space
9 | insert_final_newline = true
10 | max_line_length = 80
11 | trim_trailing_whitespace = true
12 |
13 | [*.md]
14 | max_line_length = 0
15 | trim_trailing_whitespace = false
16 |
17 | [COMMIT_EDITMSG]
18 | max_line_length = 0
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | // See https://go.microsoft.com/fwlink/?LinkId=733558
2 | // for the documentation about the tasks.json format
3 | {
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "type": "npm",
8 | "script": "watch",
9 | "problemMatcher": "$tsc-watch",
10 | "isBackground": true,
11 | "presentation": {
12 | "reveal": "never"
13 | },
14 | "group": {
15 | "kind": "build",
16 | "isDefault": true
17 | }
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ### 0.0.3 (2023-01-30)
2 | Update icon
3 |
4 | ### 0.0.2 (2023-01-08)
5 | * Add file monitoring for TypeScript (glob: `**/tsconfig.{json,app.json,app.js,js,ts}`)
6 | * Add file monitoring for ESLint (glob: `**/.eslintrc.{js,cjs,yaml,yml,json}}`)
7 | * Add toggle commands (`ctrl + shift + p`)
8 | * `Enable: Auto Restart TypeScript Server`
9 | * `Disable: Auto Restart TypeScript Server`
10 | * `Enable: Auto Restart ESLint Server`
11 | * `Disable: Auto Restart ESLint Server`
12 |
13 | ### 0.0.1 (2023-01-07)
14 | * Initial release
--------------------------------------------------------------------------------
/src/test/suite/extension.test.ts:
--------------------------------------------------------------------------------
1 | import * as assert from 'assert';
2 |
3 | // You can import and use all API from the 'vscode' module
4 | // as well as import your extension to test it
5 | import * as vscode from 'vscode';
6 | // import * as myExtension from '../../extension';
7 |
8 | suite('Extension Test Suite', () => {
9 | vscode.window.showInformationMessage('Start all tests.');
10 |
11 | test('Sample test', () => {
12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5));
13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0));
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vscode-auto-restart-typescript-eslint-servers
2 |
3 | Restart TypeScript or ESLint server automatically if monitored configuration or files changed.
4 |
5 |
6 |
7 | ## Features
8 | - Restart TypeScript and ESLint servers automatically
9 | - Enable/Disable file monitoring
10 |
11 | ## Credits
12 | * [vscode-restart-ts-server-button](https://github.com/qcz/vscode-restart-ts-server-button) by [Qcz](github.com/qcz)
13 | * [vscode-eslint](https://github.com/microsoft/vscode-eslint) by [Microsoft](github.com/microsoft)
14 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parser": "@typescript-eslint/parser",
4 | "parserOptions": {
5 | "ecmaVersion": 6,
6 | "sourceType": "module"
7 | },
8 | "plugins": [
9 | "@typescript-eslint"
10 | ],
11 | "rules": {
12 | "@typescript-eslint/naming-convention": "warn",
13 | "curly": "warn",
14 | "eqeqeq": "warn",
15 | "no-throw-literal": "warn",
16 | "semi": [
17 | "warn",
18 | "never"
19 | ],
20 | "max-len": [
21 | "error",
22 | {
23 | "code": 80
24 | }
25 | ],
26 | "indent": [
27 | "warn",
28 | 2
29 | ]
30 | },
31 | "ignorePatterns": [
32 | "out",
33 | "dist",
34 | "**/*.d.ts"
35 | ]
36 | }
--------------------------------------------------------------------------------
/src/test/runTest.ts:
--------------------------------------------------------------------------------
1 | import * as path from 'path';
2 |
3 | import { runTests } from '@vscode/test-electron';
4 |
5 | async function main() {
6 | try {
7 | // The folder containing the Extension Manifest package.json
8 | // Passed to `--extensionDevelopmentPath`
9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../');
10 |
11 | // The path to test runner
12 | // Passed to --extensionTestsPath
13 | const extensionTestsPath = path.resolve(__dirname, './suite/index');
14 |
15 | // Download VS Code, unzip it and run the integration test
16 | await runTests({ extensionDevelopmentPath, extensionTestsPath });
17 | } catch (err) {
18 | console.error('Failed to run tests');
19 | process.exit(1);
20 | }
21 | }
22 |
23 | main();
24 |
--------------------------------------------------------------------------------
/src/test/suite/index.ts:
--------------------------------------------------------------------------------
1 | import * as path from 'path';
2 | import * as Mocha from 'mocha';
3 | import * as glob from 'glob';
4 |
5 | export function run(): Promise {
6 | // Create the mocha test
7 | const mocha = new Mocha({
8 | ui: 'tdd',
9 | color: true
10 | });
11 |
12 | const testsRoot = path.resolve(__dirname, '..');
13 |
14 | return new Promise((c, e) => {
15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
16 | if (err) {
17 | return e(err);
18 | }
19 |
20 | // Add files to the test suite
21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
22 |
23 | try {
24 | // Run the mocha test
25 | mocha.run(failures => {
26 | if (failures > 0) {
27 | e(new Error(`${failures} tests failed.`));
28 | } else {
29 | c();
30 | }
31 | });
32 | } catch (err) {
33 | console.error(err);
34 | e(err);
35 | }
36 | });
37 | });
38 | }
39 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that compiles the extension and then opens it inside a new window
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | {
6 | "version": "0.2.0",
7 | "configurations": [
8 | {
9 | "name": "Run Extension",
10 | "type": "extensionHost",
11 | "request": "launch",
12 | "args": [
13 | "--extensionDevelopmentPath=${workspaceFolder}"
14 | ],
15 | "outFiles": [
16 | "${workspaceFolder}/out/**/*.js"
17 | ],
18 | "preLaunchTask": "${defaultBuildTask}"
19 | },
20 | {
21 | "name": "Extension Tests",
22 | "type": "extensionHost",
23 | "request": "launch",
24 | "args": [
25 | "--extensionDevelopmentPath=${workspaceFolder}",
26 | "--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
27 | ],
28 | "outFiles": [
29 | "${workspaceFolder}/out/test/**/*.js"
30 | ],
31 | "preLaunchTask": "${defaultBuildTask}"
32 | }
33 | ]
34 | }
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Neo Tan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.exclude": {
4 | "out": false // set this to true to hide the "out" folder with the compiled JS files
5 | },
6 | "search.exclude": {
7 | "out": true // set this to false to include "out" folder in search results
8 | },
9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10 | "typescript.tsc.autoDetect": "off",
11 | "workbench.colorCustomizations": {
12 | "activityBar.activeBackground": "#78ec6d",
13 | "activityBar.background": "#78ec6d",
14 | "activityBar.foreground": "#15202b",
15 | "activityBar.inactiveForeground": "#15202b99",
16 | "activityBarBadge.background": "#727ded",
17 | "activityBarBadge.foreground": "#15202b",
18 | "commandCenter.border": "#15202b99",
19 | "sash.hoverBorder": "#78ec6d",
20 | "statusBar.background": "#4ee640",
21 | "statusBar.foreground": "#15202b",
22 | "statusBarItem.hoverBackground": "#2cd71c",
23 | "statusBarItem.remoteBackground": "#4ee640",
24 | "statusBarItem.remoteForeground": "#15202b",
25 | "titleBar.activeBackground": "#4ee640",
26 | "titleBar.activeForeground": "#15202b",
27 | "titleBar.inactiveBackground": "#4ee64099",
28 | "titleBar.inactiveForeground": "#15202b99"
29 | },
30 | "peacock.color": "#4ee640"
31 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vscode-auto-restart-typescript-eslint-servers",
3 | "displayName": "Auto Restart TypeScript / ESLint Servers",
4 | "description": "Restart TypeScript / ESLint servers AUTOMATICALLY when monitored files were changed.",
5 | "publisher": "neotan",
6 | "version": "0.0.3",
7 | "engines": {
8 | "vscode": "^1.74.0"
9 | },
10 | "icon": "images/icon.png",
11 | "homepage": "https://github.com/neotan/vscode-auto-restart-typescript-eslint-servers.git",
12 | "repository": {
13 | "type": "git",
14 | "url": "https://github.com/neotan/vscode-auto-restart-typescript-eslint-servers.git"
15 | },
16 | "bugs": {
17 | "url": "https://github.com/neotan/vscode-auto-restart-typescript-eslint-servers.git/issues"
18 | },
19 | "keywords": [
20 | "monitor",
21 | "file watch",
22 | "folder watch",
23 | "on change",
24 | "on delete",
25 | "on create",
26 | "auto",
27 | "restart",
28 | "tsconfig",
29 | "eslint",
30 | "eslintrc",
31 | "server",
32 | "turborepo",
33 | "lerna",
34 | "nx",
35 | "configuration",
36 | "reload",
37 | "typescript"
38 | ],
39 | "categories": [
40 | "Other"
41 | ],
42 | "activationEvents": [
43 | "*"
44 | ],
45 | "main": "./out/extension.js",
46 | "contributes": {
47 | "configuration": {
48 | "type": "object",
49 | "title": "Auto Restart TypeScript / ESLint Servers",
50 | "properties": {
51 | "autoRestartTsESLint.monitorFilesForTypescript": {
52 | "type": "boolean",
53 | "default": true,
54 | "scope": "window",
55 | "markdownDescription": "Monitor TypeScript config files and restart its server."
56 | },
57 | "autoRestartTsESLint.includeFilesForTypescript": {
58 | "type": "string",
59 | "default": "**/tsconfig.{json,app.json,app.js,js,ts}",
60 | "scope": "window",
61 | "markdownDescription": "These files will be monitored, supports [Glob Pattern](https://code.visualstudio.com/api/references/vscode-api#GlobPattern). Default `**/tsconfig.{json,app.json,app.js,js,ts}`."
62 | },
63 | "autoRestartTsESLint.monitorFilesForESLint": {
64 | "type": "boolean",
65 | "default": true,
66 | "scope": "window",
67 | "markdownDescription": "Monitor ESLint config files and restart its server."
68 | },
69 | "autoRestartTsESLint.includeFilesForESLint": {
70 | "type": "string",
71 | "default": "**/.eslintrc.{js,cjs,yaml,yml,json}}",
72 | "scope": "window",
73 | "markdownDescription": "These files will be monitored, supports [Glob Pattern](https://code.visualstudio.com/api/references/vscode-api#GlobPattern). Default `**/.eslintrc.{js,cjs,yaml,yml,json}}`"
74 | }
75 | }
76 | },
77 | "commands": [
78 | {
79 | "command": "vscode-auto-restart-typescript-eslint-servers.enableMonitorFilesForTypescript",
80 | "title": "Enable: Auto Restart TypeScript Server"
81 | },
82 | {
83 | "command": "vscode-auto-restart-typescript-eslint-servers.disableMonitorFilesForTypescript",
84 | "title": "Disable: Auto Restart TypeScript Server"
85 | },
86 | {
87 | "command": "vscode-auto-restart-typescript-eslint-servers.enableMonitorFilesForESLint",
88 | "title": "Enable: Auto Restart ESLint Server"
89 | },
90 | {
91 | "command": "vscode-auto-restart-typescript-eslint-servers.disableMonitorFilesForESLint",
92 | "title": "Disable: Auto Restart ESLint Server"
93 | }
94 | ]
95 | },
96 | "scripts": {
97 | "package": "vsce package --allow-star-activation",
98 | "vscode:prepublish": "npm run compile",
99 | "compile": "tsc -p ./",
100 | "watch": "tsc -watch -p ./",
101 | "pretest": "npm run compile && npm run lint",
102 | "lint": "eslint src --ext ts",
103 | "test": "node ./out/test/runTest.js"
104 | },
105 | "devDependencies": {
106 | "@types/vscode": "^1.74.0",
107 | "@types/glob": "^8.0.0",
108 | "@types/mocha": "^10.0.1",
109 | "@types/node": "16.x",
110 | "@typescript-eslint/eslint-plugin": "^5.45.0",
111 | "@typescript-eslint/parser": "^5.45.0",
112 | "eslint": "^8.28.0",
113 | "glob": "^8.0.3",
114 | "mocha": "^10.1.0",
115 | "typescript": "^4.9.3",
116 | "@vscode/test-electron": "^2.2.0"
117 | }
118 | }
--------------------------------------------------------------------------------
/images/_logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/extension.ts:
--------------------------------------------------------------------------------
1 | import {
2 | window,
3 | workspace,
4 | extensions,
5 | commands,
6 | ExtensionContext,
7 | FileSystemWatcher,
8 | WorkspaceConfiguration
9 | } from 'vscode'
10 |
11 | const TS_EXT_ID = 'vscode.typescript-language-features'
12 | const ESLINT_EXT_ID = 'dbaeumer.vscode-eslint'
13 | const THIS_EXT_NAME = 'vscode-auto-restart-typescript-eslint-servers'
14 | const THIS_EXT_ID = `neotan.${THIS_EXT_NAME}`
15 |
16 | const TS_SERVER_RESTARTED_MSG = `TypeScript Server Restarted as file(s) `
17 | const TS_SERVER_RESTART_FAILED_MSG =
18 | `TypeScript Server Restart failed when the file `
19 | const ESLINT_SERVER_RESTARTED_MSG = `ESLint Server Restarted as file(s) `
20 | const ESLINT_SERVER_RESTART_FAILED_MSG =
21 | `ESLint Server Restart failed when the file was `
22 |
23 | let tsWatcher: FileSystemWatcher
24 | let eslintWatcher: FileSystemWatcher
25 |
26 | export function activate(context: ExtensionContext) {
27 | const wsConfig = workspace.getConfiguration('autoRestartTsESLint')
28 | console.warn(wsConfig)
29 |
30 | if (wsConfig.monitorFilesForTypescript) {
31 | tsWatcher = initWatcherForTypescriptFiles(wsConfig)
32 | }
33 |
34 | if (wsConfig.monitorFilesForESLint) {
35 | eslintWatcher = initWatcherForEslintFiles(wsConfig)
36 | }
37 |
38 | console.log(
39 | `Extension ${THIS_EXT_ID} is now active!`,
40 | JSON.stringify(wsConfig, [
41 | 'monitorFilesForTypescript',
42 | 'monitorFilesForESLint',
43 | 'includeFilesForTypescript',
44 | 'includeFilesForESLint',
45 | ], 2))
46 |
47 | context.subscriptions.push(
48 | commands
49 | .registerCommand(`${THIS_EXT_NAME}.enableMonitorFilesForTypescript`,
50 | async () => {
51 | await wsConfig.update('monitorFilesForTypescript', true)
52 | tsWatcher = initWatcherForTypescriptFiles(wsConfig)
53 | }),
54 | commands
55 | .registerCommand(`${THIS_EXT_NAME}.disableMonitorFilesForTypescript`,
56 | async () => {
57 | await wsConfig.update('monitorFilesForTypescript', false)
58 | tsWatcher?.dispose()
59 | }),
60 | commands
61 | .registerCommand(`${THIS_EXT_NAME}.enableMonitorFilesForESLint`,
62 | async () => {
63 | await wsConfig.update('monitorFilesForESLint', true)
64 | eslintWatcher = initWatcherForEslintFiles(wsConfig)
65 | }),
66 | commands
67 | .registerCommand(`${THIS_EXT_NAME}.disableMonitorFilesForESLint`,
68 | async () => {
69 | await wsConfig.update('monitorFilesForESLint', false)
70 | eslintWatcher?.dispose()
71 | }),
72 | )
73 | }
74 |
75 | export function deactivate() {
76 | tsWatcher?.dispose()
77 | eslintWatcher?.dispose()
78 | console.log(`Extension ${THIS_EXT_ID} is now deactive!`)
79 | }
80 |
81 | // ===== Utils =====
82 |
83 | function restartTsServer() {
84 | const tsExtension = extensions.getExtension(TS_EXT_ID)
85 | if (!tsExtension || tsExtension.isActive === false) {
86 | window.showErrorMessage(`${THIS_EXT_NAME} is not active or not running.`)
87 | return
88 | }
89 |
90 | return commands.executeCommand("typescript.restartTsServer")
91 | }
92 |
93 | function restartEslintServer() {
94 | const eslintExtension = extensions.getExtension(ESLINT_EXT_ID)
95 | if (!eslintExtension || eslintExtension.isActive === false) {
96 | window.showErrorMessage("ESLint extension is not active or not running.")
97 | return
98 | }
99 |
100 | return commands.executeCommand("eslint.restart")
101 | }
102 |
103 | function initWatcherForTypescriptFiles(wsConfig: WorkspaceConfiguration) {
104 | const tsWatcher: FileSystemWatcher =
105 | workspace.createFileSystemWatcher(
106 | wsConfig.includeFilesForTypescript,
107 | false,
108 | false,
109 | false
110 | )
111 |
112 | tsWatcher.onDidCreate(async (e) => {
113 | const filePath = e?.path || e?.fsPath
114 | try {
115 | await restartTsServer()
116 | window.showInformationMessage(
117 | `${TS_SERVER_RESTARTED_MSG} was created: ${filePath}`
118 | )
119 | } catch (err) {
120 | throw new Error(
121 | `${TS_SERVER_RESTART_FAILED_MSG} was created:
122 | "${filePath}"`,
123 | { cause: err }
124 | )
125 | }
126 | })
127 |
128 | tsWatcher.onDidChange(async (e) => {
129 | const filePath = e?.path || e?.fsPath
130 | try {
131 | await restartTsServer()
132 | window.showInformationMessage(
133 | `${TS_SERVER_RESTARTED_MSG} was changed: ${filePath}`
134 | )
135 | } catch (err) {
136 | throw new Error(
137 | `${TS_SERVER_RESTART_FAILED_MSG} was changed:
138 | "${filePath}"`,
139 | { cause: err }
140 | )
141 | }
142 | })
143 |
144 | tsWatcher.onDidDelete(async (e) => {
145 | const filePath = e?.path || e?.fsPath
146 | try {
147 | await restartTsServer()
148 | window.showInformationMessage(
149 | `${TS_SERVER_RESTARTED_MSG} was deleted: ${filePath}`
150 | )
151 | } catch (err) {
152 | throw new Error(
153 | `${TS_SERVER_RESTART_FAILED_MSG} was deleted:
154 | "${filePath}"`,
155 | { cause: err }
156 | )
157 | }
158 | })
159 |
160 | return tsWatcher
161 | }
162 |
163 | function initWatcherForEslintFiles(wsConfig: WorkspaceConfiguration) {
164 | const eslintWatcher: FileSystemWatcher =
165 | workspace.createFileSystemWatcher(
166 | wsConfig.includeFilesForESLint,
167 | false,
168 | false,
169 | false
170 | )
171 |
172 | eslintWatcher.onDidCreate(async (e) => {
173 | const filePath = e?.path || e?.fsPath
174 | try {
175 | await restartEslintServer()
176 | window.showInformationMessage(
177 | `${ESLINT_SERVER_RESTARTED_MSG} was created: ${filePath}`
178 | )
179 | } catch (err) {
180 | throw new Error(
181 | `${ESLINT_SERVER_RESTART_FAILED_MSG} was Created:
182 | "${filePath}"`,
183 | { cause: err }
184 | )
185 | }
186 | })
187 |
188 | eslintWatcher.onDidChange(async (e) => {
189 | const filePath = e?.path || e?.fsPath
190 | try {
191 | await restartEslintServer()
192 | window.showInformationMessage(
193 | `${ESLINT_SERVER_RESTARTED_MSG} was changed: ${filePath}`
194 | )
195 | } catch (err) {
196 | throw new Error(
197 | `${ESLINT_SERVER_RESTART_FAILED_MSG} was changed:
198 | "${filePath}"`,
199 | { cause: err }
200 | )
201 | }
202 | })
203 |
204 | eslintWatcher.onDidDelete(async (e) => {
205 | const filePath = e?.path || e?.fsPath
206 | try {
207 | await restartEslintServer()
208 | window.showInformationMessage(
209 | `${ESLINT_SERVER_RESTARTED_MSG} was deleted: ${filePath}`
210 | )
211 | } catch (err) {
212 | throw new Error(
213 | `${ESLINT_SERVER_RESTART_FAILED_MSG} was deleted:
214 | "${filePath}"`,
215 | { cause: err }
216 | )
217 | }
218 | })
219 |
220 | return eslintWatcher
221 | }
222 |
--------------------------------------------------------------------------------