-
-
Notifications
You must be signed in to change notification settings - Fork 420
Open
Labels
Description
Description
When Error subclass has a message getter, can't call super('message')
new (class MyError extends Error {
get message() {return 'message getter'}
constructor() {
super('message to super')
}
})()
MyError: message to super
at <anonymous>:1:1
Realword case https://github.com/sindresorhus/parse-json/blob/6fee59751db59a539fdf53537101a1d7c6378a65/index.js#L23-L25
Spec link https://262.ecma-international.org/14.0/#sec-error-message
Examples
// ❌
class MyError extends Error {
#message
constructor(message) {
super(message)
this.#message = message;
}
get message() {
return `somthing else ${this.#message}`
}
}
// ✅
class MyError extends Error {
#message
constructor(message) {
super()
this.#message = message;
}
get message() {
return `somthing else ${this.#message}`
}
}Proposed rule name
no-error-super-message
Additional Info
No response