🔝 Top 4 Visual Studio Code Extensions for React Developers 👩‍💻

  1. ES7 React/Redux/GraphQL/React-Native snippets

    Publisher: dsznajder

    Use React snippets to speed up your React game!

    Install using Ctrl+P

    ext install dsznajder.es7-react-js-snippets

    Some useful snippets

    imp import moduleName from 'module'
    imd import { destructuredModule } from 'module'

    rfce



    import React from 'react'

    function ComponentName() {
      return (
        <div>

        </div>
      )
    }

    export default ComponentName

  2. ESLint

    Publisher: Dirk Baeumer

    ESLint finds and fixes problems in JavaScript code. ESLint requires to be run from the command. This VSC extension checks your code on the fly. ESLint can fix code when the file is saved.

    Install this extension using Ctrl+P

    ext install dbaeumer.vscode-eslint

    Install ESLint into your React project

    npm install eslint --save-dev

    If you used npx create-react-app app-name to create your react app then you are good to go with the basic React ESLint configuration as the package.json file already has the ESlint configuration. Stosowanie npx eslint --init to create a .eslintrc file with alternate configurations.

    If you have created .eslintrc.json file, następnie dodaj następujące reguły, aby umożliwić reagowanie na rozszerzenia js.


    "rules": {
      "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
      "react/react-in-jsx-scope": "off",
      "react/jsx-one-expression-per-line": [0, { "allow": "literal" }]   "no-unused-vars": [1, { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]

    }

    Dodaj następujące elementy do ustawień VSC (Ctrl+, ➡ Naciśnij ikonę Otwórz ustawienia), uruchomić ESLint przy zapisie, i ustaw VSC na koniec linii w lf, aby ESLint nie narzekał.


    "files.eol": "\n",
    "editor.codeActionsOnSave": {
      "source.fixAll": true
    }

  3. Ładniejsze – Formater kodu

    Publisher: Ładniejsze

    Formatuje kod, aby był spójny, aby ułatwić czytanie.

    Ładniej potrafi sformatować JavaScript, Maszynopis, JSX, HTML, CSS, WykresQL, Przecena i YAML.

    ESLint może również formatować kod JavaScript i React. W związku z tym, Zalecam skonfigurowanie ESLint do formatowania plików JavaScript i React, następnie użyj Prettier do sformatowania CSS, JSON, GraphQL i przecena w React.

    Ładniej wymaga, aby linia poleceń działała na twoim kodzie. To rozszerzenie VSC sformatuje Twój kod po zapisaniu pliku kodu.

    Install this extension using Ctrl+P

    ext install esbenp.prettier-vscode

    Zainstaluj ładniej w swoim projekcie…

    npm install --save-dev --save-exact prettier

    Stwórz .prettierrc.json plik do katalogu głównego projektu React, aby utworzyć niestandardowe reguły formatowania.


    {
      "trailingComma": "es5",
      "semi": true,
      "singleQuote": true,
      "jsxSingleQuote": true,
      "printWidth": 120
    }

    Iść do Prettier site for more config. reguły.

    Dodaj następujące elementy do ustawień VSC (Ctrl+, ➡ Naciśnij ikonę Otwórz ustawienia), to format on save, disable on JavaScript and React code.


    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "prettier.disableLanguages": ["javascript", "javascriptreact"]

  4. Rainbow Brackets

    Publisher: 2gua

    Sets different colours to round, square and curly brackets. This allows you to easily visually match bracket pairs in your React code.

    Install this extension using Ctrl+P

    ext install 2gua.rainbow-brackets