diff --git a/.gitignore b/.gitignore index e997fd3f..0d311d15 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,7 @@ output/* *.swp # Vscode files -.vscode +.vscode/settings.json /patches /oldimpl diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..1234a22c --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,15 @@ +{ + "recommendations": [ + "editorconfig.editorconfig", + "esbenp.prettier-vscode", + "streetsidesoftware.code-spell-checker", + "codezombiech.gitignore", + "aaron-bond.better-comments", + "mikestead.dotenv", + "stylelint.vscode-stylelint" + ], + "unwantedRecommendations": [ + "nucllear.vscode-extension-auto-import", + "steoates.autoimport" + ] +} diff --git a/.vscode/settings.template.json b/.vscode/settings.template.json new file mode 100644 index 00000000..26fb552b --- /dev/null +++ b/.vscode/settings.template.json @@ -0,0 +1,183 @@ +{ + "eslint.nodePath": "frontend/config/eslint-config/node_modules/eslint", + "prettier.prettierPath": "frontend/config/eslint-config/node_modules/prettier", + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.formatOnSave": true, + "editor.formatOnType": false, + "editor.formatOnPaste": false, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.codeActionsOnSave": { + "source.fixAll": "never", + "source.fixAll.eslint": "never", + "source.removeUnused": "never", + "source.organizeImports": "never" + // "source.sortImports": "always" + }, + "editor.formatOnSaveMode": "modificationsIfAvailable", + "search.followSymlinks": false, + "search.exclude": { + "**/node_modules": true, + "**/.nyc_output": true, + "**/.rush": true, + "**/pnpm-lock.yaml": true, + "**/CHANGELOG.json": true, + "**/CHANGELOG.md": true, + "common/changes": true, + "**/output": true, + "**/lib": true, + "**/rush-logs": true, + "**/dist": true, + "**/coverage": true, + "common/temp": true + }, + "eslint.workingDirectories": [ + { + "mode": "auto" + } + ], + "files.defaultLanguage": "plaintext", + "files.associations": { + ".code-workspace": "jsonc", + ".babelrc": "json", + ".eslintrc": "jsonc", + ".eslintrc*.json": "jsonc", + ".stylelintrc": "javascript", + "stylelintrc": "jsonc", + "*.json": "jsonc", + "package.json": "json", + ".htmlhintrc": "jsonc", + "htmlhintrc": "jsonc", + "Procfile*": "shellscript", + "README": "markdown", + "**/coverage/**/*.*": "plaintext", + "OWNERS": "yaml", + // Set the pnpm-lock file to plaintext to avoid parsing; otherwise, VSCode may freeze when opening the file + "**/pnpm-lock.yaml": "plaintext", + "**/dist/**": "plaintext", + "**/dist_*/**": "plaintext", + "*.map": "plaintext", + "*.log": "plaintext" + }, + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true, + "**/.rush": true, + "**/.swc": true + }, + "files.watcherExclude": { + "**/.git/objects/**": true, + "**/.git/subtree-cache/**": true, + "**/node_modules/*/**": true + }, + "search.useIgnoreFiles": true, + // + "editor.rulers": [80, 120], + "files.eol": "\n", + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + "cSpell.diagnosticLevel": "Warning", + "eslint.probe": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + "editor.semanticHighlighting.enabled": false, + "eslint.format.enable": false, + "eslint.enable": true, + "eslint.useFlatConfig": true, + "eslint.codeActionsOnSave.mode": "problems", + "eslint.lintTask.enable": false, + "javascript.validate.enable": false, + "typescript.tsdk": "frontend/config/ts-config/node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true, + "typescript.disableAutomaticTypeAcquisition": true, + "typescript.format.enable": false, + "typescript.referencesCodeLens.enabled": false, + "typescript.preferGoToSourceDefinition": true, + "typescript.updateImportsOnFileMove.enabled": "never", + // tsserver logs are not automatically deleted and accumulate over time, causing disk space issues, so disabled by default + "typescript.tsserver.log": "off", + "typescript.tsserver.experimental.enableProjectDiagnostics": false, + "typescript.workspaceSymbols.excludeLibrarySymbols": true, + "editor.minimap.enabled": true, + "typescript.preferences.includePackageJsonAutoImports": "off", + "typescript.suggest.autoImports": true, + "typescript.tsserver.maxTsServerMemory": 10240, + "typescript.tsserver.enableRegionDiagnostics": false, + "typescript.tsserver.watchOptions": { + "fallbackPolling": "dynamicPriorityPolling", + "synchronousWatchDirectory": true, + "watchDirectory": "useFsEvents", + "watchFile": "useFsEventsOnParentDirectory", + "excludeDirectories": ["/**/node_modules"], + "excludeLibrarySymbols": true, + "excludeFiles": ["/**/node_modules/**"] + }, + "css.validate": false, + "scss.validate": false, + "less.validate": false, + "stylelint.enable": true, + "stylelint.validate": ["css", "scss", "less"], + "stylelint.stylelintPath": "frontend/config/stylelint-config/node_modules/stylelint", + "emmet.triggerExpansionOnTab": true, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[yaml]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[less]": { + "editor.defaultFormatter": "stylelint.vscode-stylelint" + }, + "[scss]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[ignore]": { + "editor.defaultFormatter": "foxundermoon.shell-format" + }, + "[shellscript]": { + "editor.defaultFormatter": "foxundermoon.shell-format" + }, + "[dotenv]": { + "editor.defaultFormatter": "foxundermoon.shell-format" + }, + "[svg]": { + "editor.defaultFormatter": "jock.svg" + }, + "svg.preview.background": "white", + "[xml]": { + "editor.defaultFormatter": "mblode.pretty-formatter" + }, + "[sql]": { + "editor.defaultFormatter": "adpyke.vscode-sql-formatter" + }, + "git.openRepositoryInParentFolders": "always", + "references.preferredLocation": "view" +} diff --git a/rush.json b/rush.json index c5ea5974..fda0b950 100644 --- a/rush.json +++ b/rush.json @@ -13,7 +13,7 @@ "repository": {}, "eventHooks": { "preRushInstall": [], - "postRushInstall": [], + "postRushInstall": ["scripts/hooks/post-rush-install.sh"], "preRushBuild": [], "postRushBuild": [] }, diff --git a/scripts/hooks/post-rush-install.sh b/scripts/hooks/post-rush-install.sh new file mode 100644 index 00000000..ae624ec9 --- /dev/null +++ b/scripts/hooks/post-rush-install.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Copyright 2025 coze-dev Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +set -e + +# Get script directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Setup VSCode settings if needed +bash "$SCRIPT_DIR/setup-vscode-settings.sh" + diff --git a/scripts/hooks/setup-vscode-settings.sh b/scripts/hooks/setup-vscode-settings.sh new file mode 100644 index 00000000..4a5f15c2 --- /dev/null +++ b/scripts/hooks/setup-vscode-settings.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# +# Copyright 2025 coze-dev Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +# Script to ensure .vscode/settings.json exists by copying from template +# This script creates default VSCode settings if none exist + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" +VSCODE_DIR="$PROJECT_ROOT/.vscode" +SETTINGS_FILE="$VSCODE_DIR/settings.json" +TEMPLATE_FILE="$VSCODE_DIR/settings.template.json" + +# Function to log messages (only when VERBOSE=true) +log() { + if [[ "${VERBOSE:-false}" == "true" ]]; then + echo "[setup-vscode-settings] $1" + fi +} + +# Create .vscode directory if it doesn't exist +if [[ ! -d "$VSCODE_DIR" ]]; then + log "Creating .vscode directory..." + mkdir -p "$VSCODE_DIR" +fi + +# Check if settings.json exists +if [[ ! -f "$SETTINGS_FILE" ]]; then + log "settings.json not found" + + # Check if template file exists + if [[ -f "$TEMPLATE_FILE" ]]; then + log "Copying settings.template.json to settings.json..." + cp "$TEMPLATE_FILE" "$SETTINGS_FILE" + log "✓ settings.json created from template" + else + log "Warning: settings.template.json not found, creating minimal settings.json..." + + # Create a minimal settings.json if template doesn't exist + cat > "$SETTINGS_FILE" << 'EOF' +{ + "search.exclude": { + "**/node_modules": true, + "**/common/temp": true, + "**/.rush": true + }, + "files.exclude": { + "**/node_modules": true, + "**/common/temp": true, + "**/.rush": true + } +} +EOF + log "✓ Minimal settings.json created" + fi +else + log "settings.json already exists, skipping..." +fi \ No newline at end of file