Repository navigation
Conversation
AKzar1el
left a comment
There was a problem hiding this comment.
Two concrete setup pitfalls in the new ESLint flat-config instructions, noted inline. This is a source/documentation review; I did not run ESLint or the repository's tests.
| 1. Install [Node.js](https://nodejs.org/). | ||
| 2. Install ESLint with the command `npm install -g eslint` (npm is a JavaScript package installer). | ||
| 3. Create a config file named `.eslintrc` in the root of your JavaScript project (in the folder that contains all your files). | ||
| 2. Install ESLint in your project with the command `npm install --save-dev eslint` (npm is a JavaScript package installer). |
There was a problem hiding this comment.
The manual install command only declares eslint, but the sample at lines 322–323 imports @eslint/js and globals. Those should be explicit project dev dependencies rather than depending on how transitive packages happen to be hoisted. Could this step say npm install --save-dev eslint @eslint/js globals (and mention npm init -y first if there is no package.json)? ESLint's manual setup explicitly installs @eslint/js. The npm init @eslint/config@latest generator is an alternative path, but readers copying the manual example otherwise lack the declared dependencies.
| 4. Install/enable the plugin for your editor that integrates with ESLint. The majority of editors have one. | ||
|
|
||
| Here's an example of an `.eslintrc` file: | ||
| Here's an example of an `eslint.config.js` file: |
There was a problem hiding this comment.
The example uses ESM import/export in eslint.config.js. That file will not parse as an ES module in an existing project with "type": "commonjs" in package.json. Could the tutorial use eslint.config.mjs for the ESM example, or explain that eslint.config.js needs an ESM project (and that CommonJS projects can use require/module.exports)? ESLint documents this distinction in Configuration Files.
The "Code style" chapter tells the reader to create an
.eslintrcfile. That format is no longer the way ESLint is configured: flat config (eslint.config.js) has been the default since ESLint 9, and.eslintrcsupport was removed in ESLint 10, so following the chapter today leaves beginners with a config that ESLint ignores.This updates that part of the section:
npm install --save-dev eslint) instead of globally, and mentionnpm init @eslint/config@latest, which generates the config;.eslintrcexample with an equivalenteslint.config.jsone (same idea: start from the recommended rules, declare browser/node globals, then override a couple of rules);docs/user-guide/getting-startedURL now redirects).The wording and the structure of the section are otherwise untouched.
Reported for the Russian translation in javascript-tutorial/ru.javascript.info#2187; fixing it here first so the change is not overwritten by the next upstream sync.