diff --git a/.gitignore b/.gitignore index 453417116..b169c14d9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,9 @@ *.log /errors /test*.* -/.vscode +/.vscode/**/* +!/.vscode/extensions.json +!/.vscode/settings.example.json /dist* /website/build /website/i18n diff --git a/.gitpod.yml b/.gitpod.yml index 543c194cb..cf602b034 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -4,22 +4,3 @@ tasks: - init: | brew install hyperfine yarn - -github: - # https://www.gitpod.io/docs/prebuilds/#configure-prebuilds - prebuilds: - master: true # enable for the default branch (even if it's not named "master") - branches: true - pullRequests: true - pullRequestsFromForks: true - addCheck: true - addComment: false - addBadge: true - addLabel: false - -vscode: - extensions: - - esbenp.prettier-vscode - - dbaeumer.vscode-eslint - - editorconfig.editorconfig - - streetsidesoftware.code-spell-checker diff --git a/.prettierrc b/.prettierrc index e51195551..20c2d97a0 100644 --- a/.prettierrc +++ b/.prettierrc @@ -5,3 +5,7 @@ overrides: - files: "bin/prettier.cjs" options: trailingComma: none + # TODO: Enable this after `jsonc` parser released + # - files: ".vscode/*.json" + # options: + # parser: jsonc diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..a0ee92829 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode", + "editorconfig.editorconfig", + "dbaeumer.vscode-eslint", + "streetsidesoftware.code-spell-checker" + ] +} diff --git a/.vscode/settings.example.json b/.vscode/settings.example.json new file mode 100644 index 000000000..a01541d57 --- /dev/null +++ b/.vscode/settings.example.json @@ -0,0 +1,15 @@ +{ + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": ["source.fixAll.eslint"] + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "prettier.requireConfig": true, + "eslint.experimental.useFlatConfig": true, + "files.exclude": { + "dist*": true + } +} diff --git a/.yarn/plugins/plugin-setup-editor.cjs b/.yarn/plugins/plugin-setup-editor.cjs new file mode 100644 index 000000000..2d8c3ea6e --- /dev/null +++ b/.yarn/plugins/plugin-setup-editor.cjs @@ -0,0 +1,30 @@ +const fs = require("node:fs"); +const path = require("node:path"); + +module.exports = { + name: "plugin-setup-editor", + factory: () => ({ + hooks: { + afterAllInstalled() { + const settingsFile = path.join( + __dirname, + "../../.vscode/settings.json", + ); + + const settingsExampleFile = path.join( + __dirname, + "../../.vscode/settings.example.json", + ); + + if ( + fs.existsSync(settingsFile) || + !fs.existsSync(settingsExampleFile) + ) { + return; + } + + fs.writeFileSync(settingsFile, fs.readFileSync(settingsExampleFile)); + }, + }, + }), +}; diff --git a/.yarnrc.yml b/.yarnrc.yml index 958af5b26..24c9c61ee 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -6,4 +6,7 @@ enableGlobalCache: true nodeLinker: node-modules +plugins: + - .yarn/plugins/plugin-setup-editor.cjs + yarnPath: .yarn/releases/yarn-4.0.2.cjs