vscode-eslint 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/$shared/customMessages.ts +113 -0
  2. package/$shared/settings.ts +189 -0
  3. package/.CodeQL.yml +5 -0
  4. package/.azure-pipelines.yml +27 -0
  5. package/.github/commands.yml +127 -0
  6. package/.github/locker.yml +6 -0
  7. package/.github/needs_more_info.yml +6 -0
  8. package/.github/workflows/npm-publish.yml +53 -0
  9. package/.github/workflows/release-please.yml +22 -0
  10. package/.lsifrc.json +4 -0
  11. package/.vscode/launch.json +20 -0
  12. package/.vscode/settings.json +52 -0
  13. package/.vscode/spellright.dict +8 -0
  14. package/.vscode/tasks.json +39 -0
  15. package/.vscodeignore +23 -0
  16. package/CHANGELOG.md +524 -0
  17. package/License.txt +17 -0
  18. package/README.md +517 -0
  19. package/SECURITY.md +41 -0
  20. package/agents.md +36 -0
  21. package/bin/vscode-eslint.js +56 -0
  22. package/build/azure-pipelines/linux/build.yml +14 -0
  23. package/build/azure-pipelines/pre-release.yml +42 -0
  24. package/build/azure-pipelines/release.yml +45 -0
  25. package/build/azure-pipelines/win32/build.yml +14 -0
  26. package/build/bin/all.js +29 -0
  27. package/build/bin/linking.js +102 -0
  28. package/build/bin/symlink.js +35 -0
  29. package/client/.mocharc.json +6 -0
  30. package/client/agents.md +5 -0
  31. package/client/package-lock.json +176 -0
  32. package/client/package.json +29 -0
  33. package/client/src/client.ts +992 -0
  34. package/client/src/extension.ts +180 -0
  35. package/client/src/node-utils.ts +393 -0
  36. package/client/src/settings.ts +379 -0
  37. package/client/src/tasks.ts +186 -0
  38. package/client/src/tests/glob.test.ts +31 -0
  39. package/client/src/vscode-utils.ts +28 -0
  40. package/client/test/mocha.opts +3 -0
  41. package/client/tsconfig.json +20 -0
  42. package/client/webpack.config.js +25 -0
  43. package/contributing.md +19 -0
  44. package/esbuild.js +62 -0
  45. package/eslint.config.js +129 -0
  46. package/eslint_icon.png +0 -0
  47. package/history/settings_1_9_x.md +110 -0
  48. package/images/2_1_10/eslint-dialog.png +0 -0
  49. package/images/2_1_10/eslint-status.png +0 -0
  50. package/package-json-schema.json +9 -0
  51. package/package.json +686 -0
  52. package/playgrounds/7.0/.eslintignore +1 -0
  53. package/playgrounds/7.0/.eslintrc.json +71 -0
  54. package/playgrounds/7.0/.vscode/settings.json +85 -0
  55. package/playgrounds/7.0/app.js +12 -0
  56. package/playgrounds/7.0/build/.eslintignore +1 -0
  57. package/playgrounds/7.0/build/.eslintrc.json +30 -0
  58. package/playgrounds/7.0/build/build.js +11 -0
  59. package/playgrounds/7.0/jsconfig.json +5 -0
  60. package/playgrounds/7.0/package-lock.json +2133 -0
  61. package/playgrounds/7.0/package.json +10 -0
  62. package/playgrounds/7.0/readme.md +0 -0
  63. package/playgrounds/7.0/subDir/sub.js +11 -0
  64. package/playgrounds/7.0/subDir/test.jsx +10 -0
  65. package/playgrounds/7.0/test.js +11 -0
  66. package/playgrounds/7.0/test.sh +1 -0
  67. package/playgrounds/7.0/test.vue +33 -0
  68. package/playgrounds/7.0/test2.html +8 -0
  69. package/playgrounds/8.0/.eslintignore +1 -0
  70. package/playgrounds/8.0/.eslintrc.json +71 -0
  71. package/playgrounds/8.0/.vscode/settings.json +91 -0
  72. package/playgrounds/8.0/app.js +12 -0
  73. package/playgrounds/8.0/build/.eslintignore +1 -0
  74. package/playgrounds/8.0/build/.eslintrc.json +30 -0
  75. package/playgrounds/8.0/build/build.js +11 -0
  76. package/playgrounds/8.0/jsconfig.json +5 -0
  77. package/playgrounds/8.0/package-lock.json +2321 -0
  78. package/playgrounds/8.0/package.json +10 -0
  79. package/playgrounds/8.0/readme.md +17 -0
  80. package/playgrounds/8.0/subDir/sub.js +11 -0
  81. package/playgrounds/8.0/subDir/test.jsx +10 -0
  82. package/playgrounds/8.0/test.ipynb +49 -0
  83. package/playgrounds/8.0/test.js +3 -0
  84. package/playgrounds/8.0/test.sh +1 -0
  85. package/playgrounds/8.0/test.vue +33 -0
  86. package/playgrounds/8.0/test2.html +8 -0
  87. package/playgrounds/9.0/flat/.vscode/settings.json +3 -0
  88. package/playgrounds/9.0/flat/app.js +12 -0
  89. package/playgrounds/9.0/flat/dist/ignore.js +12 -0
  90. package/playgrounds/9.0/flat/eslint.config.js +61 -0
  91. package/playgrounds/9.0/flat/package-lock.json +1053 -0
  92. package/playgrounds/9.0/flat/package.json +9 -0
  93. package/playgrounds/9.0/rc/.eslintrc.json +57 -0
  94. package/playgrounds/9.0/rc/.vscode/settings.json +3 -0
  95. package/playgrounds/9.0/rc/app.js +12 -0
  96. package/playgrounds/9.0/rc/package-lock.json +1345 -0
  97. package/playgrounds/9.0/rc/package.json +9 -0
  98. package/playgrounds/flat-config/.vscode/settings.json +22 -0
  99. package/playgrounds/flat-config/app.js +12 -0
  100. package/playgrounds/flat-config/eslint.config.js +51 -0
  101. package/playgrounds/flat-config/package-lock.json +2733 -0
  102. package/playgrounds/flat-config/package.json +12 -0
  103. package/playgrounds/flat-config/sub/sub.js +2 -0
  104. package/playgrounds/flat-config/test.ts +7 -0
  105. package/playgrounds/flat-config/tsconfig.json +11 -0
  106. package/playgrounds/flat-config-fail/f1/app.js +12 -0
  107. package/playgrounds/flat-config-fail/f1/eslint.config.js +51 -0
  108. package/playgrounds/flat-config-fail/package-lock.json +1683 -0
  109. package/playgrounds/flat-config-fail/package.json +11 -0
  110. package/playgrounds/flat-config-mjs/.vscode/settings.json +21 -0
  111. package/playgrounds/flat-config-mjs/app.js +12 -0
  112. package/playgrounds/flat-config-mjs/eslint.config.mjs +53 -0
  113. package/playgrounds/flat-config-mjs/package-lock.json +2860 -0
  114. package/playgrounds/flat-config-mjs/package.json +11 -0
  115. package/playgrounds/flat-config-mjs/sub/sub.js +2 -0
  116. package/playgrounds/flat-config-mjs/test.ts +7 -0
  117. package/playgrounds/flat-config-mjs/tsconfig.json +11 -0
  118. package/playgrounds/load-eslint/.vscode/settings.json +21 -0
  119. package/playgrounds/load-eslint/app.js +12 -0
  120. package/playgrounds/load-eslint/eslint.config.js +51 -0
  121. package/playgrounds/load-eslint/package-lock.json +2860 -0
  122. package/playgrounds/load-eslint/package.json +11 -0
  123. package/playgrounds/load-eslint/sub/sub.js +2 -0
  124. package/playgrounds/load-eslint/test.ts +7 -0
  125. package/playgrounds/load-eslint/tsconfig.json +11 -0
  126. package/playgrounds/noLib/test.js +22 -0
  127. package/playgrounds/noWD/.vscode/settings.json +2 -0
  128. package/playgrounds/noWD/src/.eslintrc.json +18 -0
  129. package/playgrounds/noWD/src/package-lock.json +2812 -0
  130. package/playgrounds/noWD/src/package.json +12 -0
  131. package/playgrounds/noWD/src/test.js +3 -0
  132. package/playgrounds/notebooks/notebook.ipynb +7072 -0
  133. package/playgrounds/notebooks/notebook2.ipynb +20 -0
  134. package/playgrounds/testing.code-workspace +28 -0
  135. package/playgrounds/ts/.eslintrc.base.json +23 -0
  136. package/playgrounds/ts/.eslintrc.json +191 -0
  137. package/playgrounds/ts/.vscode/settings.json +12 -0
  138. package/playgrounds/ts/package-lock.json +2687 -0
  139. package/playgrounds/ts/package.json +11 -0
  140. package/playgrounds/ts/test copy.ts +4 -0
  141. package/playgrounds/ts/test.ipynb +49 -0
  142. package/playgrounds/ts/test.ts +4 -0
  143. package/playgrounds/ts/test.tsx +14 -0
  144. package/playgrounds/ts/tsconfig.json +100 -0
  145. package/server/agents.md +9 -0
  146. package/server/package-lock.json +93 -0
  147. package/server/package.json +32 -0
  148. package/server/src/diff.ts +1079 -0
  149. package/server/src/eslint.ts +1471 -0
  150. package/server/src/eslintServer.ts +865 -0
  151. package/server/src/is.ts +18 -0
  152. package/server/src/languageDefaults.ts +40 -0
  153. package/server/src/linkedMap.ts +448 -0
  154. package/server/src/paths.ts +128 -0
  155. package/server/src/thenable.d.ts +5 -0
  156. package/server/tsconfig.json +21 -0
  157. package/server/webpack.config.js +25 -0
  158. package/shared.webpack.config.js +59 -0
  159. package/tsconfig.base.json +9 -0
  160. package/tsconfig.json +21 -0
@@ -0,0 +1,18 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+
6
+ const toString = Object.prototype.toString;
7
+
8
+ export function boolean(value: any): value is boolean {
9
+ return value === true || value === false;
10
+ }
11
+
12
+ export function nullOrUndefined(value: any): value is null | undefined {
13
+ return value === null || value === undefined;
14
+ }
15
+
16
+ export function string(value: any): value is string {
17
+ return toString.call(value) === '[object String]';
18
+ }
@@ -0,0 +1,40 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+
6
+ // This should either come from LSP or VS Code. That we repeat this is bogus.
7
+
8
+ type LanguageConfig = {
9
+ ext: string;
10
+ lineComment: string;
11
+ blockComment: [string, string];
12
+ };
13
+
14
+ const languageId2Config: Map<string, LanguageConfig> = new Map([
15
+ ['javascript', { ext: 'js', lineComment: '//', blockComment: ['/*', '*/'] }],
16
+ ['javascriptreact', { ext: 'jsx', lineComment: '//', blockComment: ['/*', '*/'] }],
17
+ ['typescript', { ext: 'ts', lineComment: '//', blockComment: ['/*', '*/'] } ],
18
+ ['typescriptreact', { ext: 'tsx', lineComment: '//', blockComment: ['/*', '*/'] } ],
19
+ ['html', { ext: 'html', lineComment: '//', blockComment: ['<!--', '-->'] }],
20
+ ['vue', { ext: 'vue', lineComment: '//', blockComment: ['<!--', '-->'] }],
21
+ ['coffeescript', { ext: 'coffee', lineComment: '#', blockComment: ['###', '###'] }],
22
+ ['yaml', { ext: 'yaml', lineComment: '#', blockComment: ['#', ''] }],
23
+ ['graphql', { ext: 'graphql', lineComment: '#', blockComment: ['#', ''] }]
24
+ ]);
25
+
26
+ namespace LanguageDefaults {
27
+ export function getLineComment(languageId: string): string {
28
+ return languageId2Config.get(languageId)?.lineComment ?? '//';
29
+ }
30
+
31
+ export function getBlockComment(languageId: string): [string, string] {
32
+ return languageId2Config.get(languageId)?.blockComment ?? ['/*', '*/'];
33
+ }
34
+
35
+ export function getExtension(languageId: string): string | undefined {
36
+ return languageId2Config.get(languageId)?.ext;
37
+ }
38
+ }
39
+
40
+ export default LanguageDefaults;
@@ -0,0 +1,448 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ interface Item<K, V> {
7
+ previous: Item<K, V> | undefined;
8
+ next: Item<K, V> | undefined;
9
+ key: K;
10
+ value: V;
11
+ }
12
+
13
+ export namespace Touch {
14
+ export const None: 0 = 0;
15
+ export const First: 1 = 1;
16
+ export const AsOld: 1 = Touch.First;
17
+ export const Last: 2 = 2;
18
+ export const AsNew: 2 = Touch.Last;
19
+ }
20
+
21
+ export type Touch = 0 | 1 | 2;
22
+
23
+ export class LinkedMap<K, V> implements Map<K, V> {
24
+
25
+ readonly [Symbol.toStringTag] = 'LinkedMap';
26
+
27
+ private _map: Map<K, Item<K, V>>;
28
+ private _head: Item<K, V> | undefined;
29
+ private _tail: Item<K, V> | undefined;
30
+ private _size: number;
31
+
32
+ private _state: number;
33
+
34
+ public constructor() {
35
+ this._map = new Map<K, Item<K, V>>();
36
+ this._head = undefined;
37
+ this._tail = undefined;
38
+ this._size = 0;
39
+ this._state = 0;
40
+ }
41
+
42
+ public clear(): void {
43
+ this._map.clear();
44
+ this._head = undefined;
45
+ this._tail = undefined;
46
+ this._size = 0;
47
+ this._state++;
48
+ }
49
+
50
+ public isEmpty(): boolean {
51
+ return !this._head && !this._tail;
52
+ }
53
+
54
+ public get size(): number {
55
+ return this._size;
56
+ }
57
+
58
+ public get first(): V | undefined {
59
+ return this._head?.value;
60
+ }
61
+
62
+ public get last(): V | undefined {
63
+ return this._tail?.value;
64
+ }
65
+
66
+ public has(key: K): boolean {
67
+ return this._map.has(key);
68
+ }
69
+
70
+ public get(key: K, touch: Touch = Touch.None): V | undefined {
71
+ const item = this._map.get(key);
72
+ if (!item) {
73
+ return undefined;
74
+ }
75
+ if (touch !== Touch.None) {
76
+ this.touch(item, touch);
77
+ }
78
+ return item.value;
79
+ }
80
+
81
+ public set(key: K, value: V, touch: Touch = Touch.None): this {
82
+ let item = this._map.get(key);
83
+ if (item) {
84
+ item.value = value;
85
+ if (touch !== Touch.None) {
86
+ this.touch(item, touch);
87
+ }
88
+ } else {
89
+ item = { key, value, next: undefined, previous: undefined };
90
+ switch (touch) {
91
+ case Touch.None:
92
+ this.addItemLast(item);
93
+ break;
94
+ case Touch.First:
95
+ this.addItemFirst(item);
96
+ break;
97
+ case Touch.Last:
98
+ this.addItemLast(item);
99
+ break;
100
+ default:
101
+ this.addItemLast(item);
102
+ break;
103
+ }
104
+ this._map.set(key, item);
105
+ this._size++;
106
+ }
107
+ return this;
108
+ }
109
+
110
+ public delete(key: K): boolean {
111
+ return !!this.remove(key);
112
+ }
113
+
114
+ public remove(key: K): V | undefined {
115
+ const item = this._map.get(key);
116
+ if (!item) {
117
+ return undefined;
118
+ }
119
+ this._map.delete(key);
120
+ this.removeItem(item);
121
+ this._size--;
122
+ return item.value;
123
+ }
124
+
125
+ public shift(): V | undefined {
126
+ if (!this._head && !this._tail) {
127
+ return undefined;
128
+ }
129
+ if (!this._head || !this._tail) {
130
+ throw new Error('Invalid list');
131
+ }
132
+ const item = this._head;
133
+ this._map.delete(item.key);
134
+ this.removeItem(item);
135
+ this._size--;
136
+ return item.value;
137
+ }
138
+
139
+ public forEach(callbackfn: (value: V, key: K, map: LinkedMap<K, V>) => void, thisArg?: any): void {
140
+ const state = this._state;
141
+ let current = this._head;
142
+ while (current) {
143
+ if (thisArg) {
144
+ callbackfn.bind(thisArg)(current.value, current.key, this);
145
+ } else {
146
+ callbackfn(current.value, current.key, this);
147
+ }
148
+ if (this._state !== state) {
149
+ throw new Error(`LinkedMap got modified during iteration.`);
150
+ }
151
+ current = current.next;
152
+ }
153
+ }
154
+
155
+ public keys(): IterableIterator<K> {
156
+ const map = this;
157
+ const state = this._state;
158
+ let current = this._head;
159
+ const iterator: IterableIterator<K> = {
160
+ [Symbol.iterator]() {
161
+ return iterator;
162
+ },
163
+ next(): IteratorResult<K> {
164
+ if (map._state !== state) {
165
+ throw new Error(`LinkedMap got modified during iteration.`);
166
+ }
167
+ if (current) {
168
+ const result = { value: current.key, done: false };
169
+ current = current.next;
170
+ return result;
171
+ } else {
172
+ return { value: undefined, done: true };
173
+ }
174
+ }
175
+ };
176
+ return iterator;
177
+ }
178
+
179
+ public values(): IterableIterator<V> {
180
+ const map = this;
181
+ const state = this._state;
182
+ let current = this._head;
183
+ const iterator: IterableIterator<V> = {
184
+ [Symbol.iterator]() {
185
+ return iterator;
186
+ },
187
+ next(): IteratorResult<V> {
188
+ if (map._state !== state) {
189
+ throw new Error(`LinkedMap got modified during iteration.`);
190
+ }
191
+ if (current) {
192
+ const result = { value: current.value, done: false };
193
+ current = current.next;
194
+ return result;
195
+ } else {
196
+ return { value: undefined, done: true };
197
+ }
198
+ }
199
+ };
200
+ return iterator;
201
+ }
202
+
203
+ public entries(): IterableIterator<[K, V]> {
204
+ const map = this;
205
+ const state = this._state;
206
+ let current = this._head;
207
+ const iterator: IterableIterator<[K, V]> = {
208
+ [Symbol.iterator]() {
209
+ return iterator;
210
+ },
211
+ next(): IteratorResult<[K, V]> {
212
+ if (map._state !== state) {
213
+ throw new Error(`LinkedMap got modified during iteration.`);
214
+ }
215
+ if (current) {
216
+ const result: IteratorResult<[K, V]> = { value: [current.key, current.value], done: false };
217
+ current = current.next;
218
+ return result;
219
+ } else {
220
+ return { value: undefined, done: true };
221
+ }
222
+ }
223
+ };
224
+ return iterator;
225
+ }
226
+
227
+ public [Symbol.iterator](): IterableIterator<[K, V]> {
228
+ return this.entries();
229
+ }
230
+
231
+ protected trimOld(newSize: number) {
232
+ if (newSize >= this.size) {
233
+ return;
234
+ }
235
+ if (newSize === 0) {
236
+ this.clear();
237
+ return;
238
+ }
239
+ let current = this._head;
240
+ let currentSize = this.size;
241
+ while (current && currentSize > newSize) {
242
+ this._map.delete(current.key);
243
+ current = current.next;
244
+ currentSize--;
245
+ }
246
+ this._head = current;
247
+ this._size = currentSize;
248
+ if (current) {
249
+ current.previous = undefined;
250
+ }
251
+ this._state++;
252
+ }
253
+
254
+ private addItemFirst(item: Item<K, V>): void {
255
+ // First time Insert
256
+ if (!this._head && !this._tail) {
257
+ this._tail = item;
258
+ } else if (!this._head) {
259
+ throw new Error('Invalid list');
260
+ } else {
261
+ item.next = this._head;
262
+ this._head.previous = item;
263
+ }
264
+ this._head = item;
265
+ this._state++;
266
+ }
267
+
268
+ private addItemLast(item: Item<K, V>): void {
269
+ // First time Insert
270
+ if (!this._head && !this._tail) {
271
+ this._head = item;
272
+ } else if (!this._tail) {
273
+ throw new Error('Invalid list');
274
+ } else {
275
+ item.previous = this._tail;
276
+ this._tail.next = item;
277
+ }
278
+ this._tail = item;
279
+ this._state++;
280
+ }
281
+
282
+ private removeItem(item: Item<K, V>): void {
283
+ if (item === this._head && item === this._tail) {
284
+ this._head = undefined;
285
+ this._tail = undefined;
286
+ }
287
+ else if (item === this._head) {
288
+ // This can only happen if size === 1 which is handled
289
+ // by the case above.
290
+ if (!item.next) {
291
+ throw new Error('Invalid list');
292
+ }
293
+ item.next.previous = undefined;
294
+ this._head = item.next;
295
+ }
296
+ else if (item === this._tail) {
297
+ // This can only happen if size === 1 which is handled
298
+ // by the case above.
299
+ if (!item.previous) {
300
+ throw new Error('Invalid list');
301
+ }
302
+ item.previous.next = undefined;
303
+ this._tail = item.previous;
304
+ }
305
+ else {
306
+ const next = item.next;
307
+ const previous = item.previous;
308
+ if (!next || !previous) {
309
+ throw new Error('Invalid list');
310
+ }
311
+ next.previous = previous;
312
+ previous.next = next;
313
+ }
314
+ item.next = undefined;
315
+ item.previous = undefined;
316
+ this._state++;
317
+ }
318
+
319
+ private touch(item: Item<K, V>, touch: Touch): void {
320
+ if (!this._head || !this._tail) {
321
+ throw new Error('Invalid list');
322
+ }
323
+ if ((touch !== Touch.First && touch !== Touch.Last)) {
324
+ return;
325
+ }
326
+
327
+ if (touch === Touch.First) {
328
+ if (item === this._head) {
329
+ return;
330
+ }
331
+
332
+ const next = item.next;
333
+ const previous = item.previous;
334
+
335
+ // Unlink the item
336
+ if (item === this._tail) {
337
+ // previous must be defined since item was not head but is tail
338
+ // So there are more than on item in the map
339
+ previous!.next = undefined;
340
+ this._tail = previous;
341
+ }
342
+ else {
343
+ // Both next and previous are not undefined since item was neither head nor tail.
344
+ next!.previous = previous;
345
+ previous!.next = next;
346
+ }
347
+
348
+ // Insert the node at head
349
+ item.previous = undefined;
350
+ item.next = this._head;
351
+ this._head.previous = item;
352
+ this._head = item;
353
+ this._state++;
354
+ } else if (touch === Touch.Last) {
355
+ if (item === this._tail) {
356
+ return;
357
+ }
358
+
359
+ const next = item.next;
360
+ const previous = item.previous;
361
+
362
+ // Unlink the item.
363
+ if (item === this._head) {
364
+ // next must be defined since item was not tail but is head
365
+ // So there are more than on item in the map
366
+ next!.previous = undefined;
367
+ this._head = next;
368
+ } else {
369
+ // Both next and previous are not undefined since item was neither head nor tail.
370
+ next!.previous = previous;
371
+ previous!.next = next;
372
+ }
373
+ item.next = undefined;
374
+ item.previous = this._tail;
375
+ this._tail.next = item;
376
+ this._tail = item;
377
+ this._state++;
378
+ }
379
+ }
380
+
381
+ public toJSON(): [K, V][] {
382
+ const data: [K, V][] = [];
383
+
384
+ this.forEach((value, key) => {
385
+ data.push([key, value]);
386
+ });
387
+
388
+ return data;
389
+ }
390
+
391
+ public fromJSON(data: [K, V][]): void {
392
+ this.clear();
393
+
394
+ for (const [key, value] of data) {
395
+ this.set(key, value);
396
+ }
397
+ }
398
+ }
399
+
400
+ export class LRUCache<K, V> extends LinkedMap<K, V> {
401
+
402
+ private _limit: number;
403
+ private _ratio: number;
404
+
405
+ public constructor(limit: number, ratio: number = 1) {
406
+ super();
407
+ this._limit = limit;
408
+ this._ratio = Math.min(Math.max(0, ratio), 1);
409
+ }
410
+
411
+ public get limit(): number {
412
+ return this._limit;
413
+ }
414
+
415
+ public set limit(limit: number) {
416
+ this._limit = limit;
417
+ this.checkTrim();
418
+ }
419
+
420
+ public get ratio(): number {
421
+ return this._ratio;
422
+ }
423
+
424
+ public set ratio(ratio: number) {
425
+ this._ratio = Math.min(Math.max(0, ratio), 1);
426
+ this.checkTrim();
427
+ }
428
+
429
+ public get(key: K, touch: Touch = Touch.AsNew): V | undefined {
430
+ return super.get(key, touch);
431
+ }
432
+
433
+ public peek(key: K): V | undefined {
434
+ return super.get(key, Touch.None);
435
+ }
436
+
437
+ public set(key: K, value: V): this {
438
+ super.set(key, value, Touch.Last);
439
+ this.checkTrim();
440
+ return this;
441
+ }
442
+
443
+ private checkTrim() {
444
+ if (this.size > this._limit) {
445
+ this.trimOld(Math.round(this._limit * this._ratio));
446
+ }
447
+ }
448
+ }
@@ -0,0 +1,128 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+
6
+ import * as fs from 'fs';
7
+
8
+ import { URI } from 'vscode-uri';
9
+ import { TextDocument } from 'vscode-languageserver-textdocument';
10
+
11
+ import * as Is from './is';
12
+
13
+ /**
14
+ * Special functions to deal with path conversions in the context of ESLint
15
+ */
16
+
17
+ /**
18
+ * Normalizes the drive letter to upper case which is the default in Node but not in
19
+ * VS Code.
20
+ */
21
+ export function normalizeDriveLetter(path: string): string {
22
+ if (process.platform !== 'win32' || path.length < 2 || path[1] !== ':') {
23
+ return path;
24
+ }
25
+ return path[0].toUpperCase() + path.substring(1);
26
+ }
27
+
28
+ const enum CharCode {
29
+ /**
30
+ * The `\` character.
31
+ */
32
+ Backslash = 92,
33
+ }
34
+
35
+ /**
36
+ * Check if the path follows this pattern: `\\hostname\sharename`.
37
+ *
38
+ * @see https://msdn.microsoft.com/en-us/library/gg465305.aspx
39
+ * @return A boolean indication if the path is a UNC path, on none-windows
40
+ * always false.
41
+ */
42
+ export function isUNC(path: string): boolean {
43
+ if (process.platform !== 'win32') {
44
+ // UNC is a windows concept
45
+ return false;
46
+ }
47
+
48
+ if (!path || path.length < 5) {
49
+ // at least \\a\b
50
+ return false;
51
+ }
52
+
53
+ let code = path.charCodeAt(0);
54
+ if (code !== CharCode.Backslash) {
55
+ return false;
56
+ }
57
+ code = path.charCodeAt(1);
58
+ if (code !== CharCode.Backslash) {
59
+ return false;
60
+ }
61
+ let pos = 2;
62
+ const start = pos;
63
+ for (; pos < path.length; pos++) {
64
+ code = path.charCodeAt(pos);
65
+ if (code === CharCode.Backslash) {
66
+ break;
67
+ }
68
+ }
69
+ if (start === pos) {
70
+ return false;
71
+ }
72
+ code = path.charCodeAt(pos + 1);
73
+ if (isNaN(code) || code === CharCode.Backslash) {
74
+ return false;
75
+ }
76
+ return true;
77
+ }
78
+
79
+ export function getFileSystemPath(uri: URI, useRealpaths: boolean): string {
80
+ let result = uri.fsPath;
81
+ if (process.platform === 'win32' && result.length >= 2 && result[1] === ':') {
82
+ // Node by default uses an upper case drive letter and ESLint uses
83
+ // === to compare paths which results in the equal check failing
84
+ // if the drive letter is lower case in th URI. Ensure upper case.
85
+ result = result[0].toUpperCase() + result.substr(1);
86
+ }
87
+ if (useRealpaths) {
88
+ result = tryRealpath(result);
89
+ } else if (process.platform === 'win32' || process.platform === 'darwin') {
90
+ const realpath = tryRealpath(result);
91
+ // Only use the real path if only the casing has changed.
92
+ if (realpath.toLowerCase() === result.toLowerCase()) {
93
+ result = realpath;
94
+ }
95
+ }
96
+ return result;
97
+ }
98
+
99
+ function tryRealpath(path: string): string {
100
+ try {
101
+ return fs.realpathSync.native(path);
102
+ } catch (error) {
103
+ // Silently ignore errors from `fs.realpathSync` to handle scenarios where
104
+ // the file being linted is not yet written to disk. This occurs in editors
105
+ // such as Neovim for non-written buffers.
106
+ return path;
107
+ }
108
+ }
109
+
110
+ export function normalizePath(path: string): string;
111
+ export function normalizePath(path: undefined): undefined;
112
+ export function normalizePath(path: string | undefined): string | undefined {
113
+ if (path === undefined) {
114
+ return undefined;
115
+ }
116
+ if (process.platform === 'win32') {
117
+ return path.replace(/\\/g, '/');
118
+ }
119
+ return path;
120
+ }
121
+
122
+ export function getUri(documentOrUri: string | TextDocument | URI): URI {
123
+ return Is.string(documentOrUri)
124
+ ? URI.parse(documentOrUri)
125
+ : documentOrUri instanceof URI
126
+ ? documentOrUri
127
+ : URI.parse(documentOrUri.uri);
128
+ }
@@ -0,0 +1,5 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ interface Thenable<T> extends PromiseLike<T> {}
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "Node16",
5
+ "moduleResolution": "Node16",
6
+ "target": "ES2022",
7
+ "sourceMap": true,
8
+ "outDir": "out",
9
+ "rootDir": "src",
10
+ "lib": [ "ES2023" ],
11
+ "tsBuildInfoFile": "out/compile.tsbuildinfo",
12
+ "incremental": true,
13
+ "composite": true
14
+ },
15
+ "include": [
16
+ "src"
17
+ ],
18
+ "exclude": [
19
+ "node_modules"
20
+ ]
21
+ }
@@ -0,0 +1,25 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ //@ts-check
7
+
8
+ 'use strict';
9
+
10
+ const withDefaults = require('../shared.webpack.config');
11
+ const path = require('path');
12
+
13
+ module.exports = withDefaults({
14
+ context: path.join(__dirname),
15
+ entry: {
16
+ extension: './src/eslintServer.ts',
17
+ },
18
+ resolve: {
19
+ symlinks: false
20
+ },
21
+ output: {
22
+ filename: 'eslintServer.js',
23
+ path: path.join(__dirname, 'out')
24
+ }
25
+ });