Skip to content

Improve ESLint and Babel help messages, when enabling ESLint integration #1284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

Kocal
Copy link
Member

@Kocal Kocal commented Aug 22, 2024

While working on ESLint deprecation (requiring me to have a valid setup, etc...), those messages are displayed when you try to enable ESLint integration:

➜  sf-webpack-encore-lab git:(main) ✗ pnpm dev

> @ dev /Users/kocal/workspace/sf-webpack-encore-lab
> encore dev

Running webpack ...

 DEPRECATION  The ESLint integration is now deprecated and will be removed in the next major release. Please use the standalone ESLint CLI instead, or use the ESLint Webpack plugin directly.
  Error: No ESLint configuration has been found.

   FIX  Run command ./node_modules/.bin/eslint --init or manually create a .eslintrc.js file at   the root of your project.

  If you prefer to create a .eslintrc.js file by yourself, here is an example to get you started:

  // .eslintrc.js
  module.exports = {
      parser: '@babel/eslint-parser',
      extends: ['eslint:recommended'],
  }


  Install @babel/eslint-parser to prevent potential parsing issues: yarn add @babel/eslint-parser --dev


  You will also need to specify your Babel config in a separate file. The current
  configuration Encore has been adding for your is:

  // babel.config.js
  module.exports = {
      "sourceType": "unambiguous",
      "presets": [
          [
              "/Users/kocal/workspace/sf-webpack-encore-lab/node_modules/.pnpm/@babel+preset-env@7.25.3_@babel+core@7.25.2/node_mo  dules/@babel/preset-env/lib/index.js",
              {
                  "modules": false,
                  "targets": {},
                  "useBuiltIns": false,
                  "corejs": null
              }
          ]
      ],
      "plugins": []
  }

  Additionally, remove the .configureBabel() in webpack.config.js: this will no longer be used.
  And remove the .configureBabelPresetEnv() in webpack.config.js: this will no longer be used.

There are many errors in those messages:

  1. The option root: true is missing for ESLint
  2. I expect to see require.resolve("@babel/preset-env") instead of "/Users/kocal/workspace/sf-webpack-encore-lab/node_modules/.pnpm/@babel+preset-env@7.25.3_@babel+core@7.25.2/node_mo dules/@babel/preset-env/lib/index.js" for Babel.
  3. I expect the corejs option to be set to the current version of core-js (if exists)

With this PR, the output is now:

> encore dev

Running webpack ...

 DEPRECATION  The ESLint integration is now deprecated and will be removed in the next major release. Please use the standalone ESLint CLI instead, or use the ESLint Webpack plugin directly.
  Error: No ESLint configuration has been found.

   FIX  Run command ./node_modules/.bin/eslint --init or manually create a .eslintrc.js file at   the root of your project.

  If you prefer to create a .eslintrc.js file by yourself, here is an example to get you started:

  // .eslintrc.js
  module.exports = {
      root: true,
      parser: '@babel/eslint-parser',
      extends: ['eslint:recommended'],
  }


  Install @babel/eslint-parser to prevent potential parsing issues: yarn add @babel/eslint-parser --dev


  You will also need to specify your Babel config in a separate file. The current
  configuration Encore has been adding for your is:

  // babel.config.js
  module.exports = {
      "sourceType": "unambiguous",
      "presets": [
          [
              require.resolve("@babel/preset-env"),
              {
                  "modules": false,
                  "useBuiltIns": false,
                  "corejs": "3.38.1"
              }
          ]
      ],
      "plugins": []
  }

@Kocal Kocal force-pushed the imp/eslint-config-help branch from e3ed9fc to e6b4648 Compare August 22, 2024 06:53
@Kocal Kocal merged commit 30dc220 into symfony:main Aug 22, 2024
28 checks passed
@Kocal Kocal deleted the imp/eslint-config-help branch August 22, 2024 07:01
@Kocal Kocal modified the milestones: 5.0, 4.17 Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant