sublimelsp / LSP-eslint

ESLint support for Sublime LSP plugin
MIT License
36 stars 5 forks source link

eslint language ID? #23

Closed rwols closed 4 years ago

rwols commented 4 years ago

It's a bit weird that the language ID is "eslint". Can we get away with having "javascript" and "vue" as separate language IDs?

ST3:

"languages":
[
    {
        "languageId": "javascript",
        "scopes": ["source.js"],
        "syntaxes":
        [
            "Packages/Babel/JavaScript (Babel).sublime-syntax",
            "Packages/JavaScript/JavaScript.sublime-syntax",
            "Packages/JavaScript/JavaScript.sublime-syntax",
            "Packages/User/JS Custom/Syntaxes/React.sublime-syntax"
        ]
    },
    {
        "languageId": "vue",
        "scopes": ["text.html.vue"],
        "syntaxes": ["Packages/Vue Syntax Highlight/Vue Component.sublime-syntax"]
    }
],

ST4:

"languages":
[
    {
        "languageId": "javascript",
        "document_selector": "source.js"
    },
    {
        "languageId": "vue",
        "document_selector": "text.html.vue"
    }
],
rchl commented 4 years ago

Actually eslint is incorrect. It should be language-specific ID.

As far as I can see, a better default options are provided based on the language ID. So if project specifies all settings itself correctly then there is no problem but for projects/folders that don't have proper configuration, having correct language ID should improve experience.

Some relevant parts of the code: [1] https://github.com/microsoft/vscode-eslint/blob/9b757bcee341adc983fdb9a95a4193b39a9ac34b/server/src/eslintServer.ts#L755-L766 [2] https://github.com/microsoft/vscode-eslint/blob/9b757bcee341adc983fdb9a95a4193b39a9ac34b/server/src/eslintServer.ts#L587-L619

rchl commented 4 years ago

The languageId is used when given file is set to validate: 'probe' which is sort of a "conditional" validation as opposed to normal validate: 'enable' that doesn't use that conditional logic. The "probe" options are used for some secondary file types and can be configured from eslint settings.

rchl commented 4 years ago

But actually the eslint server version that we are using doesn't support that feature yet so all this explanation was for nothing ;). That version doesn't really care about language ID but we can fix it anyway.