Skip to content

Emmet with JS files (JSX) is not working. #4962

Closed

Description

  • VSCode Version: Version 0.10.14-insider (0.10.14-insider)
  • OS Version: OSX 10.11.4

Steps to Reproduce:

  1. Type div> within the editor in a JS file (JSX)
  2. Emmet does not expand to <div></div> as expected.

Note:
This does work if explicitly using a jsx file with "Javascript React" as a language, but then you are missing features like jump to symbol etc that you get with "Javascript".

Activity

  1. added
    info-needed
    javascript
    on Apr 6, 2016
  2. egamma commented on Apr 6, 2016

    @egamma
    Member

    This does work if explicitly using a jsx file with "Javascript React" as a language,

    this is the recommended way to do it, we do not want to enable emmet by default in JS.

    Then you are missing features like jump to symbol etc that you get with "Javascript".

    this should not be the case, since the same language service/parser is used for .js and .jsx files. Can you add a snippet that illustrates the problem.

  3. egamma commented on Apr 13, 2016

    @egamma
    Member
  4. christianmalek commented on May 6, 2016

    @christianmalek

    Is there an option to enable emmet in JS files? The jsconfig.json doesn't seem to have an option. It's annoying to change every time the language mode to JavaScript React to be able to use Emmet.

  5. masoudgs commented on Sep 28, 2016

    @masoudgs

    Put bellow line into your user settings, most probably that will work.
    "emmet.syntaxProfiles": { "javascript": "html" }

  6. sillero commented on Oct 11, 2016

    @sillero

    "emmet.syntaxProfiles": { "javascript": "jsx" } did the trick
    it properly expands with the jsx notation (class -> className, for -> htmlFor, ...)

  7. admmasters commented on Nov 4, 2016

    @admmasters
    Author

    Confirmed - great work, thank you! Erich Gamma (@egamma) sorry it took so long for me to reply - I never received my notifications for this!

  8. johnpeele commented on Dec 28, 2016

    @johnpeele

    Confirmed as well! - Gus Ballard (@sillero)'s suggestion worked for me.

    Visual Studio Code - v1.8.1
    Mac OS X - v10.11.6

  9. Cipher-geek-Studios commented on Jan 10, 2017

    @Cipher-geek-Studios

    Thanks overwriting the setting page helped me thanks.
    "emmet.syntaxProfiles": { "javascript": "html" }

  10. danfma commented on Jan 11, 2017

    @danfma

    Hey guys, this doesn´t work for tsx files. I tried with typescript, typescriptreact and javascript.

    "emmet.syntaxProfiles": {
    	"javascript": "jsx",
    	"typescript": "jsx",
    	"typescriptreact": "jsx"
    }
  11. vernondegoede commented on Jan 14, 2017

    @vernondegoede

    John Peele (@johnpeele) Did you set any other options to get this working properly? Typing div and pressing tab results in inserting HTMLDivElement

    However, typing div.test results in <div className="test"></div>.

  12. yogeshlonkar commented on Jan 17, 2017

    @yogeshlonkar

    for HTML code in tsx file (Inside render's return) I can't get single quote attributes by setting

    "emmet.syntaxProfiles": {
        "typescriptreact": {
            "attr_quotes": "single"
        }
    }
    

    this doesn't work. But If i put below in settings it works

    "emmet.syntaxProfiles": {
        "xml": {
            "attr_quotes": "single"
        }
    }
    

    is it expected behavior?

  13. 39 remaining items

  14. fpigeonjr commented on Aug 31, 2017

    @fpigeonjr

    thanks Renato Michnik de Carvalho (@rmichnik). Confirmed working on macOSX and VSCode 1.15.1

  15. antoniandre commented on Sep 12, 2017

    @antoniandre

    I have the config "emmet.triggerExpansionOnTab": true and I replaced the tab key in keybindings with ctrl+e (like in ST3) so I can keep my tab key to tab :)

  16. EQuimper commented on Sep 12, 2017

    @EQuimper

    It's only me or the first component I can tab and get the autocomplete, but the second one who is inside this the other one never work. Before all was perfect but now ...

    Video about it https://drive.google.com/open?id=0B-wdzKw8lrR8MXFYSnN0RXJydjA

  17. ramya-rao-a commented on Sep 12, 2017

    @ramya-rao-a
    Contributor

    Emanuel Quimper (@EQuimper) That looks wrong but I can't repro. Can you log a new issue with repro steps?
    The video helps but I need the exact steps and the keys you pressed

  18. bullyork commented on Sep 15, 2017

    @bullyork

    VScode Version 1.16
    the setting key has changed
    so you should set it as follows

    "emmet.includeLanguages": {
    "javascript": "jsx"
    },

  19. ramya-rao-a commented on Sep 15, 2017

    @ramya-rao-a
    Contributor

    Shergin Rodion (@beholderrk) Can you upgrade to 1.16 and see if you still have the issue?
    Emanuel Quimper (@EQuimper) Are you on 1.15.1 too?
    bullyork (@bullyork) The right hand side should be javascriptreact in your setting for emmet.includeLanguages

  20. EQuimper commented on Sep 15, 2017

    @EQuimper

    No i'm on the insiders version Ramya Rao (@ramya-rao-a) v17

    {
      // Place your settings in this file to overwrite the default settings
      "editor.fontSize": 18,
      "editor.tabSize": 2,
      "editor.fontFamily": "Operator Mono",
      // "editor.fontFamily": "Inconsolata",
      // "editor.fontFamily": "Menlo",
      "editor.wordWrapColumn": 80,
      "editor.fontLigatures": true,
      "editor.snippetSuggestions": "top",
      "editor.minimap.enabled": true,
      "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.DS_Store": true,
        "**/node_modules": true,
        "**/.idea": true,
        "**/.vscode": false,
        "**/yarn.lock": true,
        "**/tmp": true
      },
      "files.watcherExclude": {
        "**/.git/objects/**": true,
        "**/node_modules/**": true,
        "**/tmp": true
      },
      "emmet.includeLanguages": {
        "javascript": "javascriptreact"
      },
      "search.exclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/.git": true,
        "**/.DS_Store": true,
        "**/tmp": true,
        "**/coverage": true,
        "**/ios": true,
        "**/android": true,
        "_build": true,
        "deps": true
      },
      "files.trimTrailingWhitespace": true,
      "html.suggest.html5": true,
      "npm-intellisense.scanDevDependencies": true,
      "stylelint.enable": true,
      // "typescript.check.tscVersion": false,
      "window.zoomLevel": 0,
      "terminal.integrated.shell.osx": "/bin/zsh",
      "javascript.validate.enable": false,
      "extensions.autoUpdate": true,
      "terminal.integrated.fontSize": 13,
      "terminal.integrated.cursorStyle": "line",
      "sync.gist": "95e4cfd731754a9c023d59c0538fa6e6",
      "sync.lastUpload": "",
      "sync.autoDownload": false,
      "sync.autoUpload": false,
      "sync.lastDownload": "2017-08-11T20:58:30.447Z",
      "sync.forceDownload": false,
      "sync.anonymousGist": false,
      "color-highlight.markerType": "outline",
      "vsicons.projectDetection.disableDetect": true,
      "vsicons.dontShowNewVersionMessage": true,
      "fileHeaderCommentHelper.languageConfigs": {
        "language_javascript": {
          "template": [
            "/**",
            " * Project: $(projectName)",
            " * File: $(currentFile)",
            " * Author: Emanuel Quimper",
            " */"
          ]
        }
      },
      // "workbench.welcome.enabled": false,
      "workbench.iconTheme": "material-icon-theme",
      "material-icon-theme.showUpdateMessage": false,
      "sync.host": "",
      "sync.pathPrefix": "",
      "eslint.autoFixOnSave": true,
      "editor.formatOnSave": false,
      "editor.renderIndentGuides": true,
      "prettier.singleQuote": true,
      "prettier.printWidth": 80,
      "prettier.trailingComma": "all",
      "prettier.semi": true,
      "prettier.useTabs": false,
      "prettier.bracketSpacing": true,
      "sync.quietSync": false,
      "files.associations": {
        "*.gohtml": "html"
      },
      "git.enableSmartCommit": true,
      "flow.useNPMPackagedFlow": true,
      "sync.askGistName": false,
      "extensions.ignoreRecommendations": true,
      "editor.autoIndent": true,
      // "emmet.showExpandedAbbreviation": "never",
      // "editor.quickSuggestions": false,
      "emmet.triggerExpansionOnTab": true,
      "workbench.startupEditor": "newUntitledFile",
      "vscode_custom_css.imports": [
        "file:///Users/equimper/coding/customStuff/custom.css"
      ],
      "workbench.colorTheme": "One Monokai"
    }
    
  21. ramya-rao-a commented on Sep 15, 2017

    @ramya-rao-a
    Contributor

    Emanuel Quimper (@EQuimper) I copied all your settings and I still can't repro.
    Can you run code-insiders --disable-extensions and then see if you can still repro?
    It might be the case that some other extension is interfering.

  22. EQuimper commented on Sep 18, 2017

    @EQuimper

    Ramya Rao (@ramya-rao-a) So have test with the disable extensions options and all work. Which kind of extensions can interfering with emmet ? :)

  23. EQuimper commented on Sep 18, 2017

    @EQuimper
  24. beholderrk commented on Sep 19, 2017

    @beholderrk

    Ramya Rao (@ramya-rao-a) Emanuel Quimper (@EQuimper) wow thanks! The problem was precisely in this extention.

  25. ramya-rao-a commented on Sep 21, 2017

    @ramya-rao-a
    Contributor

    Emanuel Quimper (@EQuimper) Shergin Rodion (@beholderrk) Add the below in your settings and Emmet should work as expected inside the nested tag when using the babel extension

    "emmet.includeLanguages": {
          "jsx-sublime-babel-tags": "javascriptreact"
      }
    
  26. EQuimper commented on Sep 22, 2017

    @EQuimper
  27. locked and limited conversation to collaborators on Nov 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

info-neededjavascript

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions