eslint / create-config

Utility to create ESLint config files
MIT License
76 stars 19 forks source link

Eslint init create-config creates a config that does not work with VSCode extension #107

Closed grentank closed 6 months ago

grentank commented 6 months ago

Steps to reproduce:

  1. Open an empty project
  2. Create package.json file with npm init -y
  3. Configure eslint: npm init @eslint/config@latest
  4. Select:
    • style
    • commonjs
    • none
    • javascript
    • node
    • airbnb
    • Yes
    • npm

This package creates a config eslint.config.mjs. Here are some problems:

  1. Eslint server (VSCode extension) returns an error:
    No ESLint configuration (e.g .eslintrc) found for file: /home/grentank/elbrus/temp/temp/eslint.config.mjs
    File will not be validated. Consider running 'eslint --init' in the workspace folder temp
    Alternatively you can disable ESLint by executing the 'Disable ESLint' command.

    The extension does not lint, nor higlight, nor fix .js files

  2. The option "eslint.experimental.useFlatConfig": true, in settings.json does help, but is it still experimental?
  3. It is impossible to load new configs/plugins in this file. For example, prettier:
    • npm i -D eslint-config-prettier
    • add to compat.extends("airbnb-base", 'prettier'), and the new config does not work. Eslint still higlights formatting rules even after restarting eslint server
    • I dont know how to add plugins or configs in this file. There are no guides on how to apply custom rules to this config. There is no information on how to apply configs or plugins

Please, provide some info on how to use this new eslint config.

nzakas commented 6 months ago

For the time being, you'll need to still set `eslint.experimental.useFlatConfig": true' to enable the config file in VS Code. There is a prerelease version that will auto-detect flat config: https://github.com/microsoft/vscode-eslint/issues/1644

We have a lot of documentation about how to use the new config system, start here: https://eslint.org/docs/latest/use/configure/migration-guide

There's also this: https://eslint.org/docs/latest/use/configure/

Note: We do not maintain the VS Code ESLint plugin. For further help, you'll need to work with them: https://github.com/microsoft/vscode-eslint/