DEV: Update linting (#704)

This commit is contained in:
Jarek Radosz 2025-03-17 11:55:49 +01:00 committed by GitHub
parent c8934ed60d
commit fc3f4071ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 1332 additions and 1421 deletions

View File

@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (8.0.0)
activesupport (8.0.2)
base64
benchmark (>= 0.3)
bigdecimal
@ -17,67 +17,77 @@ GEM
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
bigdecimal (3.1.9)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
drb (2.2.1)
i18n (1.14.6)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.8.2)
language_server-protocol (3.17.0.3)
logger (1.6.1)
minitest (5.25.1)
json (2.10.2)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
logger (1.6.6)
minitest (5.25.5)
parallel (1.26.3)
parser (3.3.6.0)
parser (3.3.7.1)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
racc (1.8.1)
rack (3.1.10)
rack (3.1.12)
rainbow (3.1.1)
regexp_parser (2.9.2)
rubocop (1.68.0)
regexp_parser (2.10.0)
rubocop (1.74.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.36.1)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.1)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-discourse (3.8.6)
rubocop-capybara (2.22.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-discourse (3.12.1)
activesupport (>= 6.1)
rubocop (>= 1.59.0)
rubocop-capybara (>= 2.0.0)
rubocop-factory_bot (>= 2.0.0)
rubocop-rails (>= 2.25.0)
lint_roller (>= 1.1.0)
rubocop (>= 1.73.2)
rubocop-capybara (>= 2.22.0)
rubocop-factory_bot (>= 2.27.0)
rubocop-rails (>= 2.30.3)
rubocop-rspec (>= 3.0.1)
rubocop-rspec_rails (>= 2.30.0)
rubocop-factory_bot (2.26.1)
rubocop (~> 1.61)
rubocop-rails (2.27.0)
rubocop-rspec_rails (>= 2.31.0)
rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.30.3)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.2.0)
rubocop (~> 1.61)
rubocop-rspec_rails (2.30.0)
rubocop (~> 1.61)
rubocop-rspec (~> 3, >= 3.0.1)
rubocop (>= 1.72.1, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-rspec (3.5.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec_rails (2.31.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec (~> 3.5)
ruby-progressbar (1.13.0)
securerandom (0.3.2)
securerandom (0.4.1)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (1.0.2)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
uri (1.0.3)
PLATFORMS
ruby
@ -87,4 +97,4 @@ DEPENDENCIES
syntax_tree
BUNDLED WITH
2.5.18
2.6.5

View File

@ -15,7 +15,9 @@ import MoreMenu from "./more-menu";
import Status from "./status";
import Url from "./url";
const StatusSeparator = <template><span class="separator">·</span></template>;
const StatusSeparator = <template>
<span class="separator">·</span>
</template>;
const InfoSection = <template>
<section class="event__section" ...attributes>

View File

@ -0,0 +1,50 @@
import Component from "@glimmer/component";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DButton from "discourse/components/d-button";
import { i18n } from "discourse-i18n";
import RegionInput from "../../components/region-input";
import { TIME_ZONE_TO_REGION } from "../../lib/regions";
export default class Region extends Component {
static shouldRender(args, component) {
return component.siteSettings.calendar_enabled;
}
@service siteSettings;
@action
onChange(value) {
this.args.outletArgs.model.set("custom_fields.holidays-region", value);
}
@action
useCurrentRegion() {
this.args.outletArgs.model.set(
"custom_fields.holidays-region",
TIME_ZONE_TO_REGION[moment.tz.guess()] || "us"
);
}
<template>
<div class="control-group region">
<label class="control-label">
{{i18n "discourse_calendar.region.title"}}
</label>
<div class="controls">
<RegionInput
@value={{@outletArgs.model.custom_fields.holidays-region}}
@allowNoneRegion={{true}}
@onChange={{this.onChange}}
/>
</div>
<DButton
@icon="globe"
@label="discourse_calendar.region.use_current_region"
@action={{this.useCurrentRegion}}
/>
</div>
</template>
}

View File

@ -1,17 +0,0 @@
<div class="control-group">
<label class="control-label">{{i18n
"discourse_calendar.region.title"
}}</label>
<div class="controls">
<RegionInput
@value={{this.model.custom_fields.holidays-region}}
@allowNoneRegion={{true}}
@onChange={{action "onChange"}}
/>
</div>
<DButton
@icon="globe"
@label="discourse_calendar.region.use_current_region"
@action={{action "useCurrentRegion"}}
/>
</div>

View File

@ -1,25 +0,0 @@
import { action } from "@ember/object";
import { TIME_ZONE_TO_REGION } from "../../lib/regions";
export default {
setupComponent(args, component) {
component.setProperties({
@action
onChange(value) {
this.model.set("custom_fields.holidays-region", value);
},
@action
useCurrentRegion() {
this.model.set(
"custom_fields.holidays-region",
TIME_ZONE_TO_REGION[moment.tz.guess()] || "us"
);
},
});
},
shouldRender(args, component) {
return component.siteSettings.calendar_enabled;
},
};

View File

@ -992,8 +992,8 @@ function initializeDiscourseCalendar(api) {
http://www.google.com/calendar/event?action=TEMPLATE&text=${encodeURIComponent(
eventTitle
)}&dates=${startDate}/${endDate}&details=${encodeURIComponent(
event.eventRange.def.extendedProps.description
)}`;
event.eventRange.def.extendedProps.description
)}`;
link.target = "_blank";
link.classList.add("fc-list-item-add-to-calendar");
event.el.querySelector(".fc-list-item-title").appendChild(link);

View File

@ -98,9 +98,10 @@ function initializeDiscoursePostEventDecorator(api) {
const event = DiscoursePostEventEvent.create(post.event);
helper.renderGlimmer(wrapper, <template>
<DiscoursePostEvent @event={{event}} />
</template>);
helper.renderGlimmer(
wrapper,
<template><DiscoursePostEvent @event={{event}} /></template>
);
}
},
{

View File

@ -1,14 +1,16 @@
@use "sass:color";
:root {
--calendar-normal: #{dark-light-choose(
lighten($tertiary, 55%),
darken($tertiary, 25%)
color.adjust($tertiary, $lightness: 55%),
color.adjust($tertiary, $lightness: -25%)
)};
--calendar-close-to-working-hours: #{dark-light-choose(
desaturate(lighten($tertiary, 45%), 15%),
darken($tertiary, 15%)
color.adjust(color.adjust($tertiary, $lightness: 45%), $saturation: -15%),
color.adjust($tertiary, $lightness: -15%)
)};
--calendar-in-working-hours: #{dark-light-choose(
desaturate(lighten($tertiary, 40%), 20%),
darken($tertiary, 10%)
color.adjust(color.adjust($tertiary, $lightness: 40%), $saturation: -20%),
color.adjust($tertiary, $lightness: -10%)
)};
}

View File

@ -30,7 +30,6 @@
}
}
}
overflow: hidden;
.fc-scroller {
@ -152,6 +151,7 @@
margin-left: 0;
}
}
.fc-list-item-add-to-calendar {
color: var(--tertiary);
font-size: var(--font-down-1);
@ -178,7 +178,9 @@ a.holiday {
min-height: 60px;
.discourse-calendar-timezone-picker {
font-size: 16px;
margin-bottom: 0;
max-width: 50vw;
}
h2.discourse-calendar-title {
@ -191,11 +193,6 @@ a.holiday {
}
}
.discourse-calendar-header .discourse-calendar-timezone-picker {
max-width: 50vw;
font-size: 16px;
}
.group-timezones {
display: grid;
width: 100%;
@ -257,6 +254,7 @@ a.holiday {
position: relative;
margin: 0.25em 0;
margin-right: 0.5em;
&::before {
display: block;
content: "";
@ -275,8 +273,7 @@ a.holiday {
display: flex;
width: 120px;
padding: 0.25em;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
font: inherit;
outline: none;
@ -379,6 +376,7 @@ a.holiday {
opacity: 0.7;
position: relative;
}
&.on-holiday::after {
content: "📅";
position: absolute;
@ -412,7 +410,7 @@ a.holiday {
box-shadow: var(--shadow-dropdown);
border-radius: 4px;
padding: 0.5em;
max-width: unquote("min(75vw, 400px)");
max-width: min(75vw, 400px);
[data-popper-arrow],
[data-popper-arrow]::before {

View File

@ -33,8 +33,6 @@
.bulk-invite-actions {
display: flex;
.send-bulk-invites {
}
.add-bulk-invite {
margin-left: auto;

View File

@ -4,6 +4,13 @@
.topic-link {
display: inline;
}
.event-date {
font-size: var(--font-down-4);
color: var(--primary-medium);
font-weight: normal;
padding: 0.25em;
}
}
.main-link {
@ -36,12 +43,3 @@
}
}
}
.header-title {
.event-date {
font-size: var(--font-down-4);
color: var(--primary-medium);
font-weight: normal;
padding: 0.25em;
}
}

View File

@ -2,27 +2,33 @@
.modal-body {
padding: 0;
}
.modal-inner-container {
min-width: 350px;
}
.loading-container {
height: 40vh;
overflow-y: scroll;
.no-users {
text-align: center;
font-size: var(--font-up-1);
}
}
.invitees-type-filter {
margin-bottom: 9px;
display: flex;
.btn {
width: calc(100% / 3);
margin: 0;
border-radius: 0px;
padding: 0.75em 0em;
border-radius: 0;
padding: 0.75em 0;
}
}
.filter {
width: calc(100% - 2em);
margin-bottom: 1em;
@ -52,6 +58,7 @@
display: flex;
align-items: center;
white-space: nowrap;
.username {
margin-left: 0.5em;
text-overflow: ellipsis;

View File

@ -1,5 +1,6 @@
.discourse-post-event-upcoming-events {
height: 100%;
.upcoming-events-table {
width: 100%;

View File

@ -371,32 +371,7 @@ $show-interested: inherit;
@include ellipsis;
}
}
}
.event-dates {
// hardcoded as cooking date is async and will change height after initial rendering otherwise
// not ideal but a decent low tech solution
height: 24px;
.participants {
margin-left: 0.5em;
color: var(--primary-medium);
}
.discourse-local-date {
.d-icon {
display: none;
}
}
.separator {
color: var(--primary-high);
margin: 0 0.5em;
text-align: center;
}
}
.discourse-post-event {
.cooked-date,
.participants,
.event-url .url {
@ -438,3 +413,26 @@ $show-interested: inherit;
color: var(--primary-medium);
}
}
.event-dates {
// hardcoded as cooking date is async and will change height after initial rendering otherwise
// not ideal but a decent low tech solution
height: 24px;
.participants {
margin-left: 0.5em;
color: var(--primary-medium);
}
.discourse-local-date {
.d-icon {
display: none;
}
}
.separator {
color: var(--primary-high);
margin: 0 0.5em;
text-align: center;
}
}

View File

@ -65,6 +65,7 @@
.combo-box {
width: 130px;
}
.selected-name {
border: 0;

View File

@ -51,7 +51,6 @@
color: var(--primary);
text-shadow: none;
border: none;
padding: 6px 12px;
&:hover {
@ -63,12 +62,12 @@
background: var(--tertiary);
color: var(--secondary);
}
margin: 0.3em 0 0.3em 0.5em;
}
.fc-button-group {
margin: 0.3em 0 0.3em 0.5em;
// margin-right: 0;
.fc-button {
margin: 0;
@ -107,7 +106,6 @@
}
&.grouped-event {
background-color: none;
background: var(--secondary);
border: 1px solid var(--primary-low-mid);
color: var(--primary);

View File

@ -5,12 +5,15 @@
padding: 0.5em;
border-radius: var(--d-border-radius);
}
&__event:last-of-type {
margin-bottom: 0.75em;
}
&__event:hover {
background-color: var(--primary-50);
}
&__event-date {
display: flex;
flex-shrink: 0;
@ -25,22 +28,26 @@
flex-direction: column;
background-color: var(--secondary);
}
&__event-date .month {
text-align: center;
color: var(--primary);
font-size: var(--font-down-3);
text-transform: uppercase;
}
&__event-date .day {
text-align: center;
color: var(--primary);
font-weight: bold;
font-size: var(--font-down-1);
}
&__event-content {
display: flex;
flex-direction: column;
}
&__event-name {
display: -webkit-box;
-webkit-line-clamp: 1;
@ -48,20 +55,24 @@
overflow: hidden;
color: var(--primary);
}
&__event-time {
font-size: var(--font-down-2);
font-weight: 400;
color: var(--primary-700);
}
&__footer {
margin-top: 1em;
font-size: var(--font-down-2);
line-height: var(--line-height-medium);
padding-left: 0.5em;
}
&__footer a {
color: var(--primary-high);
}
&__footer a:hover {
color: var(--primary);
}

View File

@ -2,10 +2,12 @@
table {
width: 100%;
}
.fc-list-item-add-to-calendar {
float: right;
margin-right: 5px;
}
.fc-list-item:hover td {
background: var(--highlight-medium);
}

View File

@ -23,6 +23,7 @@
.fc-day-header.fc-widget-header {
text-align: center;
padding: 0.25em;
span {
font-size: var(--font-down-1);
text-align: center;
@ -33,9 +34,11 @@
.calendar {
padding: 0;
.fc-list-item-add-to-calendar {
display: block;
}
&.fc-unthemed .fc-header-toolbar {
padding: 0.5em 0;
}

View File

@ -1,3 +1,8 @@
import DiscourseRecommended from "@discourse/lint-configs/eslint";
export default [...DiscourseRecommended];
export default [
...DiscourseRecommended,
{
ignores: ["public/**/*"],
},
];

View File

@ -1,10 +1,11 @@
{
"private": true,
"devDependencies": {
"@discourse/lint-configs": "2.4.0",
"ember-template-lint": "6.1.0",
"eslint": "9.19.0",
"prettier": "2.8.8"
"@discourse/lint-configs": "2.11.0",
"ember-template-lint": "7.0.1",
"eslint": "9.22.0",
"prettier": "3.5.3",
"stylelint": "16.15.0"
},
"engines": {
"node": ">= 22",

View File

@ -335,7 +335,7 @@ after_initialize do
return if self.is_first_post?
# Skip if not a calendar topic
return if !self&.topic&.first_post&.custom_fields&.[](DiscourseCalendar::CALENDAR_CUSTOM_FIELD)
return if !self.topic&.first_post&.custom_fields&.[](DiscourseCalendar::CALENDAR_CUSTOM_FIELD)
validator = DiscourseCalendar::EventValidator.new(self)
validator.validate_event

File diff suppressed because it is too large Load Diff

3
stylelint.config.mjs Normal file
View File

@ -0,0 +1,3 @@
export default {
extends: ["@discourse/lint-configs/stylelint"],
};

View File

@ -41,15 +41,17 @@ module("Integration | Component | MoreMenu", function (hooks) {
id: 322,
});
await render(<template>
<MoreMenu
@event={{hash
isExpired=false
creator=creator
canActOnDiscoursePostEvent=false
}}
/>
</template>);
await render(
<template>
<MoreMenu
@event={{hash
isExpired=false
creator=creator
canActOnDiscoursePostEvent=false
}}
/>
</template>
);
await click(".discourse-post-event-more-menu-trigger");
assert.dom(".show-all-participants").exists();

View File

@ -13,6 +13,7 @@ import UpcomingEventsList, {
class RouterStub extends Service {
currentRoute = { attributes: { category: { id: 1, slug: "announcements" } } };
currentRouteName = "discovery.latest";
on() {}
off() {}
}
@ -218,9 +219,11 @@ module("Integration | Component | upcoming-events-list", function (hooks) {
test("with events, overridden time format", async function (assert) {
pretender.get("/discourse-post-event/events", twoEventsResponseHandler);
await render(<template>
<UpcomingEventsList @params={{hash timeFormat="LLL"}} />
</template>);
await render(
<template>
<UpcomingEventsList @params={{hash timeFormat="LLL"}} />
</template>
);
this.appEvents.trigger("page:changed", { url: "/" });
@ -289,9 +292,9 @@ module("Integration | Component | upcoming-events-list", function (hooks) {
test("with events, overridden count parameter", async function (assert) {
pretender.get("/discourse-post-event/events", twoEventsResponseHandler);
await render(<template>
<UpcomingEventsList @params={{hash count=1}} />
</template>);
await render(
<template><UpcomingEventsList @params={{hash count=1}} /></template>
);
this.appEvents.trigger("page:changed", { url: "/" });
@ -319,9 +322,11 @@ module("Integration | Component | upcoming-events-list", function (hooks) {
test("with events, overridden upcomingDays parameter", async function (assert) {
pretender.get("/discourse-post-event/events", twoEventsResponseHandler);
await render(<template>
<UpcomingEventsList @params={{hash upcomingDays=1}} />
</template>);
await render(
<template>
<UpcomingEventsList @params={{hash upcomingDays=1}} />
</template>
);
this.appEvents.trigger("page:changed", { url: "/" });