From 0237ef80bde34d1a454fc194a4030686fbac609a Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 6 Nov 2024 13:31:01 +0000 Subject: [PATCH] DEV: Enable `ember/no-classic-classes` eslint rule (#28610) --- .eslintrc.cjs | 6 +++++- .../javascripts/discourse/tests/unit/lib/computed-test.js | 7 +++++++ .../discourse/tests/unit/utils/decorators-test.js | 7 +++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index be1a9f3f46c..a0e0cc1663c 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1 +1,5 @@ -module.exports = require("@discourse/lint-configs/eslint"); +const config = require("@discourse/lint-configs/eslint"); + +config.rules["ember/no-classic-classes"] = "error"; + +module.exports = config; diff --git a/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js b/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js index bf98055b8fa..a84dde8ee02 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js @@ -31,6 +31,7 @@ module("Unit | Utility | computed", function (hooks) { test("setting", function (assert) { const siteSettings = getOwner(this).lookup("service:site-settings"); + // eslint-disable-next-line ember/no-classic-classes let t = EmberObject.extend({ siteSettings, vehicle: setting("vehicle"), @@ -50,6 +51,7 @@ module("Unit | Utility | computed", function (hooks) { }); test("propertyEqual", function (assert) { + // eslint-disable-next-line ember/no-classic-classes let t = EmberObject.extend({ same: propertyEqual("cookies", "biscuits"), }).create({ @@ -63,6 +65,7 @@ module("Unit | Utility | computed", function (hooks) { }); test("propertyNotEqual", function (assert) { + // eslint-disable-next-line ember/no-classic-classes let t = EmberObject.extend({ diff: propertyNotEqual("cookies", "biscuits"), }).create({ @@ -76,6 +79,7 @@ module("Unit | Utility | computed", function (hooks) { }); test("fmt", function (assert) { + // eslint-disable-next-line ember/no-classic-classes let t = EmberObject.extend({ exclaimyUsername: fmt("username", "!!! %@ !!!"), multiple: fmt("username", "mood", "%@ is %@"), @@ -110,6 +114,7 @@ module("Unit | Utility | computed", function (hooks) { }); test("i18n", function (assert) { + // eslint-disable-next-line ember/no-classic-classes let t = EmberObject.extend({ exclaimyUsername: i18n("username", "!!! %@ !!!"), multiple: i18n("username", "mood", "%@ is %@"), @@ -146,6 +151,7 @@ module("Unit | Utility | computed", function (hooks) { test("url", function (assert) { let t, testClass; + // eslint-disable-next-line ember/no-classic-classes testClass = EmberObject.extend({ userUrl: url("username", "/u/%@"), }); @@ -168,6 +174,7 @@ module("Unit | Utility | computed", function (hooks) { test("htmlSafe", function (assert) { const cookies = "

cookies and biscuits

"; + // eslint-disable-next-line ember/no-classic-classes const t = EmberObject.extend({ desc: htmlSafe("cookies"), }).create({ cookies }); diff --git a/app/assets/javascripts/discourse/tests/unit/utils/decorators-test.js b/app/assets/javascripts/discourse/tests/unit/utils/decorators-test.js index 8d9d6c19565..b227eb34354 100644 --- a/app/assets/javascripts/discourse/tests/unit/utils/decorators-test.js +++ b/app/assets/javascripts/discourse/tests/unit/utils/decorators-test.js @@ -1,5 +1,3 @@ -// eslint-disable ember/no-classic-classes - import Component from "@ember/component"; import EmberObject from "@ember/object"; import { clearRender, render, settled } from "@ember/test-helpers"; @@ -16,6 +14,7 @@ import discourseComputed, { on, } from "discourse-common/utils/decorators"; +// eslint-disable-next-line ember/no-classic-classes const fooComponent = Component.extend({ classNames: ["foo-component"], @@ -39,6 +38,7 @@ const fooComponent = Component.extend({ }, }); +// eslint-disable-next-line ember/no-classic-classes const EmberObjectComponent = Component.extend({ name: "", layout: hbs`{{this.text}}`, @@ -59,6 +59,7 @@ class NativeComponent extends Component { } } +// eslint-disable-next-line ember/no-classic-classes const TestStub = EmberObject.extend({ counter: 0, otherCounter: 0, @@ -228,6 +229,7 @@ module("Unit | Utils | decorators", function (hooks) { }; }); + // eslint-disable-next-line ember/no-classic-classes const ExtendWithObserver = EmberObject.extend({ counter: 0, @observes("value") @@ -267,6 +269,7 @@ module("Unit | Utils | decorators", function (hooks) { }; }); + // eslint-disable-next-line ember/no-classic-classes const ExtendWithOn = EmberObject.extend({ counter: 0, @on("init")