Mayil-AI-Sandbox / eslint-v911

Clone of eslint v9.1.1 for debugging
MIT License
0 stars 0 forks source link

Bug: An error occurs when invoking ESLint#lintFiles() in Jest #6

Open NobleMathews opened 1 month ago

NobleMathews commented 1 month ago

Environment

Node version: 20.12.2 npm version: 10.5.0 Local ESLint version: 9.1.1 Global ESLint version: 9.1.1 Operating System: macOS

What parser are you using?

Default (Espree)

What did you do?

Configuration ``` 'use strict' module.exports = [ { languageOptions: { parserOptions: { ecmaVersion: 'latest', }, }, ignores: [ '**/node_modules/**', ], rules: { indent: ['error', 2], quotes: ['error', 'single'], semi: ['error', 'never'], }, }, ] ```
'use strict'

const {
  ESLint,
} = require('eslint')

describe('ESLint Bug', () => {
  test('should not throw an error', async () => {
    const eslint = new ESLint()
    const filePaths = [
      'tests/resources',
    ]
    const expectedLength = 3

    const results = await eslint.lintFiles(filePaths)

    expect(results)
      .toHaveLength(expectedLength)
  })
})

tests/resources/indent.js

'use strict'

module.exports = function doubleValue ( value, ignore ) { if (ignore) { return value }

return value + value } tests/resources/quotes.js

'use strict'

module.exports = "quotes" tests/resources/semi.js

'use strict'

global.semi = 111;

What did you expect to happen?

I expect that Jest shows the log below

PASS tests/tests/eslint-bug.js ESLint Bug ✓ should not throw an error (121 ms)

Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 1.221 s, estimated 2 s Ran all test suites.

What actually happened?

An error Result is not a promise. is thrown.

FAIL tests/tests/eslint-bug.js ESLint Bug ✕ should not throw an error (105 ms)

● ESLint Bug › should not throw an error

Result is not a promise.

  13 |     const expectedLength = 3
  14 |
> 15 |     const results = await eslint.lintFiles(filePaths)
     |                     ^
  16 |
  17 |     expect(results)
  18 |       .toHaveLength(expectedLength)

  at Retrier.retry (node_modules/@humanwhocodes/retry/dist/retrier.cjs:200:35)
      at Array.map (<anonymous>)
  at Object.<anonymous> (tests/__tests__/eslint-bug.js:15:21)

Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: 1.195 s Ran all test suites.

Link to Minimal Reproducible Example

-

Participation

Additional comments

No response

mayil-ai[bot] commented 1 month ago

Doesn't seem like we have fully grasped all the specifics of this ticket. But here are some ideas that might help you get started:

To address the error "Result is not a promise." when invoking ESLint#lintFiles() within a Jest test, perform the following actions:

Code snippets to check