Skip to content

Commit fab954f

Browse files
authored
DEV: Update linting config and run gjs-codemod (#160)
1 parent 742eac7 commit fab954f

37 files changed

+924
-779
lines changed

.discourse-compatibility

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
< 3.5.0.beta5-dev: ca2ed546834ed079b89d83e891ad638b999bdd85
12
< 3.5.0.beta3-dev: 6150b4acfbbb2cbd24053845dd90c5e72bee0680
23
< 3.5.0.beta1-dev: 8c1a83c481c25deb69e9c25bb93ca667e7c251c4
34
< 3.4.0.beta2-dev: 4efb227d5a09c011ae03aac4418f6dac6fb3fc19

Gemfile.lock

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,44 @@ GEM
1414
securerandom (>= 0.3)
1515
tzinfo (~> 2.0, >= 2.0.5)
1616
uri (>= 0.13.1)
17-
ast (2.4.2)
18-
base64 (0.2.0)
19-
benchmark (0.4.0)
20-
bigdecimal (3.1.9)
17+
ast (2.4.3)
18+
base64 (0.3.0)
19+
benchmark (0.4.1)
20+
bigdecimal (3.2.0)
2121
concurrent-ruby (1.3.5)
22-
connection_pool (2.5.0)
23-
drb (2.2.1)
22+
connection_pool (2.5.3)
23+
drb (2.2.3)
2424
i18n (1.14.7)
2525
concurrent-ruby (~> 1.0)
26-
json (2.10.2)
27-
language_server-protocol (3.17.0.4)
26+
json (2.12.2)
27+
language_server-protocol (3.17.0.5)
2828
lint_roller (1.1.0)
29-
logger (1.6.6)
29+
logger (1.7.0)
3030
minitest (5.25.5)
31-
parallel (1.26.3)
32-
parser (3.3.7.1)
31+
parallel (1.27.0)
32+
parser (3.3.8.0)
3333
ast (~> 2.4.1)
3434
racc
3535
prettier_print (1.2.1)
36+
prism (1.4.0)
3637
racc (1.8.1)
37-
rack (3.1.12)
38+
rack (3.1.15)
3839
rainbow (3.1.1)
3940
regexp_parser (2.10.0)
40-
rubocop (1.74.0)
41+
rubocop (1.75.8)
4142
json (~> 2.3)
4243
language_server-protocol (~> 3.17.0.2)
4344
lint_roller (~> 1.1.0)
4445
parallel (~> 1.10)
4546
parser (>= 3.3.0.2)
4647
rainbow (>= 2.2.2, < 4.0)
4748
regexp_parser (>= 2.9.3, < 3.0)
48-
rubocop-ast (>= 1.38.0, < 2.0)
49+
rubocop-ast (>= 1.44.0, < 2.0)
4950
ruby-progressbar (~> 1.7)
5051
unicode-display_width (>= 2.4.0, < 4.0)
51-
rubocop-ast (1.38.1)
52-
parser (>= 3.3.1.0)
52+
rubocop-ast (1.44.1)
53+
parser (>= 3.3.7.2)
54+
prism (~> 1.4)
5355
rubocop-capybara (2.22.1)
5456
lint_roller (~> 1.1)
5557
rubocop (~> 1.72, >= 1.72.1)
@@ -65,13 +67,13 @@ GEM
6567
rubocop-factory_bot (2.27.1)
6668
lint_roller (~> 1.1)
6769
rubocop (~> 1.72, >= 1.72.1)
68-
rubocop-rails (2.30.3)
70+
rubocop-rails (2.32.0)
6971
activesupport (>= 4.2.0)
7072
lint_roller (~> 1.1)
7173
rack (>= 1.1)
72-
rubocop (>= 1.72.1, < 2.0)
73-
rubocop-ast (>= 1.38.0, < 2.0)
74-
rubocop-rspec (3.5.0)
74+
rubocop (>= 1.75.0, < 2.0)
75+
rubocop-ast (>= 1.44.0, < 2.0)
76+
rubocop-rspec (3.6.0)
7577
lint_roller (~> 1.1)
7678
rubocop (~> 1.72, >= 1.72.1)
7779
rubocop-rspec_rails (2.31.0)
@@ -97,4 +99,4 @@ DEPENDENCIES
9799
syntax_tree
98100

99101
BUNDLED WITH
100-
2.6.6
102+
2.6.9

assets/javascripts/discourse/components/emoji-images.js renamed to assets/javascripts/discourse/components/emoji-images.gjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Component from "@ember/component";
22
import { classNames } from "@ember-decorators/component";
3+
import icon from "discourse/helpers/d-icon";
4+
import htmlSafe from "discourse/helpers/html-safe";
35
import computed from "discourse/lib/decorators";
46
import { emojiUnescape } from "discourse/lib/text";
57
import { i18n } from "discourse-i18n";
@@ -17,4 +19,16 @@ export default class EmojiImages extends Component {
1719
titleText(title) {
1820
return i18n(title);
1921
}
22+
23+
<template>
24+
{{#if this.siteSettings.enable_emoji}}
25+
<div title={{this.titleText}}>
26+
{{#each this.emojiHTML as |html|}}
27+
{{htmlSafe html}}
28+
{{/each}}
29+
</div>
30+
{{else}}
31+
{{icon "cake-candles" title=this.titleText}}
32+
{{/if}}
33+
</template>
2034
}

assets/javascripts/discourse/components/emoji-images.hbs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Component from "@ember/component";
2+
import { classNames, tagName } from "@ember-decorators/component";
3+
import {
4+
birthday,
5+
birthdayTitle,
6+
cakeday,
7+
cakedayTitle,
8+
} from "discourse/plugins/discourse-cakeday/discourse/lib/cakeday";
9+
import EmojiImages from "../../components/emoji-images";
10+
11+
@tagName("div")
12+
@classNames("user-card-post-names-outlet", "user-card-cakeday")
13+
export default class UserCardCakeday extends Component {
14+
init() {
15+
super.init(...arguments);
16+
const { user } = this;
17+
this.set("isCakeday", cakeday(user.cakedate));
18+
this.set("isBirthday", birthday(user.birthdate));
19+
this.set("cakedayTitle", cakedayTitle(user, this.currentUser));
20+
this.set("birthdayTitle", birthdayTitle(user, this.currentUser));
21+
}
22+
23+
<template>
24+
{{#if this.siteSettings.cakeday_birthday_enabled}}
25+
{{#if this.isBirthday}}
26+
<EmojiImages
27+
@list={{this.siteSettings.cakeday_birthday_emoji}}
28+
@title={{this.birthdayTitle}}
29+
/>
30+
{{/if}}
31+
{{/if}}
32+
{{#if this.siteSettings.cakeday_enabled}}
33+
{{#if this.isCakeday}}
34+
<EmojiImages
35+
@list={{this.siteSettings.cakeday_emoji}}
36+
@title={{this.cakedayTitle}}
37+
/>
38+
{{/if}}
39+
{{/if}}
40+
</template>
41+
}

assets/javascripts/discourse/connectors/user-card-post-names/user-card-cakeday.hbs

Lines changed: 0 additions & 16 deletions
This file was deleted.

assets/javascripts/discourse/connectors/user-card-post-names/user-card-cakeday.js

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import Component from "@ember/component";
2+
import { hash } from "@ember/helper";
3+
import { classNames, tagName } from "@ember-decorators/component";
4+
import { i18n } from "discourse-i18n";
5+
import ComboBox from "select-kit/components/combo-box";
6+
7+
@tagName("div")
8+
@classNames("user-custom-preferences-outlet", "user-date-of-birth-input")
9+
export default class UserDateOfBirthInput extends Component {
10+
init() {
11+
super.init(...arguments);
12+
const { model } = this;
13+
const { birthdate } = model;
14+
const months = moment.months().map((month, index) => {
15+
return {
16+
name: month,
17+
value: index + 1,
18+
};
19+
});
20+
const days = [...Array(31).keys()].map((d) => (d + 1).toString());
21+
const month = birthdate
22+
? moment(birthdate, "YYYY-MM-DD").month() + 1
23+
: null;
24+
const day = birthdate
25+
? moment(birthdate, "YYYY-MM-DD").date().toString()
26+
: null;
27+
this.setProperties({
28+
months,
29+
days,
30+
month,
31+
day,
32+
});
33+
const updateBirthdate = () => {
34+
let date = "";
35+
if (this.month && this.day) {
36+
date = `1904-${this.month}-${this.day}`;
37+
}
38+
39+
// The property that is being serialized when sending the update
40+
// request to the server is called `date_of_birth`
41+
model.set("date_of_birth", date);
42+
};
43+
this.addObserver("month", updateBirthdate);
44+
this.addObserver("day", updateBirthdate);
45+
}
46+
47+
<template>
48+
{{#if this.siteSettings.cakeday_birthday_enabled}}
49+
<div class="control-group">
50+
<label class="control-label">{{i18n "user.date_of_birth.label"}}</label>
51+
<div class="controls">
52+
<ComboBox
53+
@content={{this.months}}
54+
@value={{this.month}}
55+
@valueAttribute="value"
56+
@valueProperty="value"
57+
@none="cakeday.none"
58+
@options={{hash clearable=true autoInsertNoneItem=false}}
59+
@onChange={{action (mut this.month)}}
60+
/>
61+
62+
<ComboBox
63+
@content={{this.days}}
64+
@value={{this.day}}
65+
@valueProperty={{null}}
66+
@nameProperty={{null}}
67+
@none="cakeday.none"
68+
@options={{hash clearable=true autoInsertNoneItem=false}}
69+
@onChange={{action (mut this.day)}}
70+
/>
71+
</div>
72+
</div>
73+
{{/if}}
74+
</template>
75+
}

assets/javascripts/discourse/connectors/user-custom-preferences/user-date-of-birth-input.hbs

Lines changed: 0 additions & 26 deletions
This file was deleted.

assets/javascripts/discourse/connectors/user-custom-preferences/user-date-of-birth-input.js

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Component from "@ember/component";
2+
import { classNames, tagName } from "@ember-decorators/component";
3+
import {
4+
birthday,
5+
birthdayTitle,
6+
cakeday,
7+
cakedayTitle,
8+
} from "discourse/plugins/discourse-cakeday/discourse/lib/cakeday";
9+
import EmojiImages from "../../components/emoji-images";
10+
11+
@tagName("div")
12+
@classNames("user-post-names-outlet", "user-cakeday")
13+
export default class UserCakeday extends Component {
14+
init() {
15+
super.init(...arguments);
16+
const { model } = this;
17+
this.set("isCakeday", cakeday(model.cakedate));
18+
this.set("isBirthday", birthday(model.birthdate));
19+
this.set("cakedayTitle", cakedayTitle(model, this.currentUser));
20+
this.set("birthdayTitle", birthdayTitle(model, this.currentUser));
21+
}
22+
23+
<template>
24+
{{#if this.siteSettings.cakeday_birthday_enabled}}
25+
{{#if this.isBirthday}}
26+
<EmojiImages
27+
@list={{this.siteSettings.cakeday_birthday_emoji}}
28+
@title={{this.birthdayTitle}}
29+
/>
30+
{{/if}}
31+
{{/if}}
32+
{{#if this.siteSettings.cakeday_enabled}}
33+
{{#if this.isCakeday}}
34+
<EmojiImages
35+
@list={{this.siteSettings.cakeday_emoji}}
36+
@title={{this.cakedayTitle}}
37+
/>
38+
{{/if}}
39+
{{/if}}
40+
</template>
41+
}

0 commit comments

Comments
 (0)