Skip to content

Commit

Permalink
DEV: Update linting (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
CvX authored Dec 13, 2023
1 parent 7fc3f46 commit 1017b35
Show file tree
Hide file tree
Showing 13 changed files with 686 additions and 531 deletions.
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");
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,disable_ternary
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary
1 change: 1 addition & 0 deletions .template-lintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/template-lint");
4 changes: 0 additions & 4 deletions .template-lintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ source "https://rubygems.org"
group :development do
gem "rubocop-discourse"
gem "syntax_tree"
gem "syntax_tree-disable_ternary"
end
41 changes: 20 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,55 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
base64 (0.1.1)
json (2.6.3)
json (2.7.1)
language_server-protocol (3.17.0.3)
parallel (1.23.0)
parser (3.2.2.3)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
racc (1.7.1)
racc (1.7.3)
rainbow (3.1.1)
regexp_parser (2.8.1)
regexp_parser (2.8.3)
rexml (3.2.6)
rubocop (1.56.3)
base64 (~> 0.1.1)
rubocop (1.59.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
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.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-discourse (3.3.0)
rubocop (>= 1.1.0)
rubocop-rspec (>= 2.0.0)
rubocop-factory_bot (2.23.1)
rubocop (~> 1.33)
rubocop-rspec (2.23.0)
rubocop-discourse (3.5.0)
rubocop (>= 1.59.0)
rubocop-rspec (>= 2.25.0)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
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.1.1)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
syntax_tree-disable_ternary (1.0.0)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)

PLATFORMS
arm64-darwin-20
arm64-darwin-22
ruby
x86_64-linux

DEPENDENCIES
rubocop-discourse
syntax_tree
syntax_tree-disable_ternary

BUNDLED WITH
2.1.4
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { withPluginApi } from "discourse/lib/plugin-api";
import DiscourseURL from "discourse/lib/url";
import I18n from "I18n";
import { Promise } from "rsvp";
import { h } from "virtual-dom";
import loadScript from "discourse/lib/load-script";
import { Promise } from "rsvp";
import { withPluginApi } from "discourse/lib/plugin-api";
import DiscourseURL from "discourse/lib/url";
import { isDevelopment } from "discourse-common/config/environment";
import I18n from "I18n";

function initializeAutocomplete(options) {
const algoliasearch = window.algoliasearch;
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": "^4.0.0"
"@discourse/lint-configs": "^1.3.1",
"ember-template-lint": "^5.13.0",
"eslint": "^8.55.0",
"prettier": "^2.8.8"
}
}
56 changes: 27 additions & 29 deletions test/javascripts/acceptance/algolia-search-test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import {
acceptance,
exists,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, fillIn, visit, waitFor } from "@ember/test-helpers";
import { test } from "qunit";
import { click, currentURL, fillIn, settled, visit } from "@ember/test-helpers";
import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";

acceptance("Discourse Algolia - Search", function (needs) {
Expand All @@ -17,6 +12,7 @@ acceptance("Discourse Algolia - Search", function (needs) {
algolia_search_api_key: "key",
algolia_admin_api_key: "adminkey",
});

needs.site({ can_tag_topics: true });

needs.pretender((server, helper) => {
Expand Down Expand Up @@ -180,17 +176,17 @@ acceptance("Discourse Algolia - Search", function (needs) {
}),
]);
});

test("search posts, users and tags", async function (assert) {
await visit("/");

await fillIn(".aa-Input", "internationalization");
await settled();
await waitFor(".hit-post-topic-title", { count: 1 });

assert
.dom(".hit-post-topic-title")
.hasText("Internationalizations / localization");

const posts = queryAll(".hit-post-topic-title");
assert.strictEqual(posts.length, 1);
assert.strictEqual(
posts[0].textContent.trim(),
"Internationalizations / localization"
);
await click(".hit-post-topic-title");
assert.strictEqual(
currentURL(),
Expand All @@ -199,7 +195,8 @@ acceptance("Discourse Algolia - Search", function (needs) {
);

await fillIn(".aa-Input", "internationalization");
await settled();
await waitFor(".hit-post-category-name");

await click(".hit-post-category-name");
assert.strictEqual(
currentURL(),
Expand All @@ -208,7 +205,8 @@ acceptance("Discourse Algolia - Search", function (needs) {
);

await fillIn(".aa-Input", "internationalization");
await settled();
await waitFor(".hit-post-username");

await click(".hit-post-username");
assert.strictEqual(
currentURL(),
Expand All @@ -217,12 +215,12 @@ acceptance("Discourse Algolia - Search", function (needs) {
);

await fillIn(".aa-Input", "eviltrout");
await settled();
assert.strictEqual(
query(".hit-user-custom-ranking").innerText.trim(),
"❤18",
"displayes amount of likes"
);
await waitFor(".hit-user-custom-ranking");

assert
.dom(".hit-user-custom-ranking")
.hasText("❤18", "displays amount of likes");

await click(".hit-user-username");
assert.strictEqual(
currentURL(),
Expand All @@ -231,19 +229,19 @@ acceptance("Discourse Algolia - Search", function (needs) {
);

await fillIn(".aa-Input", "bug");
await settled();
assert.strictEqual(
query(".hit-tag-topic_count").innerText.trim(),
"6",
"displayes amount of topics with tag"
);
await waitFor(".hit-tag-topic_count");

assert
.dom(".hit-tag-topic_count")
.hasText("6", "displays amount of topics with tag");

await click(".hit-tag-name");
assert.strictEqual(currentURL(), "/tag/bug", "redirects to tag page");
});

test("search not visible when site is requiring login", async function (assert) {
this.siteSettings.login_required = true;
await visit("/");
assert.ok(!exists(document.querySelector(".algolia-search")));
assert.dom(".algolia-search").doesNotExist();
});
});
Loading

0 comments on commit 1017b35

Please sign in to comment.