DEV: Update linting config and run gjs-codemod (#125)

This commit is contained in:
Jarek Radosz 2025-06-05 12:40:54 +02:00 committed by GitHub
parent 4a529a5ea3
commit d5dd1d9212
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 770 additions and 690 deletions

View File

@ -1,3 +1,4 @@
< 3.5.0.beta5-dev: be64a5ea30dcda658a74e22a9e7b5fd8cd7632c8
< 3.5.0.beta1-dev: b7181ad63238adf843d27b2d0db13cb6354df379
< 3.4.0.beta2-dev: ff810c65d88e3a208b1126e94ec9ba637d6e997e
< 3.4.0.beta1-dev: 5a44de571484b2652d7ba57b16e3e1519e4d7317

View File

@ -14,30 +14,31 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
ast (2.4.3)
base64 (0.3.0)
benchmark (0.4.1)
bigdecimal (3.2.0)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
drb (2.2.1)
connection_pool (2.5.3)
drb (2.2.3)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.10.2)
language_server-protocol (3.17.0.4)
json (2.12.2)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.6.6)
logger (1.7.0)
minitest (5.25.5)
parallel (1.26.3)
parser (3.3.7.1)
parallel (1.27.0)
parser (3.3.8.0)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (1.4.0)
racc (1.8.1)
rack (3.1.12)
rack (3.1.15)
rainbow (3.1.1)
regexp_parser (2.10.0)
rubocop (1.74.0)
rubocop (1.75.8)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
@ -45,11 +46,12 @@ GEM
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.1)
parser (>= 3.3.1.0)
rubocop-ast (1.44.1)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-capybara (2.22.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
@ -65,13 +67,13 @@ GEM
rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.30.3)
rubocop-rails (2.32.0)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
rubocop (>= 1.72.1, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-rspec (3.5.0)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
rubocop-rspec (3.6.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec_rails (2.31.0)
@ -97,4 +99,4 @@ DEPENDENCIES
syntax_tree
BUNDLED WITH
2.6.6
2.6.9

View File

@ -1,4 +0,0 @@
<ShowUserNotes
@show={{action "showUserNotes"}}
@count={{this.userNotesCount}}
/>

View File

@ -1,4 +0,0 @@
import connector from "discourse/plugins/discourse-user-notes/discourse-user-notes/connectors/user-profile-controls/show-notes-on-profile";
// Same as other connector
export default connector;

View File

@ -1,18 +0,0 @@
{{#if this.userNotesCount}}
<DButton
@translatedTitle={{this.userNotesTitle}}
@action={{action "showUserNotes"}}
class="btn btn-flat"
>
{{#if this.emojiEnabled}}
<img
src={{this.emojiUrl}}
title={{this.userNotesTitle}}
alt=""
class="emoji"
/>
{{else}}
{{d-icon "pen-to-square"}}
{{/if}}
</DButton>
{{/if}}

View File

@ -1,32 +0,0 @@
import EmberObject from "@ember/object";
import { getOwner } from "@ember/owner";
import { emojiUrlFor } from "discourse/lib/text";
import { i18n } from "discourse-i18n";
import { showUserNotes } from "discourse/plugins/discourse-user-notes/discourse-user-notes/lib/user-notes";
export default {
shouldRender(args, component) {
return component.siteSettings.user_notes_enabled && args.user;
},
setupComponent(args, component) {
const model = EmberObject.create(args.user);
const userNotesCount = model.get("custom_fields.user_notes_count") || 0;
component.setProperties({
userNotesCount,
emojiEnabled: component.siteSettings.enable_emoji,
emojiUrl: emojiUrlFor("memo"),
userNotesTitle: i18n("user_notes.show", { count: userNotesCount }),
});
},
actions: {
showUserNotes() {
const store = getOwner(this).lookup("service:store");
const user = this.get("args.user");
showUserNotes(store, user.id, (count) =>
this.set("userNotesCount", count)
);
},
},
};

View File

@ -1,4 +0,0 @@
<ShowUserNotes
@show={{action "showUserNotes"}}
@count={{this.userNotesCount}}
/>

View File

@ -1,27 +0,0 @@
import { getOwner } from "@ember/owner";
import { showUserNotes } from "discourse/plugins/discourse-user-notes/discourse-user-notes/lib/user-notes";
export default {
shouldRender(args, component) {
const { siteSettings, currentUser } = component;
return siteSettings.user_notes_enabled && currentUser && currentUser.staff;
},
setupComponent(args, component) {
const { model } = args;
component.set(
"userNotesCount",
model.user_notes_count || model.get("custom_fields.user_notes_count") || 0
);
},
actions: {
showUserNotes() {
const store = getOwner(this).lookup("service:store");
const user = this.get("args.model");
showUserNotes(store, user.id, (count) =>
this.set("userNotesCount", count)
);
},
},
};

View File

@ -0,0 +1,134 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { Textarea } from "@ember/component";
import { fn } from "@ember/helper";
import { action } from "@ember/object";
import { service } from "@ember/service";
import CookText from "discourse/components/cook-text";
import DButton from "discourse/components/d-button";
import DModal from "discourse/components/d-modal";
import UserLink from "discourse/components/user-link";
import ageWithTooltip from "discourse/helpers/age-with-tooltip";
import avatar from "discourse/helpers/avatar";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { i18n } from "discourse-i18n";
export default class UserNotesModal extends Component {
@service dialog;
@service store;
@tracked newNote;
@tracked userId = this.args.model.userId;
@tracked saving = false;
postId = this.args.model.postId;
callback = this.args.model.callback;
#refreshCount() {
if (this.callback) {
this.callback(this.args.model.note.length);
}
}
get attachDisabled() {
return this.saving || !this.newNote || this.newNote.length === 0;
}
@action
async attachNote() {
const note = this.store.createRecord("user-note");
const userId = parseInt(this.userId, 10);
this.saving = true;
const args = {
raw: this.newNote,
user_id: userId,
};
if (this.postId) {
args.post_id = parseInt(this.postId, 10);
}
try {
await note.save(args);
this.newNote = "";
this.args.model.note.insertAt(0, note);
this.#refreshCount();
} catch (error) {
popupAjaxError(error);
} finally {
this.saving = false;
}
}
@action
removeNote(note) {
this.dialog.deleteConfirm({
message: i18n("user_notes.delete_confirm"),
didConfirm: () => {
note
.destroyRecord()
.then(() => {
this.args.model.note.removeObject(note);
this.#refreshCount();
})
.catch(popupAjaxError);
},
});
}
<template>
<DModal
@closeModal={{@closeModal}}
@title={{i18n "user_notes.title"}}
class="user-notes-modal"
>
<Textarea @value={{this.newNote}} />
<DButton
@action={{this.attachNote}}
@label="user_notes.attach"
@disabled={{this.attachDisabled}}
class="btn-primary"
/>
{{#each @model.note as |n|}}
<div class="user-note">
<div class="posted-by">
<UserLink @user={{n.created_by}}>
{{avatar n.created_by imageSize="small"}}
</UserLink>
</div>
<div class="note-contents">
<div class="note-info">
<span class="username">{{n.created_by.username}}</span>
<span class="post-date">{{ageWithTooltip n.created_at}}</span>
{{#if n.can_delete}}
<span class="controls">
<DButton
@action={{fn this.removeNote n}}
@icon="far-trash-can"
@title="user_notes.remove"
class="btn-small btn-danger"
/>
</span>
{{/if}}
</div>
<div class="cooked">
<CookText @rawText={{n.raw}} />
</div>
{{#if n.post_id}}
<a href={{n.post_url}} class="btn btn-small">
{{i18n "user_notes.show_post"}}
</a>
{{/if}}
</div>
<div class="clearfix"></div>
</div>
{{/each}}
</DModal>
</template>
}

View File

@ -1,52 +0,0 @@
<DModal
@closeModal={{@closeModal}}
@title={{i18n "user_notes.title"}}
class="user-notes-modal"
>
<Textarea @value={{this.newNote}} />
<DButton
@action={{this.attachNote}}
@label="user_notes.attach"
@disabled={{this.attachDisabled}}
class="btn-primary"
/>
{{#each @model.note as |n|}}
<div class="user-note">
<div class="posted-by">
<UserLink @user={{n.created_by}}>
{{avatar n.created_by imageSize="small"}}
</UserLink>
</div>
<div class="note-contents">
<div class="note-info">
<span class="username">{{n.created_by.username}}</span>
<span class="post-date">{{age-with-tooltip n.created_at}}</span>
{{#if n.can_delete}}
<span class="controls">
<DButton
@action={{fn this.removeNote n}}
@icon="far-trash-can"
@title="user_notes.remove"
class="btn-small btn-danger"
/>
</span>
{{/if}}
</div>
<div class="cooked">
<CookText @rawText={{n.raw}} />
</div>
{{#if n.post_id}}
<a href={{n.post_url}} class="btn btn-small">
{{i18n "user_notes.show_post"}}
</a>
{{/if}}
</div>
<div class="clearfix"></div>
</div>
{{/each}}
</DModal>

View File

@ -1,71 +0,0 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { i18n } from "discourse-i18n";
export default class UserNotesModal extends Component {
@service dialog;
@service store;
@tracked newNote;
@tracked userId = this.args.model.userId;
@tracked saving = false;
postId = this.args.model.postId;
callback = this.args.model.callback;
#refreshCount() {
if (this.callback) {
this.callback(this.args.model.note.length);
}
}
get attachDisabled() {
return this.saving || !this.newNote || this.newNote.length === 0;
}
@action
async attachNote() {
const note = this.store.createRecord("user-note");
const userId = parseInt(this.userId, 10);
this.saving = true;
const args = {
raw: this.newNote,
user_id: userId,
};
if (this.postId) {
args.post_id = parseInt(this.postId, 10);
}
try {
await note.save(args);
this.newNote = "";
this.args.model.note.insertAt(0, note);
this.#refreshCount();
} catch (error) {
popupAjaxError(error);
} finally {
this.saving = false;
}
}
@action
removeNote(note) {
this.dialog.deleteConfirm({
message: i18n("user_notes.delete_confirm"),
didConfirm: () => {
note
.destroyRecord()
.then(() => {
this.args.model.note.removeObject(note);
this.#refreshCount();
})
.catch(popupAjaxError);
},
});
}
}

View File

@ -1,4 +1,5 @@
import Component from "@glimmer/component";
import DButton from "discourse/components/d-button";
import { i18n } from "discourse-i18n";
export default class ShowUserNotes extends Component {
@ -9,4 +10,13 @@ export default class ShowUserNotes extends Component {
return i18n("user_notes.title");
}
}
<template>
<DButton
class="btn-default show-user-notes-btn"
@action={{@show}}
@icon="pen-to-square"
@translatedLabel={{this.label}}
/>
</template>
}

View File

@ -1,6 +0,0 @@
<DButton
class="btn-default show-user-notes-btn"
@action={{@show}}
@icon="pen-to-square"
@translatedLabel={{this.label}}
/>

View File

@ -0,0 +1,16 @@
import Component from "@ember/component";
import { classNames, tagName } from "@ember-decorators/component";
import AdminReport from "admin/components/admin-report";
@tagName("div")
@classNames(
"admin-dashboard-moderation-bottom-outlet",
"recent-user-notes-report-table"
)
export default class RecentUserNotesReportTable extends Component {
<template>
{{#if this.siteSettings.user_notes_enabled}}
<AdminReport @dataSourceName="user_notes" @filters={{this.filters}} />
{{/if}}
</template>
}

View File

@ -1,3 +0,0 @@
{{#if this.siteSettings.user_notes_enabled}}
<AdminReport @dataSourceName="user_notes" @filters={{this.filters}} />
{{/if}}

View File

@ -0,0 +1,41 @@
import Component from "@ember/component";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { classNames, tagName } from "@ember-decorators/component";
import ShowUserNotes from "../../components/show-user-notes";
import { showUserNotes } from "../../lib/user-notes";
@tagName("")
@classNames("admin-user-controls-after-outlet", "add-user-notes-button")
export default class AddUserNotesButton extends Component {
static shouldRender(args, context) {
const { siteSettings, currentUser } = context;
return siteSettings.user_notes_enabled && currentUser && currentUser.staff;
}
@service store;
init() {
super.init(...arguments);
const { model } = this;
this.set(
"userNotesCount",
model.user_notes_count || model.get("custom_fields.user_notes_count") || 0
);
}
@action
showUserNotes() {
const user = this.model;
showUserNotes(this.store, user.id, (count) =>
this.set("userNotesCount", count)
);
}
<template>
<ShowUserNotes
@show={{this.showUserNotes}}
@count={{this.userNotesCount}}
/>
</template>
}

View File

@ -0,0 +1,62 @@
import Component from "@ember/component";
import EmberObject, { action } from "@ember/object";
import { service } from "@ember/service";
import { classNames, tagName } from "@ember-decorators/component";
import DButton from "discourse/components/d-button";
import icon from "discourse/helpers/d-icon";
import { emojiUrlFor } from "discourse/lib/text";
import { i18n } from "discourse-i18n";
import { showUserNotes } from "../../lib/user-notes";
@tagName("div")
@classNames("after-reviewable-post-user-outlet", "show-user-notes-on-flags")
export default class ShowUserNotesOnFlags extends Component {
static shouldRender(args, context) {
return context.siteSettings.user_notes_enabled && args.user;
}
@service store;
init() {
super.init(...arguments);
const model = EmberObject.create(this.user);
const userNotesCount = model.get("custom_fields.user_notes_count") || 0;
this.setProperties({
userNotesCount,
emojiEnabled: this.siteSettings.enable_emoji,
emojiUrl: emojiUrlFor("memo"),
userNotesTitle: i18n("user_notes.show", {
count: userNotesCount,
}),
});
}
@action
showUserNotes() {
const user = this.user;
showUserNotes(this.store, user.id, (count) =>
this.set("userNotesCount", count)
);
}
<template>
{{#if this.userNotesCount}}
<DButton
@translatedTitle={{this.userNotesTitle}}
@action={{this.showUserNotes}}
class="btn btn-flat"
>
{{#if this.emojiEnabled}}
<img
src={{this.emojiUrl}}
title={{this.userNotesTitle}}
alt
class="emoji"
/>
{{else}}
{{icon "pen-to-square"}}
{{/if}}
</DButton>
{{/if}}
</template>
}

View File

@ -5,7 +5,7 @@ import DButton from "discourse/components/d-button";
import icon from "discourse/helpers/d-icon";
import emoji from "discourse/helpers/emoji";
import I18n from "discourse-i18n";
import { showUserNotes } from "discourse/plugins/discourse-user-notes/discourse-user-notes/lib/user-notes";
import { showUserNotes } from "../../lib/user-notes";
export default class extends Component {
static shouldRender(args, context) {

View File

@ -0,0 +1,41 @@
import Component from "@ember/component";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { classNames, tagName } from "@ember-decorators/component";
import ShowUserNotes from "../../components/show-user-notes";
import { showUserNotes } from "../../lib/user-notes";
@tagName("li")
@classNames("user-profile-controls-outlet", "show-notes-on-profile")
export default class ShowNotesOnProfile extends Component {
static shouldRender(args, context) {
const { siteSettings, currentUser } = context;
return siteSettings.user_notes_enabled && currentUser && currentUser.staff;
}
@service store;
init() {
super.init(...arguments);
const { model } = this;
this.set(
"userNotesCount",
model.user_notes_count || model.get("custom_fields.user_notes_count") || 0
);
}
@action
showUserNotes() {
const user = this.model;
showUserNotes(this.store, user.id, (count) =>
this.set("userNotesCount", count)
);
}
<template>
<ShowUserNotes
@show={{this.showUserNotes}}
@count={{this.userNotesCount}}
/>
</template>
}

View File

@ -1,6 +1,6 @@
import { iconNode } from "discourse/lib/icon-library";
import { withPluginApi } from "discourse/lib/plugin-api";
import { showUserNotes } from "discourse/plugins/discourse-user-notes/discourse-user-notes/lib/user-notes";
import { showUserNotes } from "../lib/user-notes";
export default {
name: "enable-user-notes",

View File

@ -31,10 +31,6 @@
&:first-of-type {
margin-top: 1em;
}
@include breakpoint(mobile, min-width) {
max-width: 530px;
}
}
.controls {
@ -85,5 +81,5 @@
}
.add-user-note {
border-top: 1px solid rgba(var(--primary-low-rgb), 0.5);
border-top: 1px solid rgb(var(--primary-low-rgb), 0.5);
}

View File

@ -1,11 +1,11 @@
{
"private": true,
"devDependencies": {
"@discourse/lint-configs": "2.11.1",
"ember-template-lint": "7.0.1",
"eslint": "9.22.0",
"@discourse/lint-configs": "2.23.0",
"ember-template-lint": "7.7.0",
"eslint": "9.28.0",
"prettier": "3.5.3",
"stylelint": "16.16.0"
"stylelint": "16.20.0"
},
"engines": {
"node": ">= 22",

File diff suppressed because it is too large Load Diff