eslint
eslint copied to clipboard
Bug: Configuration that throws an error with an immutable message will crash ESLint with useless error
Environment
Node version: 14.19.3 npm version: 8.15.0 Local ESLint version: 8.22.0 Global ESLint version: N/A Operating System: Manjaro
What parser are you using?
Default (Espree)
What did you do?
Configuration
class TestError extends Error {
get message () {
return `TestError: message`
}
}
throw new TestError()
No linted code necessary
What did you expect to happen?
ESLint to "crash out" with the TestError's message: TestError: message
What actually happened?
ESLint triggered an unexpected TypeError: Cannot set property message of Error which has only a getter
Participation
- [ ] I am willing to submit a pull request for this issue.
Additional comments
No response
Can you create a reproduction case?
ESLint doesn’t execute your code, and the error you’re getting is a runtime error.
The config code is the reproduction case, it doesn't require any actual code to lint. The .eslintrc.js
file is itself throwing an error on purpose.
The issue is; if the error thrown from the config file has an immutable/read-only message property, ESLint causes an new runtime error and swallow the more relevant error thrown by the config file. In this case, the TestError is completely lost and the user is shown the message and stack trace of the irrelevant runtime error.
Hope this helps.
Oh I see, thanks for explaining. We will take a look.
@6XGate This seems to be fixed in the new configuration system. I'm not sure if we would want to fix it in the current config system.
@nzakas WDYT?
Old config

New Config

@snitin315 thanks for looking into this! As long as it's fixed in the new config system, then I think we are all set and don't need to worry about it for the old config system. @mdjermanovic do you agree?
I agree as the eslintrc config system is frozen and this doesn't seem like a critical problem.