Open NobleMathews opened 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:
async/await
in your test functions.lintFiles()
method returning a promise. You may need to check the ESLint documentation or the package.json
file to ensure compatibility.console.log
statements before and after the lintFiles()
call to verify the behavior:
console.log('Before lintFiles call');
const result = await eslint.lintFiles(patterns);
console.log('After lintFiles call', result);
lintFiles()
invocation to inspect the returned value and determine why it is not recognized as a promise. This can help identify where the promise is being mishandled.lib/eslint/legacy-eslint.js:530-640 | Contains 'lintFiles' method which may need to be edited to return a promise and resolve the 'Result is not a promise' error.
lib/linter/linter.js:1-69 | Provides context for the main Linter class which could be relevant for understanding the issue with 'lintFiles' method.
lib/eslint/eslint.js:578-578 | Mentions the ESLint class which is instantiated in the issue description, may need review for constructor or initialization issues.
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'], }, }, ] ```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
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