question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: ESLint API cannot find eslint-recommended.js

See original GitHub issue

Environment

Node version: v16.10.0 npm version: 7.24.0 Local ESLint version: 8.8.0 Global ESLint version: N/A Operating System: macOS Big Sur

What parser are you using?

Default (Espree)

What did you do?

To reproduce the issue:

  • git clone https://github.com/daidodo/eslint-api-issue.git
  • cd eslint-api-issue && npm i && npx webpack
  • node dist/main.js src/index.ts

What did you expect to happen?

I expect the output is the ESLint resolved config for the given file. If you run npx tsc && node dist/main.js src/index.ts, you can get:

ESLint version: 8.8.0
eslint object: ESLint {}
Resolving ESLint config:
{
  env: {},
  globals: {},
  noInlineConfig: undefined,
  parser: null,
  parserOptions: {},
  plugins: [],
  reportUnusedDisableDirectives: undefined,
  rules: {
    'no-unused-vars': [ 'warn', [Object] ],
    'constructor-super': [ 'error' ],
    'for-direction': [ 'error' ],
    'getter-return': [ 'error' ],
    'no-async-promise-executor': [ 'error' ],
    'no-case-declarations': [ 'error' ],
    'no-class-assign': [ 'error' ],
    'no-compare-neg-zero': [ 'error' ],
    'no-cond-assign': [ 'error' ],
    'no-const-assign': [ 'error' ],
    'no-constant-condition': [ 'error' ],
    'no-control-regex': [ 'error' ],
    'no-debugger': [ 'error' ],
    'no-delete-var': [ 'error' ],
    'no-dupe-args': [ 'error' ],
    'no-dupe-class-members': [ 'error' ],
    'no-dupe-else-if': [ 'error' ],
    'no-dupe-keys': [ 'error' ],
    'no-duplicate-case': [ 'error' ],
    'no-empty': [ 'error' ],
    'no-empty-character-class': [ 'error' ],
    'no-empty-pattern': [ 'error' ],
    'no-ex-assign': [ 'error' ],
    'no-extra-boolean-cast': [ 'error' ],
    'no-extra-semi': [ 'error' ],
    'no-fallthrough': [ 'error' ],
    'no-func-assign': [ 'error' ],
    'no-global-assign': [ 'error' ],
    'no-import-assign': [ 'error' ],
    'no-inner-declarations': [ 'error' ],
    'no-invalid-regexp': [ 'error' ],
    'no-irregular-whitespace': [ 'error' ],
    'no-loss-of-precision': [ 'error' ],
    'no-misleading-character-class': [ 'error' ],
    'no-mixed-spaces-and-tabs': [ 'error' ],
    'no-new-symbol': [ 'error' ],
    'no-nonoctal-decimal-escape': [ 'error' ],
    'no-obj-calls': [ 'error' ],
    'no-octal': [ 'error' ],
    'no-prototype-builtins': [ 'error' ],
    'no-redeclare': [ 'error' ],
    'no-regex-spaces': [ 'error' ],
    'no-self-assign': [ 'error' ],
    'no-setter-return': [ 'error' ],
    'no-shadow-restricted-names': [ 'error' ],
    'no-sparse-arrays': [ 'error' ],
    'no-this-before-super': [ 'error' ],
    'no-undef': [ 'error' ],
    'no-unexpected-multiline': [ 'error' ],
    'no-unreachable': [ 'error' ],
    'no-unsafe-finally': [ 'error' ],
    'no-unsafe-negation': [ 'error' ],
    'no-unsafe-optional-chaining': [ 'error' ],
    'no-unused-labels': [ 'error' ],
    'no-useless-backreference': [ 'error' ],
    'no-useless-catch': [ 'error' ],
    'no-useless-escape': [ 'error' ],
    'no-with': [ 'error' ],
    'require-yield': [ 'error' ],
    'use-isnan': [ 'error' ],
    'valid-typeof': [ 'error' ]
  },
  settings: {},
  ignorePatterns: [ '**/xxx.js' ]
}

What actually happened?

If webpacked, the output would be:

ESLint version: 8.8.0
eslint object: ESLint {}

Error: Cannot read config file: /Users/xxx/Desktop/private/projects/conf/eslint-recommended.js
Error: Cannot find module '/Users/xxx/Desktop/private/projects/conf/eslint-recommended.js'
Require stack:
- /Users/xxx/Desktop/private/projects/eslint-api-issue/dist/noop.js
Referenced from: /Users/xxx/Desktop/private/projects/eslint-api-issue/package.json

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

I’ve submitted a similar issue (https://github.com/eslint/eslint/issues/13974) but got aged. My guess is the __dirname in lib/cli-engine/cli-engine.js causes the issue. But I don’t have enough context to confirm or fix it.

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Feb 25, 2022

Reopening as this isn’t fixed until https://github.com/eslint/eslint/pull/15616 gets merged.

0reactions
nzakascommented, Feb 10, 2022

I don’t know. Why don’t you try it and see what happens?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLint couldn't find the plugin "eslint-plugin-@typescript-eslint"
Solution was simply to upgrade to the latest version of eslint.
Read more >
eslint/eslint - Gitter
I am having an issue with ESLint while deploying my react app to Heroku. I am getting this error "Oops! Something went wrong!...
Read more >
Find and fix problems in your JavaScript code - ESLint ...
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
WEB-53184 - YouTrack
eslintrc.json': Cannot find module '@typescript-eslint/eslint-plugin' ... Gets the attached ESLint Error line top of the Editor and the ESLint doesn't work.
Read more >
[eslint] failed to load plugin 'prettier' declared in '.eslintrc.js'
[Error] Failed to load plugin 'prettier' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-prettier' Require stack ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found