sublimelsp / LSP-eslint

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

Support flat config #68

Closed predragnikolic closed 2 weeks ago

predragnikolic commented 3 months ago

ESLint v9 landed two weeks ago.

Currently to use the new flat config ESlint file, someone has to enable the following setting in LSP-eslint.sublime-settings:

{
    "settings": {
        "experimental.useFlatConfig": true
    }
}

The vs-code eslint extension added support for in in the latest alpha! (thank you dbaeumer) https://github.com/microsoft/vscode-eslint/issues/1644#issuecomment-2025756588

https://github.com/microsoft/vscode-eslint/releases

It would be nice to also support this soon in ST LSP.

predragnikolic commented 4 weeks ago

So it is finally released

https://github.com/microsoft/vscode-eslint/releases/tag/release%2F3.0.8

Some additional info can be found here. https://github.com/microsoft/vscode-eslint/pull/1882/files

Here is the diff to see what settings changed:

@@ -2,7 +2,7 @@
    "name": "vscode-eslint",
    "displayName": "ESLint",
    "description": "Integrates ESLint JavaScript into VS Code.",
-   "version": "2.3.3",
+   "version": "3.0.10",
    "author": "Microsoft Corporation",
    "license": "MIT",
    "repository": {
@@ -22,7 +22,7 @@
        "multi-root ready"
    ],
    "engines": {
-       "vscode": "^1.68.0"
+       "vscode": "^1.90.0"
    },
    "activationEvents": [
        "onStartupFinished"
@@ -63,7 +63,8 @@
                        "pnpm"
                    ],
                    "default": "npm",
-                   "description": "The package manager you use to install node modules."
+                   "description": "The package manager you use to install node modules.",
+                   "deprecationMessage": "The setting is deprecated. The Package Manager is automatically detected now."
                },
                "eslint.problems.shortenToSingleLine": {
                    "type": "boolean",
@@ -182,11 +183,18 @@
                    "default": false,
                    "description": "Since version 7 ESLint offers a new API call ESLint. Use it even if the old CLIEngine is available. From version 8 on forward on ESLint class is available."
                },
+               "eslint.useFlatConfig": {
+                   "scope": "resource",
+                   "type": "boolean",
+                   "default": null,
+                   "markdownDescription": "Controls whether flat config should be used or not. This setting requires ESLint version 8.57 or later and is interpreted according to the [ESLint Flat Config rollout plan](https://eslint.org/blog/2023/10/flat-config-rollout-plans/). This means:\n\n - *8.57.0 <= ESLint version < 9.x*: setting is honored and defaults to false\n- *9.0.0 <= ESLint version < 10.x*: settings is honored and defaults to true\n- *10.0.0 <= ESLint version*: setting is ignored. Flat configs are the default and can't be turned off."
+               },
                "eslint.experimental.useFlatConfig": {
                    "scope": "resource",
                    "type": "boolean",
                    "default": false,
-                   "description": "Enables support of experimental Flat Config (aka eslint.config.js, supported by ESLint version 8.21 or later)."
+                   "deprecationMessage": "Use ESLint version 8.57 or later and `eslint.useFlatConfig` instead.",
+                   "description": "Enables support of experimental Flat Config (aka eslint.config.js). Requires ESLint version >= 8.21 < 8.57.0)."
                },
                "eslint.workingDirectories": {
                    "scope": "resource",
@@ -304,13 +312,17 @@
                        "type": "string"
                    },
                    "default": [
+                       "astro",
                        "javascript",
                        "javascriptreact",
                        "typescript",
                        "typescriptreact",
                        "html",
+                       "mdx",
                        "vue",
-                       "markdown"
+                       "markdown",
+                       "json",
+                       "jsonc"
                    ],
                    "description": "An array of language ids for which the extension should probe if support is installed."
                },
@@ -499,6 +511,52 @@
                        "scope": "resource",
                        "type": "array",
                        "description": "A special rules customization section for text cells in notebook documents."
+               },
+               "eslint.timeBudget.onValidation": {
+                   "scope": "resource",
+                   "type": "object",
+                   "properties": {
+                       "warn": {
+                           "type": "number",
+                           "default": 4000,
+                           "minimum": 0,
+                           "markdownDescription": "The time budget in milliseconds to spend on validation before showing a warning."
+                       },
+                       "error": {
+                           "type": "number",
+                           "default": 8000,
+                           "minimum": 0,
+                           "markdownDescription": "The time budget in milliseconds to spend on validation before showing an error."
+                       }
+                   },
+                   "default": {
+                       "warn": 4000,
+                       "error": 8000
+                   },
+                   "markdownDescription": "The time budget in milliseconds to spend on validation before showing a warning or error."
+               },
+               "eslint.timeBudget.onFixes": {
+                   "scope": "resource",
+                   "type": "object",
+                   "properties": {
+                       "warn": {
+                           "type": "number",
+                           "default": 3000,
+                           "minimum": 0,
+                           "markdownDescription": "The time budget in milliseconds to spend on computing fixes before showing a warning."
+                       },
+                       "error": {
+                           "type": "number",
+                           "default": 6000,
+                           "minimum": 0,
+                           "markdownDescription": "The time budget in milliseconds to spend on computing fixes before showing an error."
+                       }
+                   },
+                   "default": {
+                       "warn": 3000,
+                       "error": 6000
+                   },
+                   "markdownDescription": "The time budget in milliseconds to spend on computing fixes before showing a warning or error."
                }
            }
        },
@@ -527,6 +585,11 @@
                "title": "Restart ESLint Server",
                "category": "ESLint",
                "command": "eslint.restart"
+           },
+           {
+               "title": "Revalidate all open files",
+               "category": "ESLint",
+               "command": "eslint.revalidate"
            }
        ],
        "taskDefinitions": [
@@ -578,18 +641,18 @@
        "symlink:lsp": "node ./build/bin/symlink.js"
    },
    "devDependencies": {
-       "@types/mocha": "^9.1.1",
-       "@types/node": "^16.11.33",
-       "@typescript-eslint/eslint-plugin": "^5.32.0",
-       "@typescript-eslint/parser": "^5.32.0",
-       "eslint": "^8.21.0",
+       "@types/mocha": "^10.0.6",
+       "@types/node": "^18.14.6",
+       "@typescript-eslint/eslint-plugin": "^7.1.1",
+       "@typescript-eslint/parser": "^7.1.1",
+       "eslint": "^8.57.0",
        "merge-options": "^3.0.4",
-       "mocha": "^10.0.0",
-       "rimraf": "^3.0.2",
-       "ts-loader": "^9.3.1",
-       "typescript": "^4.7.4",
-       "webpack": "^5.74.0",
-       "webpack-cli": "^4.10.0",
+       "mocha": "^10.3.0",
+       "rimraf": "^5.0.5",
+       "ts-loader": "^9.5.1",
+       "typescript": "^5.3.3",
+       "webpack": "^5.90.3",
+       "webpack-cli": "^5.1.4",
        "shelljs": "^0.8.5"
    }
 }
predragnikolic commented 4 weeks ago

PR is open https://github.com/sublimelsp/LSP-eslint/pull/72

Till now I've used the eslint v8.57.0 with"experimental.useFlatConfig": true and it worked ok. And maybe it makes more sense to use v8.57.0 with "experimental.useFlatConfig": true, till the bellow thing is resolved.

The thing is the ESLint ecosystem didn't catch up yet. So packages doesn't have stable npm releases which support ESLint v9, or don't have v9 support at all.

If people want to use v9 now, they would have to install canary releases... and things like that. Which is ok if you are ok with that.

"eslint-plugin-react-hooks": "5.1.0-rc-3563387fe3-20240621",
"typescript-eslint": "8.0.0-alpha.30"

Some packages don't support v9 like "eslint-plugin-react", there is an issue for that.


So there is that. To wrap up LSP-eslint will be able to support flat config by default for ESLint v9 and above, after the PR is merged.