Skip to content

Commit

Permalink
Add VS Code workspace config
Browse files Browse the repository at this point in the history
Summary:
## Summary

Adds and recommends use of `react-native.code-workspace` file when using VS Code. This disables the built-in TypeScript Language Service for `.js` files, recommends extensions, enables `formatOnSave`, and configures Flow language support.

**Motivation**

This is a DevX benefit for **React Native contributors** using open source VS Code — in particular to help with recent/trivial papercuts in PRs such as inserting a final newline in files (configured by EditorConfig).

**Recommended extensions**

NOTE: The recommended extensions list is currently minimal — happy to extend this now or in future, but let's aim to keep these conservative.

- Flow — language support
- EditorConfig — formatting based on `.editorconfig`, all file types
- Prettier — formatting for JS* files
- ESLint — linter for JS* files
- Kotlin — language support

**Why `react-native.code-workspace`?**

`.code-workspace` files have slight extra behaviours over a `.vscode/` directory:
- Allows user to opt-in or skip.
- Allows double-click launching from file managers.
- Allows base folder (and any subfolders in future) to be opened with local file tree scope (useful in fbsource!)
- (Minor point) Single config file over multiple files.

https://code.visualstudio.com/docs/editor/workspaces

Changelog: [Internal]

## Test plan

Aganst a new unconfigured copy of Visual Studio Code Insiders.

**Without workspace config**

❌ `.js` files raise errors by default (built-in TypeScript language service)

 {F1478195672} 

❌ When using the Flow VS Code extension, the wrong version (global) of Flow is used.

**With workspace config**

✅ Workspace config is suggested when folder is opened in VS Code

 {F1478194795} 

✅ Dialog is shown on workspace launch with recommended VS Code extensions

{F1478196003} 

✅ Built-in TypeScript Language Service is disabled for `.js` files
✅ Flow language support is configured correctly against `flow` version in `package.json`

{F1478291085}
{F1478200649}

Differential Revision: D55698495
  • Loading branch information
huntie authored and facebook-github-bot committed Apr 4, 2024
1 parent dc83cb7 commit 6fc8678
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions react-native.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"folders": [
{
"path": "."
}
],
"extensions": {
"recommendations": [
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"flowtype.flow-for-vscode",
"mathiasfrohlich.Kotlin"
],
},
"settings": {
"editor.formatOnSave": true,
"flow.pathToFlow": "${workspaceFolder}/node_modules/.bin/flow",
"javascript.validate.enable": false
}
}

0 comments on commit 6fc8678

Please sign in to comment.