Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate all samples to eslint 9 #1115

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 0 additions & 20 deletions .base-sample/.eslintrc.js

This file was deleted.

43 changes: 43 additions & 0 deletions .base-sample/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* ESLint configuration for the project.
*
* See https://eslint.style and https://typescript-eslint.io for additional linting options.
*/
// @ts-check
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin';

export default tseslint.config(
{
ignores: [
'out'
]
},
js.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
plugins: {
'@stylistic': stylistic
},
rules: {
'curly': 'warn',
'@stylistic/semi': ['warn', 'always'],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/naming-convention': [
'warn',
{
'selector': 'import',
'format': ['camelCase', 'PascalCase']
}
],
'@typescript-eslint/no-unused-vars': [
'error',
{
'argsIgnorePattern': '^_'
}
]
}
}
);
13 changes: 7 additions & 6 deletions .base-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint",
"watch": "tsc -watch -p ./"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@stylistic/eslint-plugin": "^2.9.0",
"@types/node": "^20",
"@types/vscode": "^1.74.0",
"@typescript-eslint/eslint-plugin": "^7.14.0",
"@typescript-eslint/parser": "^7.14.0",
"eslint": "^8.26.0",
"typescript": "^5.6.2"
"@types/vscode": "1.90.0",
"eslint": "^9.13.0",
"typescript": "^5.6.2",
"typescript-eslint": "^8.11.0"
}
}
22 changes: 22 additions & 0 deletions .scripts/copy-into.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @ts-check
/**
* Copies a file into every sample, overwriting the existing file if it exists.
*/
const fs = require('fs');
const path = require('path');
const { samples, lspSamples } = require('./samples')

const filePath = process.argv[2];
if (!filePath) {
console.error('Please provide a file path as the argument.');
process.exit(1);
}

const fileName = path.basename(filePath);
const fileContent = fs.readFileSync(filePath);

for (const sample of [...samples, ...lspSamples]) {
const destinationPath = path.join(sample.path, fileName);
fs.writeFileSync(destinationPath, fileContent);
console.log(`Copied ${fileName} to ${sample.path}`);
}
39 changes: 32 additions & 7 deletions .scripts/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,18 @@ const samples = [
{ description: 'shell-integration-sample', excludeFromReadme: true, path: 'shell-integration-sample', guide: null, apis: [], contributions: [] },
{ description: 'tabs-api-sample', excludeFromReadme: true, path: 'tabs-api-sample', guide: null, apis: [], contributions: [] },
{ description: 'telemetry-sample', excludeFromReadme: true, path: 'telemetry-sample', guide: null, apis: [], contributions: [] },
{ description: 'lm-api-tutorial', excludeFromReadme: true, path: 'lm-api-tutorial', guide: null, apis: [], contributions: [] },
{ description: 'wasm-component-model', excludeFromReadme: true, path: 'wasm-component-model', guide: null, apis: [], contributions: [] },
{ description: 'wasm-component-model-async', excludeFromReadme: true, path: 'wasm-component-model-async', guide: null, apis: [], contributions: [] },
{ description: 'wasm-component-model-resource', excludeFromReadme: true, path: 'wasm-component-model-resource', guide: null, apis: [], contributions: [] },
]

/** LSP specific samples */
/** @type {Sample[]} */
/**
* LSP specific samples
* DO NOT add non-LSP items here. Add it to `samples` list.
*
* @type {Sample[]}
*/
const lspSamples = [
{
description: 'Snippet Sample',
Expand Down Expand Up @@ -378,11 +386,28 @@ const lspSamples = [
apis: [],
contributions: []
},
]
/**
* LSP specific samples
* DO NOT add non-LSP items here. Add it to `samples` list.
*/
{
description: 'LSP Embedded Language Service',
path: 'lsp-embedded-language-service',
guide: null,
apis: [],
contributions: []
},
{
description: 'LSP Embedded Request Forwarding',
path: 'lsp-embedded-request-forwarding',
guide: null,
apis: [],
contributions: []
},
{
description: 'Wasm language server',
path: 'wasm-language-server',
guide: null,
apis: [],
contributions: []
},
];

// eslint-disable-next-line no-undef
module.exports = {
Expand Down
5 changes: 4 additions & 1 deletion .scripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ function validateSamplesAreListed() {
}

for (const fileName of fs.readdirSync(root)) {
if (!fileName.endsWith('-sample') || fileName.startsWith('.')) {
if (fileName === 'node_modules'
|| fileName.startsWith('.')
|| !fs.lstatSync(path.join(root, fileName)).isDirectory()
) {
continue;
}

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ You need to have [node](https://nodejs.org/en/) and [npm](https://nodejs.org/en/
| [notebook-extend-markdown-renderer-sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/notebook-extend-markdown-renderer-sample) | [/api/extension-guides/notebook#notebook-renderer](https://code.visualstudio.com/api/extension-guides/notebook#notebook-renderer) | [contributes.notebookRenderer](https://code.visualstudio.com/api/references/contribution-points#contributes.notebookRenderer) |
| [jupyter-server-provider-sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/jupyter-server-provider-sample) | N/A | |
| [Chat Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/chat-sample) | N/A | |
| [Chat Tutorial](https://github.com/Microsoft/vscode-extension-samples/tree/main/chat-tutorial) | N/A | |
| [Notifications Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/notifications-sample) | N/A | |
<!-- SAMPLES_END -->

Expand All @@ -82,6 +83,9 @@ You need to have [node](https://nodejs.org/en/) and [npm](https://nodejs.org/en/
| [LSP Multi Root Server Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-multi-server-sample) | https://github.com/Microsoft/vscode/wiki/Extension-Authoring:-Adopting-Multi-Root-Workspace-APIs#language-client--language-server | |
| [LSP Web Extension Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-web-extension-sample) | [/api/language-extensions/language-server-extension-guide](https://code.visualstudio.com/api/language-extensions/language-server-extension-guide) | |
| [LSP User Input Sample](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-user-input-sample) | N/A | |
| [LSP Embedded Language Service](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-embedded-language-service) | N/A | |
| [LSP Embedded Request Forwarding](https://github.com/Microsoft/vscode-extension-samples/tree/main/lsp-embedded-request-forwarding) | N/A | |
| [Wasm language server](https://github.com/Microsoft/vscode-extension-samples/tree/main/wasm-language-server) | N/A | |
<!-- LSP_SAMPLES_END -->

## License
Expand Down
24 changes: 0 additions & 24 deletions authenticationprovider-sample/.eslintrc.json

This file was deleted.

43 changes: 43 additions & 0 deletions authenticationprovider-sample/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* ESLint configuration for the project.
*
* See https://eslint.style and https://typescript-eslint.io for additional linting options.
*/
// @ts-check
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin';

export default tseslint.config(
{
ignores: [
'out'
]
},
js.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
plugins: {
'@stylistic': stylistic
},
rules: {
'curly': 'warn',
'@stylistic/semi': ['warn', 'always'],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/naming-convention': [
'warn',
{
'selector': 'import',
'format': ['camelCase', 'PascalCase']
}
],
'@typescript-eslint/no-unused-vars': [
'error',
{
'argsIgnorePattern': '^_'
}
]
}
}
);
Loading