简体   繁体   中英

How do I update my config file in vs code?

When I see example config files on VS Code they are often lengthy and offer two panels for updating (one for default settings and the other for customization). For some reason my config file is only a few lines and whenever I try to update it, nothing happens:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

For example I'm trying add a line of code to get rid of the error displayed for using .jsx in a .js file as found here and here but it doesn't work. This is just an example, I've tried other modifications as well. How do I add the below code my launch.json (and is there more than one launch.json?). As you can see, I'm super new to this so thanks for any help.

"rules": {
  "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
}

You can open:

  • default settings: Ctrl + Shift + P / Cmd + Shift + P -> Open Default Settings (JSON).
  • VS Code setting (applied to whole VS code instance): Ctrl + Shift + P / Cmd + Shift + P ` -> Open Settings (JSON).
  • workspace settings (applied only to current "project"/folder): create in root directory '.vscode' folder -> 'settings.json' file.

All these you can find in UI instead of JSON.

In your example, you provided Launch configuration (it is not vs code settings), it is used to configure how to launch/debug your application.

And if you want to get rid of errors, you don't need to use VS Code settings. These rules:

"rules": { "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], }

are configuration for eslint plugin (based on links you provided). So, you need to place these lines to .eslintrc file and eslint and appropriate plugins should be installed and properly configured.

The launch.json file is used for launching commands like building, running or debugging, you need to change some settings, not launching any thing. vsCode offers you couple of ways to declare your settings:

  1. Workspace - will save a settings.json file on your root workspace dir.
  2. User - will save a settings.json file on one of those pathes (according your os):
    1. Windows %APPDATA%\\Code\\User\\settings. json.
    2. Mac $HOME/Library/Application Support/Code/User/settings. json.
    3. Linux $HOME/. config/Code/User/settings. json.

On vsCode docs you can read all about it.

You can edit your settings by ctrl + shift + p to open the command palette and search settings, or File > Preferences > Settings (Code > Preferences > Settings on Mac).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM