zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.51k stars 3.13k forks source link

Allow custom settings for eslint #17088

Open andy0130tw opened 2 months ago

andy0130tw commented 2 months ago

Check for existing issues

Edit: See also https://github.com/zed-industries/zed/issues/9648.

Describe the feature

Zed's eslint support for TypeScript projects is implemented by adapting the language service powered by vscode-eslint. The docs hint the key lsp.eslint.settings.* for configurating eslint, however, only few key is read. Its configuration, is a hardcoded object with values determined with some heuristics, which is hardly configurable. It can gain much more flexibility if we can supply a set of extra options from Zed's settings.

A use case would be disabling flat config in a nested directory setup where eslint.config.{,c,m}js is present in workspace root. Note that setting a working directory following #9648's suggestion does not work around this issue. This is currently impossible without patching the package Zed has downloaded.

If applicable, add mockups / screenshots to help present your vision of the feature

N/A

qbtf commented 3 weeks ago

I found this ad-hoc patch useful if I want to disable the flat config no matter what:

Edit ~/Library/Application\ Support/Zed/languages/eslint/vscode-eslint-release/2.4.4/vscode-eslint/server/out/eslint.js at line 606:

 resultPromise = connection.workspace.getConfiguration({ scopeUri: uri, section: '' }).then((configuration) => {
   const settings = Object.assign({}, configuration, { silent: false, library: undefined, resolvedGlobalPackageManagerPath: undefined }, { workingDirectory: undefined });
+  settings.experimental.useFlatConfig = false
   if (settings.validate === settings_1.Validate.off) {