Repository navigation
VS Code: Add managed workspace config #84025
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
de5c2c9
Monorepo tools: Add a VS Code settings installer
manzoorwanijk 18a73f1
VS Code: Add managed workspace config
manzoorwanijk 06347fc
Docs: Point to the managed VS Code workspace settings
manzoorwanijk 1223581
Docs: Clarify when the VS Code settings installer overwrites
manzoorwanijk 38dc766
Monorepo tools: Document the VS Code settings installer
manzoorwanijk 236485e
VS Code: Drop the Native TypeScript preview recommendation
manzoorwanijk 23261a4
Revert "VS Code: Drop the Native TypeScript preview recommendation"
manzoorwanijk 21bb2f5
VS Code: Name the line that keeps settings managed
manzoorwanijk 9bbfac2
Docs: Mention the TypeScript 7 workspace tsdk prompt
manzoorwanijk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| /** | ||
| * List of recommended extensions to use for this workspace. | ||
| * The identifier of an extension is always `${publisher}.${name}`, | ||
| * which is a part of the URL, e.g. https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint | ||
| * You can view these extensions using the command `Extensions: Show Recommended Extensions`. | ||
| */ | ||
| "recommendations": [ | ||
| "editorconfig.editorconfig", // EditorConfig | ||
| "bmewburn.vscode-intelephense-client", // PHP Intelephense | ||
| "dbaeumer.vscode-eslint", // ESLint | ||
| "esbenp.prettier-vscode", // Prettier - Code formatter | ||
| "obliviousharmony.vscode-php-codesniffer", // PHP_CodeSniffer | ||
| "stylelint.vscode-stylelint", // Stylelint | ||
| "TypeScriptTeam.native-preview" // Native TypeScript preview | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // This is a managed VS Code settings file. | ||
| // While the first line is present, opening the folder replaces this file with `.vscode/settings.dist.jsonc`. | ||
| // To customize these settings and keep your changes, delete the first line. | ||
| { | ||
| // Define schema to allow auto-completion. | ||
| "$schema": "vscode://schemas/settings/workspace", | ||
| // Don't show these files in VS Code. | ||
| "files.exclude": { | ||
| "**/.DS_Store/**": true, | ||
| }, | ||
| // Don't search these files in VS Code. | ||
| "search.exclude": { | ||
| "**/.cache/**": true, | ||
| "**/build/**": true, | ||
| "**/build-module/**": true, | ||
| "**/build-types/**": true, | ||
| "**/build-style/**": true, | ||
| "**/node_modules/**": true, | ||
| "**/vendor/**": true, | ||
| }, | ||
| // Use TypeScript from the workspace instead of VS Code's built-in TypeScript version. | ||
| "js/ts.tsdk.path": "tools/build-scripts/node_modules/@typescript/native/lib", | ||
| // Use Native TypeScript. | ||
| "js/ts.experimental.useTsgo": true, | ||
| // Use ESLint, Prettier and Stylelint from the workspaces that declare them. | ||
| "eslint.nodePath": "tools/eslint/node_modules", | ||
| "prettier.prettierPath": "packages/prettier-config/node_modules/prettier", | ||
| "stylelint.stylelintPath": "tools/stylelint/node_modules/stylelint", | ||
| // Show suppressed ESLint violations as hints. | ||
| "eslint.bulkSuppression.enable": true, | ||
| "eslint.bulkSuppression.location": "tools/eslint/suppressions.json", | ||
| "eslint.bulkSuppression.severity": "hint", | ||
| // Custom settings for PHP files. | ||
| "[php]": { | ||
| // Ensure that PHP files are formatted with PHPCS. | ||
| "editor.formatOnSave": true, | ||
| "editor.defaultFormatter": "obliviousharmony.vscode-php-codesniffer", | ||
| }, | ||
| "intelephense.environment.phpVersion": "7.4.0", | ||
| // Don't run Intelephense on these files. | ||
| "intelephense.files.exclude": [ | ||
| "**/.cache/**", | ||
| "**/.git/**", | ||
| "**/.history/**", | ||
| "**/build/**", | ||
| "**/build-module/**", | ||
| "**/build-types/**", | ||
| "**/build-style/**", | ||
| "**/node_modules/**", | ||
| "**/vendor/**", | ||
| ], | ||
| "phpCodeSniffer.autoExecutable": true, | ||
| "phpCodeSniffer.standard": "Automatic", | ||
| // Have PHPCS ignore these files. | ||
| "phpCodeSniffer.exclude": [ | ||
| "**/.git/**", | ||
| "**/.svn/**", | ||
| "**/.hg/**", | ||
| "**/.cache/**", | ||
| "**/build/**", | ||
| "**/node_modules/**", | ||
| "**/vendor/**", | ||
| ], | ||
| // Custom settings for JavaScript and TypeScript files. | ||
| "[javascript][javascriptreact][typescript][typescriptreact]": { | ||
| "editor.formatOnSave": false, | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode", | ||
| }, | ||
| // Run Code Actions for the editor. | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll.eslint": "explicit", | ||
| "source.fixAll.stylelint": "explicit", | ||
| }, | ||
| // Custom settings for CSS, SCSS, and SASS files. | ||
| "[css][scss][sass]": { | ||
| "editor.formatOnSave": false, | ||
| "editor.defaultFormatter": "stylelint.vscode-stylelint", | ||
| }, | ||
| "stylelint.validate": [ "css", "postcss", "scss" ], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| // See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
| // for the documentation about the tasks.json format | ||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "label": "Install VS Code settings", | ||
| "type": "shell", | ||
| "command": "npm", | ||
| "args": [ | ||
| "run", | ||
| "install-vscode-settings", | ||
| "--workspace", | ||
| "@wordpress/monorepo-tools" | ||
| ], | ||
| "runOptions": { | ||
| "runOn": "folderOpen" | ||
| }, | ||
| "problemMatcher": [], | ||
| "presentation": { | ||
| "reveal": "silent", | ||
| "close": true | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /** | ||
| * Install repo-recommended VS Code settings. | ||
| * | ||
| * Cross-platform replacement for a shell script: invoked from `.vscode/tasks.json` | ||
| * on folder open. Runs on Windows, macOS, and Linux without a POSIX shell. | ||
| * | ||
| * Exit codes: | ||
| * 0: All is well (or user has custom settings we shouldn't touch) | ||
| * 1: Repo settings template is missing | ||
| * 2: Settings file creation failed | ||
| */ | ||
|
|
||
| import { readFileSync, copyFileSync, existsSync } from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const REPO_ROOT = path.resolve( | ||
| path.dirname( fileURLToPath( import.meta.url ) ), | ||
| '../../..' | ||
| ); | ||
| const templateFile = path.join( REPO_ROOT, '.vscode', 'settings.dist.jsonc' ); | ||
| const destFile = path.join( REPO_ROOT, '.vscode', 'settings.json' ); | ||
| const managedComment = '// This is a managed VS Code settings file.'; | ||
|
|
||
| if ( ! existsSync( templateFile ) ) { | ||
| console.error( 'Repo settings template is missing; aborting.' ); | ||
| process.exit( 1 ); | ||
| } | ||
|
|
||
| const template = readFileSync( templateFile, 'utf8' ); | ||
|
|
||
| if ( existsSync( destFile ) ) { | ||
| const current = readFileSync( destFile, 'utf8' ); | ||
| if ( current === template ) { | ||
| console.log( 'Managed settings are up to date; no changes needed.' ); | ||
| process.exit( 0 ); | ||
| } | ||
| if ( ! current.startsWith( managedComment ) ) { | ||
| console.log( 'Custom settings file; aborting.' ); | ||
| process.exit( 0 ); | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| copyFileSync( templateFile, destFile ); | ||
| } catch ( err ) { | ||
| console.error( 'Error copying settings into place!', err ); | ||
| process.exit( 2 ); | ||
| } | ||
|
|
||
| if ( readFileSync( destFile, 'utf8' ) !== template ) { | ||
| console.error( 'Error copying settings into place!' ); | ||
| process.exit( 2 ); | ||
| } | ||
|
|
||
| console.log( 'Copied managed settings into place.' ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.