-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not force VS Code settings (#37498)
* Suggest VS Code settings * Remove hard-coded VS Code settings * Update .gitignore * Add simple VS Code symlink script * Add VS Code task * Update tools/install-vscode-settings.sh Co-authored-by: Brad Jorsch <[email protected]> * Add prettier config back * Copy instead of symlink * Update comment * Rename to a .jsonc file * Add some comments * Add "managed" comment to file * Detect managed vs. custom settings * Add schema for settings autocomplete --------- Co-authored-by: Brad Jorsch <[email protected]>
- Loading branch information
Showing
4 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,41 +1,42 @@ | ||
// This is a managed VS Code settings file. | ||
// It is copied into place by `tools/install-vscode-settings.sh`. | ||
// If you no longer want the settings managed, remove these comments. | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
// 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, | ||
"**/.DS_Store/**": true, | ||
"**/.git/**": true, | ||
"**/.hg/**": true, | ||
"**/.svn/**": true, | ||
"**/bower_components/**": true, | ||
"**/CVS/**": true, | ||
"**/jetpack_vendor/**": true, | ||
"**/node_modules/**": true, | ||
"**/vendor/**": true, | ||
"**/vendor/**": true | ||
}, | ||
// Don't run Intelephense on these files. | ||
"intelephense.files.exclude": [ | ||
"**/.cache/**", | ||
"**/.git/**", | ||
"**/.svn/**", | ||
"**/.hg/**", | ||
"**/.history/**", | ||
"**/bower_components/**", | ||
"**/jetpack_vendor/**", | ||
"**/packages/**/wordpress/**", | ||
"**/projects/**/wordpress/**", | ||
"**/plugins/**/wordpress/**", | ||
"**/vendor/**", | ||
"**/vendor/**" | ||
], | ||
"phpCodeSniffer.autoExecutable": true, | ||
"phpCodeSniffer.standard": "Automatic", | ||
// Have PHPCS ignore these files. | ||
"phpCodeSniffer.exclude": [ | ||
"**/.git/**", | ||
"**/.svn/**", | ||
"**/.hg/**", | ||
"**/.cache/**", | ||
"**/jetpack_vendor/**", | ||
"**/vendor/**", | ||
"**/vendor/**" | ||
], | ||
// Use this wp-prettier from this path. | ||
"prettier.prettierPath": "tools/js-tools/node_modules/prettier/index.cjs" | ||
} |
This file contains 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,20 @@ | ||
{ | ||
// 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": "./tools/install-vscode-settings.sh", | ||
"runOptions": { | ||
"runOn": "folderOpen" | ||
}, | ||
"problemMatcher": [], | ||
"presentation": { | ||
"reveal": "silent", | ||
"close": true | ||
} | ||
} | ||
] | ||
} |
This file contains 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,43 @@ | ||
#!/usr/bin/env bash | ||
# This script allows a user to install repo-recommended VS Code settings. | ||
# See: p1HpG7-sQE-p2 | ||
# | ||
# Exit codes: | ||
# 0: All is well | ||
# 1: Repo settings template is missing | ||
# 2: Settings file creation failed | ||
|
||
# Go to monorepo root. | ||
cd "$(dirname "${BASH_SOURCE[0]}")/.." | ||
|
||
template_file=.vscode/settings.dist.jsonc | ||
dest_file=.vscode/settings.json | ||
|
||
# Abort if repo settings file is missing. | ||
if [[ ! -f "$template_file" ]]; then | ||
echo "Repo settings template is missing; aborting." | ||
exit 1 | ||
fi | ||
|
||
# Abort if settings file already exists and managed comment is missing. | ||
managed_comment='// This is a managed VS Code settings file.' | ||
if [[ -f "$dest_file" ]]; then | ||
if diff -q "$template_file" "$dest_file" > /dev/null; then | ||
echo 'Managed settings are up to date; no changes needed.' | ||
exit | ||
elif [[ $(head -1 "$dest_file") != "$managed_comment" ]]; then | ||
echo "Custom settings file; aborting." | ||
exit | ||
fi | ||
fi | ||
|
||
# Copy file into place. | ||
cp "$template_file" "$dest_file" | ||
|
||
# Verify success. | ||
if [[ ! -f "$dest_file" ]] || ! diff -q "$template_file" "$dest_file" > /dev/null; then | ||
echo "Error copying settings into place!" | ||
exit 2 | ||
fi | ||
|
||
echo "Copied managed settings into place." |