mirror of
https://github.com/discourse/discourse.git
synced 2025-04-11 07:30:50 +08:00
DEV: Fix ember/no-arrow-function-computed-properties
lint (#29110)
This commit is contained in:
parent
1ba8b6b22a
commit
48c908c04d
@ -22,16 +22,18 @@ export default class PluginConnector extends Component {
|
||||
init() {
|
||||
super.init(...arguments);
|
||||
|
||||
const args = this.args || {};
|
||||
Object.keys(args).forEach((key) => {
|
||||
defineProperty(
|
||||
this,
|
||||
key,
|
||||
computed("args", () => (this.args || {})[key])
|
||||
);
|
||||
});
|
||||
if (this.args) {
|
||||
Object.keys(this.args).forEach((key) => {
|
||||
defineProperty(
|
||||
this,
|
||||
key,
|
||||
computed("args", function () {
|
||||
return this.args[key];
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const deprecatedArgs = this.deprecatedArgs || {};
|
||||
const connectorInfo = {
|
||||
outletName: this.connector?.outletName,
|
||||
connectorName: this.connector?.connectorName,
|
||||
@ -40,18 +42,20 @@ export default class PluginConnector extends Component {
|
||||
layoutName: this.layoutName,
|
||||
};
|
||||
|
||||
Object.keys(deprecatedArgs).forEach((key) => {
|
||||
defineProperty(
|
||||
this,
|
||||
key,
|
||||
computed("deprecatedArgs", () => {
|
||||
return deprecatedArgumentValue(deprecatedArgs[key], {
|
||||
...connectorInfo,
|
||||
argumentName: key,
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
if (this.deprecatedArgs) {
|
||||
Object.keys(this.deprecatedArgs).forEach((key) => {
|
||||
defineProperty(
|
||||
this,
|
||||
key,
|
||||
computed("deprecatedArgs", function () {
|
||||
return deprecatedArgumentValue(this.deprecatedArgs[key], {
|
||||
...connectorInfo,
|
||||
argumentName: key,
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const connectorClass = this.connector.connectorClass;
|
||||
this.set("actions", connectorClass?.actions);
|
||||
@ -63,8 +67,8 @@ export default class PluginConnector extends Component {
|
||||
}
|
||||
|
||||
const merged = buildArgsWithDeprecations(
|
||||
args,
|
||||
deprecatedArgs,
|
||||
this.args,
|
||||
this.deprecatedArgs,
|
||||
connectorInfo
|
||||
);
|
||||
connectorClass?.setupComponent?.call(this, merged, this);
|
||||
|
@ -241,22 +241,26 @@ export function rawConnectorsFor(outletName) {
|
||||
export function buildArgsWithDeprecations(args, deprecatedArgs, opts = {}) {
|
||||
const output = {};
|
||||
|
||||
Object.keys(args).forEach((key) => {
|
||||
Object.defineProperty(output, key, { value: args[key] });
|
||||
});
|
||||
|
||||
Object.keys(deprecatedArgs).forEach((argumentName) => {
|
||||
Object.defineProperty(output, argumentName, {
|
||||
get() {
|
||||
const deprecatedArg = deprecatedArgs[argumentName];
|
||||
|
||||
return deprecatedArgumentValue(deprecatedArg, {
|
||||
...opts,
|
||||
argumentName,
|
||||
});
|
||||
},
|
||||
if (args) {
|
||||
Object.keys(args).forEach((key) => {
|
||||
Object.defineProperty(output, key, { value: args[key] });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (deprecatedArgs) {
|
||||
Object.keys(deprecatedArgs).forEach((argumentName) => {
|
||||
Object.defineProperty(output, argumentName, {
|
||||
get() {
|
||||
const deprecatedArg = deprecatedArgs[argumentName];
|
||||
|
||||
return deprecatedArgumentValue(deprecatedArg, {
|
||||
...opts,
|
||||
argumentName,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user