DEV: Update linting setup and fix issues (#17345)

Re-lands #16119 and #17298

* Update eslint-config-discourse
* Update linting workflow
* Prettier-ignore stuff
* Update template-lint config
* Auto-fix template issues
* Fix various template issues
  Mostly incorrect attributes and unused templates
* Prettier js files
* Fix template auto-fix regressions
* Small css tweak

Co-authored-by: Peter Wagenet <peter.wagenet@gmail.com>
This commit is contained in:
Jarek Radosz
2022-07-06 10:37:54 +02:00
committed by GitHub
parent f7c133ac74
commit c3fd91670e
186 changed files with 3235 additions and 3127 deletions
@@ -5,7 +5,8 @@ import I18n from "I18n";
import { bind, observes } from "discourse-common/utils/decorators";
import { on } from "@ember/object/evented";
const COLOR_VARS_REGEX = /\$(primary|secondary|tertiary|quaternary|header_background|header_primary|highlight|danger|success|love)(\s|;|-(low|medium|high))/g;
const COLOR_VARS_REGEX =
/\$(primary|secondary|tertiary|quaternary|header_background|header_primary|highlight|danger|success|love)(\s|;|-(low|medium|high))/g;
export default Component.extend({
mode: "css",
@@ -12,7 +12,7 @@ export default Controller.extend({
"filter",
"siteSettings.dashboard_hidden_reports"
)
filterReports(reports, filter) {
filteredReports(reports, filter) {
if (filter) {
filter = filter.toLowerCase();
reports = reports.filter((report) => {
@@ -32,8 +32,9 @@ export default Route.extend({
actions: {
installModal() {
const currentTheme = this.controllerFor("adminCustomizeThemes.show")
.model;
const currentTheme = this.controllerFor(
"adminCustomizeThemes.show"
).model;
if (currentTheme && currentTheme.warnUnassignedComponent) {
showUnassignedComponentWarning(currentTheme, (result) => {
if (!result) {
@@ -12,8 +12,9 @@ export default DiscourseRoute.extend({
const routeName = "adminUsersList.show";
if (transition.targetName === routeName) {
const params = transition.routeInfos.find((a) => a.name === routeName)
.params;
const params = transition.routeInfos.find(
(a) => a.name === routeName
).params;
const controller = this.controllerFor(routeName);
if (controller) {
controller.setProperties({
@@ -46,9 +46,10 @@ export default Service.extend({
});
controller.setProperties({ postId: opts.postId, postEdit: opts.postEdit });
return (user.adminUserView
? Promise.resolve(user)
: AdminUser.find(user.get("id"))
return (
user.adminUserView
? Promise.resolve(user)
: AdminUser.find(user.get("id"))
).then((loadedUser) => {
controller.setProperties({
user: loadedUser,
@@ -16,7 +16,7 @@
</AdminFormRow>
{{else}}
<AdminFormRow @label="admin.api.description">
<Input @value={{this.model.description}} @maxlength="255" placeholder={{i18n "admin.api.description_placeholder"}} />
<Input @value={{this.model.description}} maxlength="255" placeholder={{i18n "admin.api.description_placeholder"}} />
</AdminFormRow>
<AdminFormRow @label="admin.api.user_mode">
@@ -76,7 +76,7 @@
</td>
<td>
{{#each act.params as |p|}}
<Input @maxlength="255" @value={{get act p}} placeholder={{p}} />
<Input maxlength="255" @value={{get act p}} placeholder={{p}} />
{{/each}}
</td>
</tr>
@@ -11,7 +11,7 @@
<AdminFormRow @label="admin.api.description">
{{#if this.editingDescription}}
<Input @value={{this.buffered.description}} @maxlength="255" placeholder={{i18n "admin.api.description_placeholder"}} />
<Input @value={{this.buffered.description}} maxlength="255" placeholder={{i18n "admin.api.description_placeholder"}} />
{{else}}
<span>
{{if this.model.description this.model.description (i18n "admin.api.no_description")}}
@@ -3,14 +3,14 @@
<div class="control-group">
<label for="name">{{i18n "admin.badges.name"}}</label>
{{#if this.readOnly}}
<Input @type="text" @name="name" @value={{this.buffered.name}} @disabled={{true}} />
<Input @type="text" name="name" @value={{this.buffered.name}} disabled={{true}} />
<p class="help">
<LinkTo @route="adminSiteText" @query={{hash q=(concat this.textCustomizationPrefix "name")}}>
{{i18n "admin.badges.read_only_setting_help"}}
</LinkTo>
</p>
{{else}}
<Input @type="text" @name="name" @value={{this.buffered.name}} />
<Input @type="text" name="name" @value={{this.buffered.name}} />
{{/if}}
</div>
@@ -56,28 +56,28 @@
<div class="control-group">
<label for="description">{{i18n "admin.badges.description"}}</label>
{{#if this.buffered.system}}
<Textarea @name="description" @value={{this.buffered.description}} @disabled={{true}} />
<Textarea name="description" @value={{this.buffered.description}} disabled={{true}} />
<p class="help">
<LinkTo @route="adminSiteText" @query={{hash q=(concat this.textCustomizationPrefix "description")}}>
{{i18n "admin.badges.read_only_setting_help"}}
</LinkTo>
</p>
{{else}}
<Textarea @name="description" @value={{this.buffered.description}} />
<Textarea name="description" @value={{this.buffered.description}} />
{{/if}}
</div>
<div class="control-group">
<label for="long_description">{{i18n "admin.badges.long_description"}}</label>
{{#if this.buffered.system}}
<Textarea @name="long_description" @value={{this.buffered.long_description}} @disabled={{true}} />
<Textarea name="long_description" @value={{this.buffered.long_description}} disabled={{true}} />
<p class="help">
<LinkTo @route="adminSiteText" @query={{hash q=(concat this.textCustomizationPrefix "long_description")}}>
{{i18n "admin.badges.read_only_setting_help"}}
</LinkTo>
</p>
{{else}}
<Textarea @name="long_description" @value={{this.buffered.long_description}} />
<Textarea name="long_description" @value={{this.buffered.long_description}} />
{{/if}}
</div>
@@ -97,14 +97,14 @@
<div class="control-group">
<label>
<Input @type="checkbox" @checked={{this.buffered.auto_revoke}} @disabled={{this.readOnly}} />
<Input @type="checkbox" @checked={{this.buffered.auto_revoke}} disabled={{this.readOnly}} />
{{i18n "admin.badges.auto_revoke"}}
</label>
</div>
<div class="control-group">
<label>
<Input @type="checkbox" @checked={{this.buffered.target_posts}} @disabled={{this.readOnly}} />
<Input @type="checkbox" @checked={{this.buffered.target_posts}} disabled={{this.readOnly}} />
{{i18n "admin.badges.target_posts"}}
</label>
</div>
@@ -128,21 +128,21 @@
<div>
<label>
<Input @type="checkbox" @checked={{this.buffered.multiple_grant}} @disabled={{this.readOnly}} />
<Input @type="checkbox" @checked={{this.buffered.multiple_grant}} disabled={{this.readOnly}} />
{{i18n "admin.badges.multiple_grant"}}
</label>
</div>
<div>
<label>
<Input @type="checkbox" @checked={{this.buffered.listable}} @disabled={{this.readOnly}} />
<Input @type="checkbox" @checked={{this.buffered.listable}} disabled={{this.readOnly}} />
{{i18n "admin.badges.listable"}}
</label>
</div>
<div>
<label>
<Input @type="checkbox" @checked={{this.buffered.show_posts}} @disabled={{this.readOnly}} />
<Input @type="checkbox" @checked={{this.buffered.show_posts}} disabled={{this.readOnly}} />
{{i18n "admin.badges.show_posts"}}
</label>
</div>
@@ -3,7 +3,7 @@
<ul class="nav nav-pills target">
{{#each this.visibleTargets as |target|}}
<li>
<LinkTo @route={{this.editRouteName}} @models={{array this.theme.id target.name this.fieldName}} @replace={{true}} @title={{this.field.title}} class={{if target.edited "edited" "blank"}}>
<LinkTo @route={{this.editRouteName}} @models={{array this.theme.id target.name this.fieldName}} @replace={{true}} title={{this.field.title}} class={{if target.edited "edited" "blank"}}>
{{#if target.error}}{{d-icon "exclamation-triangle"}}{{/if}}
{{#if target.icon}}{{d-icon target.icon}}{{/if}}
{{i18n (concat "admin.customize.theme." target.name)}}
@@ -24,7 +24,7 @@
<li class="spacer"></li>
<li>
<label>
<Input @type="checkbox" @checked={{this.onlyOverridden}} @click={{action "onlyOverriddenChanged" value="target.checked"}} />
<Input @type="checkbox" @checked={{this.onlyOverridden}} {{on "click" (action "onlyOverriddenChanged" value="target.checked")}} />
{{i18n "admin.customize.theme.hide_unused_fields"}}
</label>
</li>
@@ -37,7 +37,7 @@
<ul class="nav nav-pills fields">
{{#each this.visibleFields as |field|}}
<li>
<LinkTo @route={{this.editRouteName}} @models={{array this.theme.id this.currentTargetName field.name}} @replace={{true}} @title={{field.title}} class={{if field.edited "edited" "blank"}}>
<LinkTo @route={{this.editRouteName}} @models={{array this.theme.id this.currentTargetName field.name}} @replace={{true}} title={{field.title}} class={{if field.edited "edited" "blank"}}>
{{#if field.error}}{{d-icon "exclamation-triangle"}}{{/if}}
{{#if field.icon}}{{d-icon field.icon}}{{/if}}
{{field.translatedName}}
@@ -5,11 +5,11 @@
</AdminFormRow>
<AdminFormRow @label="admin.user_fields.name">
<Input @value={{this.buffered.name}} class="user-field-name" @maxlength="255" />
<Input @value={{this.buffered.name}} class="user-field-name" maxlength="255" />
</AdminFormRow>
<AdminFormRow @label="admin.user_fields.description">
<Input @value={{this.buffered.description}} class="user-field-desc" @maxlength="255" />
<Input @value={{this.buffered.description}} class="user-field-desc" maxlength="255" />
</AdminFormRow>
{{#if this.bufferedFieldType.hasOptions}}
@@ -1,3 +1,3 @@
<Input @id={{this.typeName}} @type="checkbox" @name="event-choice" @checked={{this.enabled}} />
<Input id={{this.typeName}} @type="checkbox" name="event-choice" @checked={{this.enabled}} />
<label for={{this.typeName}}>{{this.name}}</label>
<p>{{this.details}}</p>
@@ -1,7 +1,7 @@
{{#if this.editing}}
<td class="editing-input">
<div class="label">{{i18n "admin.embedding.host"}}</div>
<Input @value={{this.buffered.host}} placeholder="example.com" @enter={{action "save"}} class="host-name" @autofocus={{true}} />
<Input @value={{this.buffered.host}} placeholder="example.com" @enter={{action "save"}} class="host-name" autofocus={{true}} />
</td>
<td class="editing-input">
<div class="label">{{i18n "admin.embedding.class_name"}}</div>
@@ -1,11 +1,11 @@
{{#if this.isCheckbox}}
<label for={{this.inputId}}>
<Input @checked={{this.checked}} @id={{this.inputId}} @type="checkbox" />
<Input @checked={{this.checked}} id={{this.inputId}} @type="checkbox" />
{{i18n this.translationKey}}
</label>
{{else}}
<label for={{this.inputId}}>{{i18n this.translationKey}}</label>
<Input @value={{this.value}} @id={{this.inputId}} placeholder={{this.placeholder}} />
<Input @value={{this.value}} id={{this.inputId}} placeholder={{this.placeholder}} />
{{/if}}
<div class="clearfix"></div>
@@ -1,5 +1,5 @@
<label class="checkbox-label">
<Input @type="checkbox" @disabled={{this.disabled}} @checked={{this.buffer}} />
<Input @type="checkbox" disabled={{this.disabled}} @checked={{this.buffer}} />
{{i18n this.labelKey}}
</label>
{{#if this.changed}}
@@ -1 +1 @@
<Input @type="checkbox" @checked={{this.checked}} @click={{action "onChange"}} />
<Input @type="checkbox" @checked={{this.checked}} {{on "click" (action "onChange")}} />
@@ -3,8 +3,8 @@
{{#each this.collection as |value index|}}
<div class="value" data-index={{index}}>
<DButton @action={{action "removeValue"}} @actionParam={{value}} @icon="times" @class="remove-value-btn btn-small" />
<Input @value={{value.key}} class="value-input" @focus-out={{action "changeKey" index}} />
<Input @value={{value.secret}} class="value-input" @focus-out={{action "changeSecret" index}} @type={{if this.isSecret "password" "text"}} />
<Input @value={{value.key}} class="value-input" {{on "focusout" (action "changeKey" index)}} />
<Input @value={{value.secret}} class="value-input" @type={{if this.isSecret "password" "text"}} {{on "focusout" (action "changeSecret" index)}} />
</div>
{{/each}}
</div>
@@ -4,21 +4,19 @@
<div data-index={{index}} class="value">
<DButton @action={{action "removeValue"}} @actionParam={{value}} @icon="times" @class="remove-value-btn btn-small" />
<Input @title={{value}} @value={{value}} class="value-input" @focus-out={{action "changeValue" index}} />
<Input title={{value}} @value={{value}} class="value-input" {{on "focusout" (action "changeValue" index)}} />
{{#if this.showUpDownButtons}}
<DButton @action={{action "shift" -1 index}} @icon="arrow-up" @class="shift-up-value-btn btn-small" />
<DButton @action={{action "shift" 1 index}} @icon="arrow-down" @class="shift-down-value-btn btn-small" />
{{/if}}
</div>
{{/each}}
</div>
{{/if}}
<div class="simple-list-input">
<Input @type="text" @value={{this.newValue}} @placeholderKey="admin.site_settings.simple_list.add_item" class="add-value-input" @autocomplete="off" @autocorrect="off" @autocapitalize="off" />
<Input @type="text" @value={{this.newValue}} placeholder={{i18n "admin.site_settings.simple_list.add_item"}} class="add-value-input" autocomplete="off" autocorrect="off" autocapitalize="off" />
<DButton @action={{action "addValue"}} @actionParam={{this.newValue}} @disabled={{this.inputEmpty}} @icon="plus" @class="add-value-btn btn-small" />
</div>
@@ -2,7 +2,7 @@
<h3>
{{#if this.staffLogFilter}}
{{this.settingName}}
<LinkTo @route="adminLogs.staffActionLogs" @query={{hash filters=this.staffLogFilter force_refresh=true}} @title={{i18n "admin.settings.history"}}>
<LinkTo @route="adminLogs.staffActionLogs" @query={{hash filters=this.staffLogFilter force_refresh=true}} title={{i18n "admin.settings.history"}}>
<span class="history-icon">
{{d-icon "history"}}
</span>
@@ -1,9 +1,9 @@
{{#if this.setting.textarea}}
<Textarea @value={{this.value}} @classNames="input-setting-textarea" />
<Textarea @value={{this.value}} class="input-setting-textarea" />
{{else if this.setting.json_schema}}
<DButton @action={{action "launchJsonEditorModal"}} @icon="pencil-alt" @label="admin.site_settings.json_schema.edit" />
{{else if this.isSecret}}
<Input @type="password" @value={{this.value}} @classNames="input-setting-string" />
<Input @type="password" @value={{this.value}} class="input-setting-string" />
{{else}}
<TextField @value={{this.value}} @classNames="input-setting-string" />
{{/if}}
@@ -1,4 +1,4 @@
{{!-- template-lint-disable no-invalid-interactive --}}
<div class="table staff-actions" {{on "click" (fn this.openLinks)}}>
<div class="table staff-actions" {{on "click" this.openLinks}}>
{{yield}}
</div>
@@ -6,7 +6,7 @@
<div class="themes-list-container">
{{#if this.showFilter}}
<div class="themes-list-filter themes-list-item">
<Input class="filter-input" placeholder={{i18n "admin.customize.theme.filter_placeholder"}} @autocomplete="off" @type="search" @value={{mut this.filterTerm}} />
<Input class="filter-input" placeholder={{i18n "admin.customize.theme.filter_placeholder"}} autocomplete="off" @type="search" @value={{mut this.filterTerm}} />
{{d-icon "search"}}
</div>
{{/if}}
@@ -4,7 +4,7 @@
<div data-index={{index}} class="value">
<DButton @action={{action "removeValue"}} @actionParam={{value}} @icon="times" @class="remove-value-btn btn-small" />
<Input @title={{value}} @value={{value}} class="value-input" @focus-out={{action "changeValue" index}} />
<Input title={{value}} @value={{value}} class="value-input" {{on "focusout" (action "changeValue" index)}} />
{{#if this.showUpDownButtons}}
<DButton @action={{action "shift" -1 index}} @icon="arrow-up" @class="shift-up-value-btn btn-small" />
@@ -22,8 +22,8 @@
{{#if this.canLink}}
<div class="watched-word-input">
<label for="watched-replacement">{{i18n "admin.watched_words.form.link_label"}}</label>
<TextField @id="watched-replacement" @value={{this.replacement}} @disabled={{this.formSubmitted}} @class="watched-word-input-field" @autocorrect="off" @autocapitalize="off" @placeholderKey="admin.watched_words.form.link_placeholder" />
<label for="watched-link">{{i18n "admin.watched_words.form.link_label"}}</label>
<TextField @id="watched-link" @value={{this.replacement}} @disabled={{this.formSubmitted}} @class="watched-word-input-field" @autocorrect="off" @autocapitalize="off" @placeholderKey="admin.watched_words.form.link_placeholder" />
</div>
{{/if}}
@@ -2,11 +2,11 @@
<div class="reports-index section">
<div class="section-title">
<h2>{{i18n "admin.reports.title"}}</h2>
<Input class="filter-reports-input" @input={{action "filterReports" value="target.value"}} placeholder={{i18n "admin.dashboard.filter_reports"}} @autofocus={{true}} />
<Input class="filter-reports-input" placeholder={{i18n "admin.dashboard.filter_reports"}} autofocus={{true}} {{on "input" (action "filterReports" value="target.value")}} />
</div>
<ul class="reports-list">
{{#each this.filterReports as |report|}}
{{#each this.filteredReports as |report|}}
<li class="report">
<LinkTo @route="adminReports.show" @model={{report.type}}>
<h3 class="report-title">{{report.title}}</h3>
@@ -2,7 +2,7 @@
<div class="email-advanced-test">
<label for="email">{{i18n "admin.email.advanced_test.email"}}</label>
<Textarea @name="email" @value={{this.email}} class="email-body" /> <DButton @action={{action "run"}} @label="admin.email.advanced_test.run" />
<Textarea name="email" @value={{this.email}} class="email-body" /> <DButton @action={{action "run"}} @label="admin.email.advanced_test.run" />
</div>
<ConditionalLoadingSpinner @condition={{this.loading}}>
@@ -1,7 +1,7 @@
<p>
{{i18n "admin.logs.screened_urls.description"}}
</p>
<DButton @class="btn-default" @action={{action "exportScreenedUrlList"}} @title="admin.export_csv.button_title.screened_url" @icon="download" @label="admin.export_csv.button_text" />
<DButton @class="btn-default" @action={{action "exportScreenedUrlList"}} @title="admin.export_csv.button_title.screened_url" @icon="download" @label="admin.export_csv.button_text" />
<br>
<ConditionalLoadingSpinner @condition={{this.loading}}>
@@ -6,7 +6,7 @@
</section>
<section class="field">
<label for="theme-variable-name">{{i18n "admin.customize.theme.variable_name"}}</label>
<Input @id="theme-variable-name" @value={{this.name}} />
<Input id="theme-variable-name" @value={{this.name}} />
</section>
{{#if this.fileSelected}}
{{#if this.errorMessage}}
@@ -14,7 +14,7 @@
<div class="control-group">
<label>{{i18n "admin.email.incoming_emails.modal.headers"}}</label>
<div class="controls">
<Textarea @value={{this.model.headers}} @wrap="off" />
<Textarea @value={{this.model.headers}} wrap="off" />
</div>
</div>
@@ -72,7 +72,7 @@
<div class="public-key">
<div class="label">{{i18n "admin.customize.theme.public_key"}}</div>
<div class="public-key-text-wrapper">
<Textarea class="public-key-value" @readonly={{true}} @value={{this.publicKey}} /> <CopyButton @selector="textarea.public-key-value" />
<Textarea class="public-key-value" readonly={{true}} @value={{this.publicKey}} /> <CopyButton @selector="textarea.public-key-value" />
</div>
</div>
{{else}}
@@ -1,6 +1,6 @@
<DModalBody @rawTitle={{i18n "admin.watched_words.test.modal_title" action=this.model.name}} @class="watched-words-test-modal">
<p>{{i18n "admin.watched_words.test.description"}}</p>
<Textarea @name="test_value" @value={{this.value}} @autofocus="autofocus" />
<Textarea name="test_value" @value={{this.value}} autofocus="autofocus" />
{{#if this.matches}}
<p>
{{i18n "admin.watched_words.test.found_matches"}}
@@ -14,7 +14,7 @@
</div>
<label>
<Input @type="checkbox" @checked={{this.overridden}} @click={{action "toggleOverridden"}} />
<Input @type="checkbox" @checked={{this.overridden}} {{on "click" (action "toggleOverridden")}} />
{{i18n "admin.site_text.show_overriden"}}
</label>
</p>
@@ -22,7 +22,7 @@
{{#if this.currentAction.words}}
<label class="show-words-checkbox">
<Input @type="checkbox" @checked={{this.adminWatchedWords.showWords}} @disabled={{this.adminWatchedWords.disableShowWords}} />
<Input @type="checkbox" @checked={{this.adminWatchedWords.showWords}} disabled={{this.adminWatchedWords.disableShowWords}} />
{{i18n "admin.watched_words.show_words" count=this.currentAction.words.length}}
</label>
{{/if}}
@@ -1,9 +1,9 @@
<div class="web-hook-direction">
<LinkTo @route="adminWebHooks" @tagName="button" @classNames="btn">
<LinkTo @route="adminWebHooks" class="btn">
{{d-icon "list"}} {{i18n "admin.web_hooks.events.go_list"}}
</LinkTo>
<DButton @icon="paper-plane" @label="admin.web_hooks.events.ping" @action={{action "ping"}} @disabled={{this.pingDisabled}} />
<LinkTo @route="adminWebHooks.show" @model={{this.model.extras.web_hook_id}} @tagName="button" @classNames="btn">
<LinkTo @route="adminWebHooks.show" @model={{this.model.extras.web_hook_id}} class="btn">
{{d-icon "far-edit"}} {{i18n "admin.web_hooks.events.go_details"}}
</LinkTo>
</div>
@@ -66,11 +66,11 @@
<PluginOutlet @name="web-hook-fields" @tagName="span" @connectorTagName="div" @args={{hash model=this.model}} />
<div>
<Input @type="checkbox" @name="verify_certificate" @checked={{this.model.verify_certificate}} /> {{i18n "admin.web_hooks.verify_certificate"}}
<Input @type="checkbox" name="verify_certificate" @checked={{this.model.verify_certificate}} /> {{i18n "admin.web_hooks.verify_certificate"}}
</div>
<div>
<div>
<Input @type="checkbox" @name="active" @checked={{this.model.active}} /> {{i18n "admin.web_hooks.active"}}
<Input @type="checkbox" name="active" @checked={{this.model.active}} /> {{i18n "admin.web_hooks.active"}}
</div>
{{#if this.model.active}}
<div class="instructions">{{i18n "admin.web_hooks.active_notice"}}</div>
@@ -1,7 +1,7 @@
<div class="web-hooks-listing">
<p>{{i18n "admin.web_hooks.instruction"}}</p>
<div class="new-webhook">
<LinkTo @route="adminWebHooks.show" @model="new" @tagName="button" @classNames="btn btn-default">
<LinkTo @route="adminWebHooks.show" @model="new" class="btn btn-default">
{{d-icon "plus"}} {{i18n "admin.web_hooks.new"}}
</LinkTo>
</div>
@@ -23,7 +23,7 @@
<td class="payload-url"><LinkTo @route="adminWebHooks.show" @model={{webHook}}>{{webHook.payload_url}}</LinkTo></td>
<td class="description">{{webHook.description}}</td>
<td class="controls">
<LinkTo @route="adminWebHooks.show" @model={{webHook}} @tagName="button" @classNames="btn btn-default no-text">{{d-icon "far-edit"}}</LinkTo>
<LinkTo @route="adminWebHooks.show" @model={{webHook}} class="btn btn-default no-text">{{d-icon "far-edit"}}</LinkTo>
<DButton @class="destroy btn-danger" @action={{action "destroy"}} @actionParam={{webHook}} @icon="times" />
</td>
</tr>