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
package/esbuild.js ADDED
@@ -0,0 +1,62 @@
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
+ //@ts-check
6
+ const esbuild = require('esbuild');
7
+
8
+ /**
9
+ * @typedef {import('esbuild').BuildOptions} BuildOptions
10
+ */
11
+
12
+ /** @type BuildOptions */
13
+ const clientOptions = {
14
+ bundle: true,
15
+ external: ['vscode'],
16
+ target: 'ES2022',
17
+ platform: 'node',
18
+ sourcemap: false,
19
+ entryPoints: ['client/src/extension.ts'],
20
+ outfile: 'client/out/extension.js',
21
+ preserveSymlinks: true,
22
+ format: 'cjs',
23
+ };
24
+
25
+ /** @type BuildOptions */
26
+ const serverOptions = {
27
+ bundle: true,
28
+ target: 'ES2022',
29
+ platform: 'node',
30
+ sourcemap: false,
31
+ entryPoints: ['server/src/eslintServer.ts'],
32
+ outfile: 'server/out/eslintServer.js',
33
+ preserveSymlinks: true,
34
+ format: 'cjs',
35
+ };
36
+
37
+ function createContexts() {
38
+ return Promise.all([
39
+ esbuild.context(clientOptions),
40
+ esbuild.context(serverOptions),
41
+ ]);
42
+ }
43
+
44
+ createContexts().then(contexts => {
45
+ if (process.argv[2] === '--watch') {
46
+ const promises = [];
47
+ for (const context of contexts) {
48
+ promises.push(context.watch());
49
+ }
50
+ return Promise.all(promises).then(() => { return undefined; });
51
+ } else {
52
+ const promises = [];
53
+ for (const context of contexts) {
54
+ promises.push(context.rebuild());
55
+ }
56
+ Promise.all(promises).then(async () => {
57
+ for (const context of contexts) {
58
+ await context.dispose();
59
+ }
60
+ }).then(() => { return undefined; }).catch(console.error);
61
+ }
62
+ }).catch(console.error);
@@ -0,0 +1,129 @@
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
+ const typescriptParser = require('@typescript-eslint/parser');
6
+ const typescriptPlugin = require('@typescript-eslint/eslint-plugin');
7
+ const stylistic = require('@stylistic/eslint-plugin');
8
+
9
+ module.exports = [
10
+ {
11
+ ignores: [
12
+ 'client/out/**/*.*',
13
+ 'server/out/**/*.*'
14
+ ]
15
+ },
16
+ {
17
+ files: [
18
+ 'client/src/**/*.ts',
19
+ 'server/src/**/*.ts'
20
+ ],
21
+ ignores: [
22
+ 'eslint.config.js',
23
+ 'playgrounds/**/*.ts'
24
+ ],
25
+ plugins: {
26
+ '@typescript-eslint': typescriptPlugin,
27
+ '@stylistic': stylistic
28
+ },
29
+ languageOptions: {
30
+ sourceType: 'module',
31
+ parser: typescriptParser,
32
+ parserOptions: {
33
+ ecmaVersion: 2020
34
+ }
35
+ },
36
+
37
+ rules: {
38
+ 'semi': 'off',
39
+ '@stylistic/semi': 'error',
40
+ '@stylistic/member-delimiter-style': ['error' ,{
41
+ 'multiline': {
42
+ 'delimiter': 'semi',
43
+ 'requireLast': true
44
+ },
45
+ 'singleline': {
46
+ 'delimiter': 'semi',
47
+ 'requireLast': false
48
+ },
49
+ 'multilineDetection': 'brackets'
50
+ }],
51
+ 'indent': 'off',
52
+ '@stylistic/indent': ['warn', 'tab', { 'SwitchCase': 1 } ],
53
+ '@typescript-eslint/no-floating-promises': 'error',
54
+ '@typescript-eslint/consistent-type-exports': 'error',
55
+ '@typescript-eslint/naming-convention': [
56
+ 'warn',
57
+ {
58
+ 'selector': 'class',
59
+ 'format': [
60
+ 'PascalCase'
61
+ ],
62
+ 'leadingUnderscore': 'allow'
63
+ }
64
+ ],
65
+ 'no-extra-semi': 'warn',
66
+ 'curly': 'warn',
67
+ 'quotes': ['error', 'single', { 'allowTemplateLiterals': true } ],
68
+ 'eqeqeq': 'error',
69
+ 'constructor-super': 'warn',
70
+ 'prefer-const': [
71
+ 'warn',
72
+ {
73
+ 'destructuring': 'all'
74
+ }
75
+ ],
76
+ 'no-buffer-constructor': 'warn',
77
+ 'no-caller': 'warn',
78
+ 'no-case-declarations': 'warn',
79
+ 'no-debugger': 'warn',
80
+ 'no-duplicate-case': 'warn',
81
+ 'no-duplicate-imports': 'warn',
82
+ 'no-eval': 'warn',
83
+ 'no-async-promise-executor': 'warn',
84
+ 'no-new-wrappers': 'warn',
85
+ 'no-redeclare': 'off',
86
+ 'no-sparse-arrays': 'warn',
87
+ 'no-throw-literal': 'warn',
88
+ 'no-unsafe-finally': 'warn',
89
+ 'no-unused-labels': 'warn',
90
+ 'no-restricted-globals': [
91
+ 'warn',
92
+ 'name',
93
+ 'length',
94
+ 'event',
95
+ 'closed',
96
+ 'external',
97
+ 'status',
98
+ 'origin',
99
+ 'orientation',
100
+ 'context'
101
+ ],
102
+ 'no-var': 'warn'
103
+ }
104
+ },
105
+ {
106
+ files: [
107
+ 'client/src/**/*.ts',
108
+ ],
109
+ languageOptions: {
110
+ parserOptions: {
111
+ project: ['./tsconfig.json']
112
+ }
113
+ }
114
+
115
+ },
116
+ {
117
+ files: [
118
+ 'server/src/**/*.ts',
119
+ ],
120
+ languageOptions: {
121
+ parserOptions: {
122
+ project: ['./tsconfig.json']
123
+ }
124
+ },
125
+ rules: {
126
+ 'no-console': 'error'
127
+ }
128
+ }
129
+ ];
Binary file
@@ -0,0 +1,110 @@
1
+ # VS Code ESLint extension
2
+
3
+ The document describes the settings and setup instructions for the previous 1.9.x version of the extension.
4
+
5
+ ## Settings Options
6
+
7
+ The extension contributes the following variables to the [settings](https://code.visualstudio.com/docs/customization/userandworkspace):
8
+
9
+ - `eslint.enable`: enable/disable ESLint. Is enabled by default.
10
+ - `eslint.lintTask.enable`: whether the extension contributes a lint task to lint a whole workspace folder.
11
+ - `eslint.lintTask.options`: Command line options applied when running the task for linting the whole workspace (https://eslint.org/docs/user-guide/command-line-interface).
12
+ An example to point to a custom `.eslintrc.json` file and a custom `.eslintignore` is:
13
+ ```json
14
+ {
15
+ "eslint.lintTask.options": "-c C:/mydirectory/.eslintrc.json --ignore-path C:/mydirectory/.eslintignore ."
16
+ }
17
+ ```
18
+ - `eslint.packageManager`: controls the package manager to be used to resolve the ESLint library. This has only an influence if the ESLint library is resolved globally. Valid values are `"npm"` or `"yarn"` or `"pnpm"`.
19
+ - `eslint.options`: options to configure how ESLint is started using the [ESLint CLI Engine API](http://eslint.org/docs/developer-guide/nodejs-api#cliengine). Defaults to an empty option bag.
20
+ An example to point to a custom `.eslintrc.json` file is:
21
+ ```json
22
+ {
23
+ "eslint.options": { "configFile": "C:/mydirectory/.eslintrc.json" }
24
+ }
25
+ ```
26
+ - `eslint.run` - run the linter `onSave` or `onType`, default is `onType`.
27
+ - `eslint.autoFixOnSave` - enables auto fix on save. Please note auto fix on save is only available if VS Code's `files.autoSave` is either `off`, `onFocusChange` or `onWindowChange`. It will not work with `afterDelay`.
28
+ - `eslint.quiet` - ignore warnings.
29
+ - `eslint.runtime` - use this setting to set the path of the node runtime to run ESLint under.
30
+ - `eslint.nodePath` - use this setting if an installed ESLint package can't be detected, for example `/myGlobalNodePackages/node_modules`.
31
+ - `eslint.validate` - an array of language identifiers specify the files to be validated. Something like `"eslint.validate": [ "javascript", "javascriptreact", "html" ]`. If the setting is missing, it defaults to `["javascript", "javascriptreact"]`. You can also control which plugins should provide auto fix support. To do so simply provide an object literal in the validate setting with the properties `language` and `autoFix` instead of a simple `string`. An example is:
32
+ ```json
33
+ "eslint.validate": [ "javascript", "javascriptreact", { "language": "html", "autoFix": true } ]
34
+ ```
35
+
36
+ - `eslint.workingDirectories` - an array for working directories to be used. ESLint resolves configuration files (e.g. `eslintrc`) relative to a working directory. This new settings allows users to control which working directory is used for which files (see also [CLIEngine options#cwd](https://eslint.org/docs/developer-guide/nodejs-api#cliengine)).
37
+ Example:
38
+ ```
39
+ root/
40
+ client/
41
+ .eslintrc.json
42
+ client.js
43
+ server/
44
+ .eslintignore
45
+ .eslintrc.json
46
+ server.js
47
+ ```
48
+
49
+ Then using the setting:
50
+
51
+ ```javascript
52
+ "eslint.workingDirectories": [
53
+ "./client", "./server"
54
+ ]
55
+ ```
56
+
57
+ will validate files inside the server directory with the server directory as the current eslint working directory. Same for files in the client directory.
58
+
59
+ ESLint also considers the process's working directory when resolving `.eslintignore` files or when validating relative import statements like `import A from 'components/A';` for which no base URI can be found. To make this work correctly the eslint validation process needs to switch the process's working directory as well. Since changing the processes`s working directory needs to be handled with care it must be explicitly enabled. To do so use the object literal syntax as show below for the server directory:
60
+
61
+ ```javascript
62
+ "eslint.workingDirectories": [
63
+ "./client", // Does not change the process's working directory
64
+ { "directory": "./server", "changeProcessCWD": true }
65
+ ]
66
+ ```
67
+ This validates files in the client folder with the process's working directory set to the `workspace folder` and files in the server folder with the process's working directory set to the `server` folder. This is like switching to the `server` folder in a terminal if ESLint is used as a shell command.
68
+
69
+ If the `workingDirectories` setting is omitted the eslint working directory and the process's working directory is the `workspace folder`.
70
+
71
+ - `eslint.codeAction.disableRuleComment` - object with properties:
72
+ - `enable` - show disable lint rule in the quick fix menu. `true` by default.
73
+ - `location` - choose to either add the `eslint-disable` comment on the `separateLine` or `sameLine`. `separateLine` is the default.
74
+ Example:
75
+ ```json
76
+ { "enable": true, "location": "sameLine" }
77
+ ```
78
+ - `eslint.codeAction.showDocumentation` - object with properties:
79
+ - `enable` - show open lint rule documentation web page in the quick fix menu. `true` by default.
80
+
81
+ The extension is linting an individual file only on typing. If you want to lint the whole workspace set `eslint.lintTasks.enable` to `true` and the extension will also contribute the `eslint: lint whole folder` task. There is no need anymore to define a custom task in `tasks.json`.
82
+
83
+ ## Using ESLint to validate TypeScript files
84
+
85
+ A great introduction on how to lint TypeScript using ESlint can be found in the [TypeScript - ESLint](https://github.com/typescript-eslint/typescript-eslint). Please make yourself familiar with the introduction before using the VS Code ESLint extension in a TypeScript setup. Especially make sure that you can validate TypeScript files successfully in a terminal using the `eslint` command.
86
+
87
+ This project itself uses ESLint to validate its TypeScript files. So it can be used as a blueprint to get started.
88
+
89
+ ### Enable TypeScript file validation
90
+
91
+ To enable TypeScript file validation in the ESLint extension please add the following to your VS Code settings (either user or workspace):
92
+
93
+ ```json
94
+ "eslint.validate": [
95
+ { "language": "typescript", "autoFix": true }
96
+ ]
97
+ ```
98
+
99
+ To avoid validation from any TSLint installation disable TSLint using `"tslint.enable": false`.
100
+
101
+ ### Mono repository setup
102
+
103
+ As with JavaScript validating TypeScript in a mono repository requires that you tell the VS Code ESLint extension what the current working directories are. Use the `eslint.workingDirectories` setting to do so. For this repository the working directory setup looks as follows:
104
+
105
+ ```json
106
+ "eslint.workingDirectories": [
107
+ { "directory": "./client", "changeProcessCWD": true },
108
+ { "directory": "./server", "changeProcessCWD": true }
109
+ ]
110
+ ```
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema",
3
+ "properties": {
4
+ "eslintConfig": {
5
+ "description": "ESLint configuration",
6
+ "$ref": "https://json.schemastore.org/eslintrc"
7
+ }
8
+ }
9
+ }