DEV: Fix array-related linting issues in templates (#22935)

and remove more linting exemptions
This commit is contained in:
Jarek Radosz
2023-08-02 19:43:37 +02:00
committed by GitHub
parent cc7dabe20d
commit c5c786b4ac
10 changed files with 25 additions and 23 deletions

View File

@ -5,7 +5,6 @@ module.exports = {
rules: { rules: {
"no-action-modifiers": true, "no-action-modifiers": true,
"no-args-paths": true, "no-args-paths": true,
"no-array-prototype-extensions": false,
"no-attrs-in-components": true, "no-attrs-in-components": true,
"no-capital-arguments": false, // TODO: we extensively use `args` argument name "no-capital-arguments": false, // TODO: we extensively use `args` argument name
"no-curly-component-invocation": { "no-curly-component-invocation": {
@ -22,7 +21,6 @@ module.exports = {
"no-implicit-this": { "no-implicit-this": {
allow: ["loading-spinner"], allow: ["loading-spinner"],
}, },
"no-obscure-array-access": false,
"require-mandatory-role-attributes": false, "require-mandatory-role-attributes": false,
"require-media-caption": false, "require-media-caption": false,
// Begin prettier compatibility // Begin prettier compatibility

View File

@ -23,10 +23,7 @@
<:footer> <:footer>
<DButton <DButton
class="btn-primary" class="btn-primary"
@action={{fn @action={{fn @model.showMergeConfirmation (get this.targetUsername "0")}}
@model.showMergeConfirmation
this.targetUsername.firstObject
}}
@icon="trash-alt" @icon="trash-alt"
@disabled={{this.mergeDisabled}} @disabled={{this.mergeDisabled}}
@translatedLabel={{i18n @translatedLabel={{i18n

View File

@ -11,11 +11,18 @@ export default class AdminUserFieldsController extends Controller {
@service dialog; @service dialog;
fieldTypes = null; fieldTypes = null;
fieldSortOrder = ["position"];
@gte("model.length", MAX_FIELDS) createDisabled; @gte("model.length", MAX_FIELDS) createDisabled;
@sort("model", "fieldSortOrder") sortedFields; @sort("model", "fieldSortOrder") sortedFields;
fieldSortOrder = ["position"]; get firstField() {
return this.sortedFields[0];
}
get lastField() {
return this.sortedFields[this.sortedFields.length - 1];
}
@action @action
createField() { createField() {

View File

@ -8,8 +8,8 @@
<AdminUserFieldItem <AdminUserFieldItem
@userField={{uf}} @userField={{uf}}
@fieldTypes={{this.fieldTypes}} @fieldTypes={{this.fieldTypes}}
@firstField={{this.sortedFields.firstObject}} @firstField={{this.firstField}}
@lastField={{this.sortedFields.lastObject}} @lastField={{this.lastField}}
@destroyAction={{action "destroyField"}} @destroyAction={{action "destroyField"}}
@moveUpAction={{action "moveUp"}} @moveUpAction={{action "moveUp"}}
@moveDownAction={{action "moveDown"}} @moveDownAction={{action "moveDown"}}

View File

@ -29,7 +29,7 @@
{{on "click" (fn this.onCategorySelection (concat "custom-" group))}} {{on "click" (fn this.onCategorySelection (concat "custom-" group))}}
class="btn btn-default category-button emoji" class="btn btn-default category-button emoji"
> >
{{replace-emoji (concat ":" emojis.firstObject.code ":")}} {{replace-emoji (concat ":" (get emojis "0.code") ":")}}
</button> </button>
{{/each-in}} {{/each-in}}
</div> </div>

View File

@ -23,7 +23,7 @@
{{#each this.filteredCategoriesGroupings as |categories|}} {{#each this.filteredCategoriesGroupings as |categories|}}
<div <div
class="sidebar-categories-form__row" class="sidebar-categories-form__row"
style={{html-safe (border-color categories.0.color "left")}} style={{border-color (get categories "0.color") "left"}}
> >
{{#each categories as |category|}} {{#each categories as |category|}}

View File

@ -7,7 +7,7 @@
{{@channel.chatable.users.length}} {{@channel.chatable.users.length}}
</span> </span>
{{else}} {{else}}
<Chat::UserAvatar @user={{@channel.chatable.users.firstObject}} /> <Chat::UserAvatar @user={{get @channel.chatable.users "0"}} />
{{/if}} {{/if}}
</div> </div>
{{/if}} {{/if}}
@ -18,12 +18,12 @@
{{#if this.multiDm}} {{#if this.multiDm}}
<span class="chat-channel-title__name">{{this.usernames}}</span> <span class="chat-channel-title__name">{{this.usernames}}</span>
{{else}} {{else}}
{{#let @channel.chatable.users.firstObject as |user|}} {{#let (get @channel.chatable.users "0") as |user|}}
<span class="chat-channel-title__name">{{user.username}}</span> <span class="chat-channel-title__name">{{user.username}}</span>
{{#if this.showUserStatus}} {{#if this.showUserStatus}}
<UserStatusMessage <UserStatusMessage
@class="chat-channel-title__user-status-message" @class="chat-channel-title__user-status-message"
@status={{@channel.chatable.users.firstObject.status}} @status={{get @channel.chatable.users "0.status"}}
@showDescription={{if this.site.mobileView "true"}} @showDescription={{if this.site.mobileView "true"}}
/> />
{{/if}} {{/if}}

View File

@ -109,7 +109,7 @@
width="18" width="18"
height="18" height="18"
class="emoji" class="emoji"
src={{emojis.firstObject.url}} src={{get emojis "0.url"}}
/> />
{{/if}} {{/if}}
</DButton> </DButton>
@ -177,7 +177,7 @@
</h2> </h2>
<div class="chat-emoji-picker__section-emojis"> <div class="chat-emoji-picker__section-emojis">
{{! we always want the first emoji for tabbing}} {{! we always want the first emoji for tabbing}}
{{#let emojis.firstObject as |emoji|}} {{#let (get emojis "0") as |emoji|}}
<img <img
width="32" width="32"
height="32" height="32"

View File

@ -44,7 +44,7 @@
<StyleguideExample <StyleguideExample
@title="inline-form with <ComboBox>" @title="inline-form with <ComboBox>"
@initialValue={{@dummy.options.0.name}} @initialValue={{get @dummy "options.0.name"}}
as |value| as |value|
> >
<div class="inline-form"> <div class="inline-form">

View File

@ -1,6 +1,6 @@
<StyleguideExample <StyleguideExample
@title="<ComboBox>" @title="<ComboBox>"
@initialValue={{@dummy.options.0.name}} @initialValue={{get @dummy "options.0.name"}}
as |value| as |value|
> >
<ComboBox <ComboBox
@ -12,7 +12,7 @@
<StyleguideExample <StyleguideExample
@title="filterable <ComboBox>" @title="filterable <ComboBox>"
@initialValue={{@dummy.categories.0.name}} @initialValue={{get @dummy "categories.0.name"}}
as |value| as |value|
> >
<ComboBox <ComboBox
@ -25,7 +25,7 @@
<StyleguideExample <StyleguideExample
@title="<ComboBox> with a default state" @title="<ComboBox> with a default state"
@initialValue={{@dummy.options.0.name}} @initialValue={{get @dummy "options.0.name"}}
as |value| as |value|
> >
<ComboBox <ComboBox
@ -38,7 +38,7 @@
<StyleguideExample <StyleguideExample
@title="<ComboBox> clearable" @title="<ComboBox> clearable"
@initialValue={{@dummy.options.0.name}} @initialValue={{get @dummy "options.0.name"}}
as |value| as |value|
> >
<ComboBox <ComboBox
@ -68,7 +68,7 @@
<StyleguideExample <StyleguideExample
@title="<CategoryChooser>" @title="<CategoryChooser>"
@initialValue={{@categories.0.name}} @initialValue={{get @categories "0" "name"}}
as |value| as |value|
> >
<CategoryChooser @value={{value}} @onChange={{fn (mut value)}} /> <CategoryChooser @value={{value}} @onChange={{fn (mut value)}} />
@ -88,7 +88,7 @@
<StyleguideExample @title="<CategoryNotificationsButton>"> <StyleguideExample @title="<CategoryNotificationsButton>">
<CategoryNotificationsButton <CategoryNotificationsButton
@category={{get @dummy.categories 0}} @category={{get @dummy "categories.0"}}
@value={{1}} @value={{1}}
@onChange={{@dummyAction}} @onChange={{@dummyAction}}
/> />