mightyiam/eslint-config-love

Bug: npm init @eslint/config with eslint-config-standard-with-typescript generates incorrect setup

OnkelTem opened this issue · 3 comments

Hello. I run npm init @eslint/config to get eslint setup. I go the following path:

$ npm init @eslint/config
✔ How would you like to use ESLint? · style
✔ What type of modules does your project use? · esm
✔ Which framework does your project use? · none
✔ Does your project use TypeScript? · No / Yes
✔ Where does your code run? · browser
✔ How would you like to define a style for your project? · guide
✔ Which style guide do you want to follow? · standard-with-typescript
✔ What format do you want your config file to be in? · JavaScript
Checking peerDependencies of eslint-config-standard-with-typescript@latest
Local ESLint installation not found.
The config that you've selected requires the following dependencies:

eslint-config-standard-with-typescript@latest @typescript-eslint/eslint-plugin@^5.52.0 eslint@^8.0.1 eslint-plugin-import@^2.25.2 eslint-plugin-n@^15.0.0 || ^16.0.0  eslint-plugin-promise@^6.0.0 typescript@*
✔ Would you like to install them now? · No / Yes
✔ Which package manager do you want to use? · npm
Installing eslint-config-standard-with-typescript@latest, @typescript-eslint/eslint-plugin@^5.52.0, eslint@^8.0.1, eslint-plugin-import@^2.25.2, eslint-plugin-n@^15.0.0 || ^16.0.0 , eslint-plugin-promise@^6.0.0, typescript@*

After it finishes, running eslint results to this error:

$ $npx eslint './src/**/*.ts'

Oops! Something went wrong! :(

ESLint: 8.47.0

Error: Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /projects/custom/eslint/tts/src/index.ts
    at getParserServices (/projects/custom/eslint/tts/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:22:15)
    at create (/projects/custom/eslint/tts/node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js:85:81)
    at Object.create (/projects/custom/eslint/tts/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:41:20)
    at createRuleListeners (/projects/custom/eslint/tts/node_modules/eslint/lib/linter/linter.js:870:21)
    at /projects/custom/eslint/tts/node_modules/eslint/lib/linter/linter.js:1040:110
    at Array.forEach (<anonymous>)
    at runRules (/projects/custom/eslint/tts/node_modules/eslint/lib/linter/linter.js:977:34)
    at Linter._verifyWithoutProcessors (/projects/custom/eslint/tts/node_modules/eslint/lib/linter/linter.js:1330:31)
    at Linter._verifyWithConfigArray (/projects/custom/eslint/tts/node_modules/eslint/lib/linter/linter.js:1706:21)
    at Linter.verify (/projects/custom/eslint/tts/node_modules/eslint/lib/linter/linter.js:1412:65)

I'm not really sure what makes this error happen - if it's at the eslint or this plugin side.

Node version: 16.17
npm version: 8.15
Local ESLint version: 8.47
Global ESLint version:
Operating System: Linux Ubuntu 22.04

Sorry for not responding earlier. Although this is not the best error message, this is not a bug in this project. All you need to do is to read this.

Good luck!

@mightyiam Sorry, I don't get it, what precisely from that link should explain the situation? I'm not asking how to fix the config (which is useful anyway, thanks).

Let me restart, please:

I run npm init @eslint/config

Which is the official wizard mentioned in the docs:

image

It is my understanding, that wizards shouldn't end up with the wrong configurations. This is mine btw:

module.exports = {
  env: {
    browser: true,
    es2021: true,
  },
  extends: ['standard-with-typescript', 'plugin:react/recommended'],
  overrides: [
    {
      env: {
        node: true,
      },
      files: ['.eslintrc.{js,cjs}'],
      parserOptions: {
        sourceType: 'script',
      },
    },
  ],
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
  },
  plugins: ['react'],
  rules: {},
};

Maybe I should have created this issue in the main eslint repo. Ok, let me do it.

UPDATE: eslint/create-config#71

Thank you. I will follow that one. There's likely a bunch of different ways in which the configuration created by that wizard could end up unsatisfactory...