Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Update linting config #185

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/eslint");
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/prettier");
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
inherit_gem:
rubocop-discourse: stree-compat.yml

RSpec/NamedSubject:
Enabled: false
2 changes: 1 addition & 1 deletion .streerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
--print-width=100
--plugins=plugin/trailing_comma
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary
5 changes: 1 addition & 4 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
module.exports = {
plugins: ["ember-template-lint-plugin-discourse"],
extends: "discourse:recommended",
};
module.exports = require("@discourse/lint-configs/template-lint");
49 changes: 30 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,53 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
json (2.6.2)
parallel (1.22.1)
parser (3.1.2.1)
json (2.6.3)
language_server-protocol (3.17.0.3)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
prettier_print (1.2.0)
racc
prettier_print (1.2.1)
racc (1.7.3)
rainbow (3.1.1)
regexp_parser (2.6.0)
rexml (3.2.5)
rubocop (1.36.0)
regexp_parser (2.8.2)
rexml (3.2.6)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
rubocop-discourse (3.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-discourse (3.4.0)
rubocop (>= 1.1.0)
rubocop-rspec (>= 2.0.0)
rubocop-rspec (2.13.2)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
ruby-progressbar (1.11.0)
syntax_tree (5.1.0)
rubocop-rspec (2.25.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
unicode-display_width (2.3.0)
unicode-display_width (2.5.0)

PLATFORMS
ruby
arm64-darwin-21
x86_64-linux

DEPENDENCIES
rubocop-discourse
syntax_tree

BUNDLED WITH
2.1.4
2.4.21
2 changes: 1 addition & 1 deletion assets/javascripts/discourse/components/ad-component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from "@ember/component";
import { inject as service } from "@ember/service";
import { alias, or } from "@ember/object/computed";
import { inject as service } from "@ember/service";
import discourseComputed from "discourse-common/utils/decorators";
import {
isNthPost,
Expand Down
4 changes: 2 additions & 2 deletions assets/javascripts/discourse/components/ad-slot.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EmberObject from "@ember/object";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { isBlank } from "@ember/utils";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import {
isNthPost,
isNthTopicListItem,
Expand Down
8 changes: 4 additions & 4 deletions assets/javascripts/discourse/components/adbutler-ad.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import loadScript from "discourse/lib/load-script";
import RSVP from "rsvp";
import { scheduleOnce } from "@ember/runloop";
import RSVP from "rsvp";
import loadScript from "discourse/lib/load-script";
import { isTesting } from "discourse-common/config/environment";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";

let _loaded = false,
_promise = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed from "discourse-common/utils/decorators";
import { and } from "@ember/object/computed";
import { htmlSafe } from "@ember/template";
import discourseComputed from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";

export default AdComponent.extend({
classNames: ["amazon-product-links"],
Expand Down
4 changes: 2 additions & 2 deletions assets/javascripts/discourse/components/carbonads-ad.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed from "discourse-common/utils/decorators";
import { htmlSafe } from "@ember/template";
import discourseComputed from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";

export default AdComponent.extend({
serve_id: null,
Expand Down
10 changes: 5 additions & 5 deletions assets/javascripts/discourse/components/google-adsense.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import loadScript from "discourse/lib/load-script";
import RSVP from "rsvp";
import { scheduleOnce } from "@ember/runloop";
import { isTesting } from "discourse-common/config/environment";
import { htmlSafe } from "@ember/template";
import RSVP from "rsvp";
import loadScript from "discourse/lib/load-script";
import { isTesting } from "discourse-common/config/environment";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";

let _loaded = false,
_promise = null,
Expand Down
8 changes: 4 additions & 4 deletions assets/javascripts/discourse/components/google-dfp-ad.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { on } from "discourse-common/utils/decorators";
import loadScript from "discourse/lib/load-script";
import { alias } from "@ember/object/computed";
import { htmlSafe } from "@ember/template";
import RSVP from "rsvp";
import loadScript from "discourse/lib/load-script";
import { isTesting } from "discourse-common/config/environment";
import { htmlSafe } from "@ember/template";
import discourseComputed, { on } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";

let _loaded = false,
_promise = null,
Expand Down
4 changes: 2 additions & 2 deletions assets/javascripts/discourse/components/house-ad.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { isBlank } from "@ember/utils";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";

const adIndex = {
topic_list_top: null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MultiSelectComponent from "select-kit/components/multi-select";
import Ember from "ember";
import MultiSelectComponent from "select-kit/components/multi-select";
const { makeArray } = Ember;
import { computed } from "@ember/object";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
import { mapBy } from "@ember/object/computed";
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";

export default HouseAdsSetting.extend({
classNames: "house-ads-setting house-ads-list-setting",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import I18n from "I18n";
import Controller, { inject as controller } from "@ember/controller";
import { not, or } from "@ember/object/computed";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { propertyNotEqual } from "discourse/lib/computed";
import { bufferedProperty } from "discourse/mixins/buffered-content";
import Controller, { inject as controller } from "@ember/controller";
import { not, or } from "@ember/object/computed";
import I18n from "I18n";

export default Controller.extend(bufferedProperty("model"), {
adminPluginsHouseAds: controller("adminPlugins.houseAds"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DiscourseRoute from "discourse/routes/discourse";
import { action } from "@ember/object";
import DiscourseRoute from "discourse/routes/discourse";

export default DiscourseRoute.extend({
@action
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DiscourseRoute from "discourse/routes/discourse";
import EmberObject from "@ember/object";
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";

export default DiscourseRoute.extend({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import DiscourseRoute from "discourse/routes/discourse";
import EmberObject from "@ember/object";

export default DiscourseRoute.extend({
settings: null,
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"author": "Discourse",
"license": "MIT",
"devDependencies": {
"eslint-config-discourse": "^2.0.0"
"@discourse/lint-configs": "^1.0.0",
"ember-template-lint": "^5.11.2",
"eslint": "^8.52.0",
"prettier": "^2.8.8"
}
}
76 changes: 30 additions & 46 deletions test/javascripts/acceptance/adsense-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import groupFixtures from "discourse/tests/fixtures/group-fixtures";
import {
acceptance,
updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import groupFixtures from "discourse/tests/fixtures/group-fixtures";
import { visit } from "@ember/test-helpers";

acceptance("AdSense", function (needs) {
needs.user();
Expand Down Expand Up @@ -42,45 +42,33 @@ acceptance("AdSense", function (needs) {
updateCurrentUser({ staff: false, trust_level: 1 });
await visit("/t/280"); // 20 posts

assert.equal(
find(".google-adsense.adsense-topic-above-post-stream").length,
1,
"it should render 1 ad"
);
assert
.dom(".google-adsense.adsense-topic-above-post-stream")
.exists({ count: 1 }, "it should render 1 ad above post stream");

assert
.dom(".google-adsense.adsense-post-bottom")
.exists({ count: 3 }, "it should render 3 ads");

assert
.dom("#post_6 + .widget-connector .google-adsense.adsense-post-bottom")
.exists({ count: 1 }, "ad after 6th post");

assert
.dom("#post_12 + .widget-connector .google-adsense.adsense-post-bottom")
.exists({ count: 1 }, "ad after 12th post");

const ads = find(".google-adsense.adsense-post-bottom");
assert.equal(ads.length, 3, "it should render 3 ads");
assert.equal(
find("#post_6 + .widget-connector").find(
".google-adsense.adsense-post-bottom"
).length,
1,
"ad after 6th post"
);
assert.equal(
find("#post_12 + .widget-connector").find(
".google-adsense.adsense-post-bottom"
).length,
1,
"ad after 12th post"
);
assert.equal(
find("#post_18 + .widget-connector").find(
".google-adsense.adsense-post-bottom"
).length,
1,
"ad after 18th post"
);
assert
.dom("#post_18 + .widget-connector .google-adsense.adsense-post-bottom")
.exists({ count: 1 }, "ad after 18th post");
});

test("no ads for trust level 3", async (assert) => {
updateCurrentUser({ staff: false, trust_level: 3 });
await visit("/t/280");
assert.equal(
find(".google-adsense.adsense-post-bottom").length,
0,
"it should render 0 ads"
);
assert
.dom(".google-adsense.adsense-post-bottom")
.doesNotExist("it should render 0 ads");
});

test("can omit ads based on groups", async (assert) => {
Expand All @@ -90,20 +78,16 @@ acceptance("AdSense", function (needs) {
groups: [groupFixtures["/groups/discourse.json"].group],
});
await visit("/t/280");
assert.equal(
find(".google-adsense.adsense-post-bottom").length,
0,
"it should render 0 ads"
);
assert
.dom(".google-adsense.adsense-post-bottom")
.doesNotExist("it should render 0 ads");
});

test("can omit ads based on category", async (assert) => {
updateCurrentUser({ staff: false, trust_level: 1 });
await visit("/t/28830");
assert.equal(
find(".google-adsense.adsense-topic-above-post-stream").length,
0,
"it should render 0 ads"
);
assert
.dom(".google-adsense.adsense-topic-above-post-stream")
.doesNotExist("it should render 0 ads");
});
});
Loading