Skip to content

Commit

Permalink
eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
klaascuvelier committed Jan 1, 2025
1 parent b607313 commit 5b9c1c7
Show file tree
Hide file tree
Showing 45 changed files with 220 additions and 146 deletions.
2 changes: 1 addition & 1 deletion src/accordion/accordion-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
display: list-item;
}
`],
changeDetection: ChangeDetectionStrategy.OnPush
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AccordionItem {
static accordionItemCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/breadcrumb/breadcrumb-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Router } from "@angular/router";
<ng-container *ngTemplateOutlet="content" />
}
`,
changeDetection: ChangeDetectionStrategy.OnPush
changeDetection: ChangeDetectionStrategy.OnPush
})
export class BreadcrumbItemComponent {
@Input() set href(v: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/breadcrumb/breadcrumb.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const MINIMUM_OVERFLOW_THRESHOLD = 4;
}
</nav>
`,
changeDetection: ChangeDetectionStrategy.OnPush
changeDetection: ChangeDetectionStrategy.OnPush
})
export class Breadcrumb implements AfterContentInit {
@ContentChildren(BreadcrumbItemComponent) children: QueryList<BreadcrumbItemComponent>;
Expand Down
6 changes: 3 additions & 3 deletions src/checkbox/checkbox-exported-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class CheckboxExportedTests extends ComponentTests {
afterClickState
});
}),
runComparison: results => {
// eslint-disable-next-line no-unused-expressions
runComparison: results => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
expect(results.initialState).to.be.false;
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
expect(results.afterClickState).to.be.true;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/checkbox/stories/reactive-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class ReactiveFormsStory implements OnInit {
toggleDisable() {
const checkbox = this.formGroup.get("checkbox");
if (checkbox != null) {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
checkbox.disabled ? checkbox.enable() : checkbox.disable();
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/code-snippet/code-snippet.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export enum SnippetType {
}
}
@if (!skeleton) {
<pre #codeContent (scroll)="(display === 'multi' ? handleScroll() : null)"><code #code><ng-container *ngTemplateOutlet="codeTemplate" /></code></pre>
<pre
#codeContent
(scroll)="(display === 'multi' ? handleScroll() : null)"
>
<code #code><ng-container *ngTemplateOutlet="codeTemplate" /></code>
</pre>
}
</div>
@if (hasLeft) {
Expand All @@ -85,7 +90,12 @@ export enum SnippetType {
(click)="toggleSnippetExpansion()"
type="button">
<span class="cds--snippet-btn--text">{{expanded ? translations.SHOW_LESS : translations.SHOW_MORE}}</span>
<svg cdsIcon="chevron--down" size="16" class="cds--icon-chevron--down" [attr.aria-label]="translations.SHOW_MORE_ICON"></svg>
<svg
cdsIcon="chevron--down"
size="16"
class="cds--icon-chevron--down"
[attr.aria-label]="translations.SHOW_MORE_ICON"
></svg>
</button>
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/common/tab.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export let tabbableSelector = "a[href], area[href], input:not([disabled]):not([tabindex=\'-1\']), " +
"button:not([disabled]):not([tabindex=\'-1\']),select:not([disabled]):not([tabindex=\'-1\']), " +
"textarea:not([disabled]):not([tabindex=\'-1\']), " +
"iframe, object, embed, *[tabindex]:not([tabindex=\'-1\']), *[contenteditable=true]";
export let tabbableSelector = "a[href], area[href], input:not([disabled]):not([tabindex='-1']), " +
"button:not([disabled]):not([tabindex='-1']),select:not([disabled]):not([tabindex='-1']), " +
"textarea:not([disabled]):not([tabindex='-1']), " +
"iframe, object, embed, *[tabindex]:not([tabindex='-1']), *[contenteditable=true]";

export let tabbableSelectorIgnoreTabIndex = "a[href], area[href], input:not([disabled]), " +
"button:not([disabled]),select:not([disabled]), " +
Expand Down
6 changes: 4 additions & 2 deletions src/contained-list/contained-list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ describe("ContainedList", () => {
const wrapperFixture: ComponentFixture<WrapperComponent> = TestBed.createComponent(WrapperComponent);
wrapperFixture.detectChanges();

const actionElementRef = wrapperFixture.nativeElement.querySelector(".cds--contained-list .cds--contained-list__action ibm-icon-button");
const actionElementRef = wrapperFixture.nativeElement
.querySelector(".cds--contained-list .cds--contained-list__action ibm-icon-button");
expect(actionElementRef).toBeTruthy();
});
});
Expand All @@ -141,7 +142,8 @@ describe("ContainedList", () => {
const wrapperFixture: ComponentFixture<WrapperComponent> = TestBed.createComponent(WrapperComponent);
wrapperFixture.detectChanges();

const iconElement = wrapperFixture.debugElement.query(By.css(".cds--contained-list-item:nth-child(3) svg[ng-reflect-ibm-icon='apple']"));
const iconElement = wrapperFixture.debugElement
.query(By.css(".cds--contained-list-item:nth-child(3) svg[ng-reflect-ibm-icon='apple']"));
expect(iconElement).toBeTruthy();
});

Expand Down
7 changes: 6 additions & 1 deletion src/contained-list/contained-list.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ const usageExamplesTemplate = () => ({
</ng-template>
<ng-template #overflowMenu let-item>
<ibm-tooltip class="cds--icon-tooltip" description="Options" align="left">
<ibm-overflow-menu [flip]="true" [customTrigger]="customTrigger" triggerClass="cds--toolbar-action" [offset]="{ x: 0, y: 0 }">
<ibm-overflow-menu
[flip]="true"
[customTrigger]="customTrigger"
triggerClass="cds--toolbar-action"
[offset]="{ x: 0, y: 0 }"
>
<ibm-overflow-menu-option>View details</ibm-overflow-menu-option>
<ibm-overflow-menu-option>Edit</ibm-overflow-menu-option>
<ibm-overflow-menu-option [divider]="true" type="danger">Remove</ibm-overflow-menu-option>
Expand Down
2 changes: 1 addition & 1 deletion src/context-menu/context-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class ContextMenuComponent implements OnChanges {
const menuItems: HTMLElement[] = (
Array.from(list.querySelectorAll(".cds--menu-item")) as HTMLElement[])
.filter(menuItem => !subMenus.some(subMenu => subMenu.contains(menuItem))
);
);
const currentIndex = menuItems.findIndex(menuItem => parseInt(menuItem.getAttribute("tabindex"), 10) === 0);
const currentMenuItem = menuItems[currentIndex];

Expand Down
1 change: 1 addition & 0 deletions src/datepicker/carbon-flatpickr-month-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const carbonFlatpickrMonthSelectPlugin = fp => {
0,
fp.monthElements.length,
...fp.monthElements.map(() => {
// eslint-disable-next-line no-underscore-dangle
const monthElement = fp._createElement(
"span",
config.classFlatpickrCurrentMonth
Expand Down
4 changes: 2 additions & 2 deletions src/datepicker/datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ export class DatePicker implements
singleDate = this.flatpickrInstance.parseDate(this.flatpickrInstance.selectedDates[0], this.dateFormat);
singleDate = this.flatpickrInstance.formatDate(singleDate, this.dateFormat);
// if date is not a string we can assume it's a Date and we should format
} else if (!!this.flatpickrInstance.selectedDates[0]) {
} else if (this.flatpickrInstance.selectedDates[0]) {
singleDate = this.flatpickrInstance.formatDate(this.flatpickrInstance.selectedDates[0], this.dateFormat);
}

Expand All @@ -655,7 +655,7 @@ export class DatePicker implements
rangeDate = this.flatpickrInstance.parseDate(this.flatpickrInstance.selectedDates[1].toString(), this.dateFormat);
rangeDate = this.flatpickrInstance.formatDate(rangeDate, this.dateFormat);
// if date is not a string we can assume it's a Date and we should format
} else if (!!this.flatpickrInstance.selectedDates[1]) {
} else if (this.flatpickrInstance.selectedDates[1]) {
rangeDate = this.flatpickrInstance.formatDate(this.flatpickrInstance.selectedDates[1], this.dateFormat);
}
setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class Dialog implements OnInit, AfterViewInit, OnDestroy {
});
}
}
);
);
}

this.placeDialog();
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/overflow-menu/overflow-menu-option.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class OverflowMenuOption implements AfterViewInit {
@Input() set target(value: Target) {
if (!Object.values(Target).includes(value)) {
console.warn(
`\`target\` must have one of the following values: ${Object.values(Target).join(", ")}.
`\`target\` must have one of the following values: ${Object.values(Target).join(", ")}.
Please use the \`Target\` enum exported by carbon-components-angular`);
return;
}
Expand Down
14 changes: 11 additions & 3 deletions src/dialog/overflow-menu/overflow-menu.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
})
],
args: {
placement: "bottom"
placement: "bottom"
},
argTypes: {
code: {
Expand Down Expand Up @@ -87,10 +87,18 @@ const LinkTemplate = (args) => ({
<cds-overflow-menu-option href="https://www.ibm.com" (selected)="selected($event)" (click)="click($event)">
An example option that is really long to show what should be done to handle long text
</cds-overflow-menu-option>
<cds-overflow-menu-option href="https://www.ibm.com" target="_blank" (selected)="selected($event)">Option 2</cds-overflow-menu-option>
<cds-overflow-menu-option
href="https://www.ibm.com"
target="_blank"
(selected)="selected($event)"
>Option 2</cds-overflow-menu-option>
<cds-overflow-menu-option href="https://www.ibm.com" (selected)="selected($event)">Option 3</cds-overflow-menu-option>
<cds-overflow-menu-option href="https://www.ibm.com" (selected)="selected($event)">Option 4</cds-overflow-menu-option>
<cds-overflow-menu-option href="https://www.ibm.com" disabled="true" (selected)="selected($event)">Disabled</cds-overflow-menu-option>
<cds-overflow-menu-option
href="https://www.ibm.com"
disabled="true"
(selected)="selected($event)"
>Disabled</cds-overflow-menu-option>
<cds-overflow-menu-option href="https://www.ibm.com" type="danger" (selected)="selected($event)">
Danger option
</cds-overflow-menu-option>
Expand Down
20 changes: 10 additions & 10 deletions src/dropdown/list/dropdown-list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { I18nModule } from "../../i18n/index";
})
class DropdownListTest {
items = [
<ListItem>{content: "one", selected: false},
<ListItem>{content: "two", selected: false}
({content: "one", selected: false} as ListItem),
({content: "two", selected: false} as ListItem)
];
selected: ListItem;
onSelect(ev) {
Expand All @@ -26,8 +26,8 @@ class DropdownListTest {
})
class MultiTest {
items = [
<ListItem>{content: "one", selected: false},
<ListItem>{content: "two", selected: false}
({content: "one", selected: false} as ListItem),
({content: "two", selected: false} as ListItem)
];
selected: ListItem[];
onSelect(ev) {
Expand Down Expand Up @@ -71,9 +71,9 @@ describe("Dropdown list", () => {

it("should disable a list-item", () => {
wrapper.items = [
<ListItem>{content: "one", selected: false},
<ListItem>{content: "two", selected: false, disabled: false},
<ListItem>{content: "three", selected: false, disabled: true}
({content: "one", selected: false} as ListItem),
({content: "two", selected: false, disabled: false} as ListItem),
({content: "three", selected: false, disabled: true} as ListItem)
];
fixture.detectChanges();
const disabledEls = fixture.debugElement.queryAll(By.css(".cds--list-box__menu-item[disabled]"));
Expand Down Expand Up @@ -126,9 +126,9 @@ describe("Dropdown multi list", () => {

it("should disable a list-item and its checkbox", () => {
wrapper.items = [
<ListItem>{content: "one", selected: false},
<ListItem>{content: "two", selected: false, disabled: false},
<ListItem>{content: "three", selected: false, disabled: true}
({content: "one", selected: false} as ListItem),
({content: "two", selected: false, disabled: false} as ListItem),
({content: "three", selected: false, disabled: true} as ListItem)
];
fixture.detectChanges();
const disabledEls = fixture.debugElement.queryAll(By.css(".cds--list-box__menu-item[disabled]"));
Expand Down
2 changes: 1 addition & 1 deletion src/file-uploader/file-uploader.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("FileUploader", () => {
it("should only accept .txt files", () => {
fixture = TestBed.createComponent(FileUploaderTest);
fixture.detectChanges();
element = fixture.debugElement.query(By.css("cds-file-uploader"));
element = fixture.debugElement.query(By.css("cds-file-uploader"));
expect(element.nativeElement.querySelector(".cds--file-input").getAttribute("accept")).toEqual(".txt");
});

Expand Down
2 changes: 1 addition & 1 deletion src/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class Overridable {
/**
* An object of strings, should follow the same format as src/i18n/en.json
*/
export type TranslationStrings = { [key: string]: string };
export interface TranslationStrings { [key: string]: string }


/**
Expand Down
2 changes: 1 addition & 1 deletion src/index.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ import { IconModule } from "./icon/icon.module";
</div>
</section>
`,
/* eslint-disable max-len */

styles: [`
.overview-page__banner {
height: 100vh;
Expand Down
2 changes: 1 addition & 1 deletion src/input/label.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class Label implements AfterContentInit, AfterViewInit {
@ContentChild(TextInput, { static: false }) textInput: TextInput;

@ContentChild(PasswordInput, { static: false })
passwordInput: PasswordInput;
passwordInput: PasswordInput;

@HostBinding("class.cds--form-item") get labelClass() {
return this.type === undefined;
Expand Down
1 change: 1 addition & 0 deletions src/layer/layer.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class LayerDirective implements AfterContentInit {
if (layer === this) {
return;
}
// eslint-disable-next-line no-underscore-dangle
layer.layer = typeof layer._passedLevel === "number" ? layer._passedLevel : this.layer + 1;
});
}
Expand Down
11 changes: 9 additions & 2 deletions src/modal/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ import { BaseModalService } from "./base-modal.service";
<cds-modal-header (closeSelect)="closeModal()">Header text</cds-modal-header>
<section class="modal-body">
<h1>Sample modal works.</h1>
<button class="btn--icon-link" nPopover="Hello there" title="Popover title" placement="right" appendInline="true">
<button
class="btn--icon-link"
nPopover="Hello there"
title="Popover title"
placement="right"
appendInline="true"
>
<svg cdsIcon="info" size="sm"></svg>
</button>
{{modalText}}
Expand Down Expand Up @@ -134,7 +140,8 @@ export class Modal implements AfterViewInit, OnChanges, OnDestroy {
@Input() hasScrollingContent: boolean = null;

/**
* Emits event when click occurs within `n-overlay` element. This is to track click events occurring outside bounds of the `Modal` object.
* Emits event when click occurs within `n-overlay` element.
* This is to track click events occurring outside bounds of the `Modal` object.
*/
@Output() overlaySelected = new EventEmitter();
/**
Expand Down
8 changes: 6 additions & 2 deletions src/notification/actionable-notification.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ export class ActionableNotification extends BaseNotification {
@HostBinding("class.cds--actionable-notification--toast") get toastVariant() { return this.notificationObj.variant === "toast"; }
@HostBinding("class.cds--actionable-notification--error") get isError() { return this.notificationObj.type === "error"; }
@HostBinding("class.cds--actionable-notification--info") get isInfo() { return this.notificationObj.type === "info"; }
@HostBinding("class.cds--actionable-notification--info-square") get isInfoSquare() { return this.notificationObj.type === "info-square"; }
@HostBinding("class.cds--actionable-notification--info-square") get isInfoSquare() {
return this.notificationObj.type === "info-square";
}
@HostBinding("class.cds--actionable-notification--success") get isSuccess() { return this.notificationObj.type === "success"; }
@HostBinding("class.cds--actionable-notification--warning") get isWarning() { return this.notificationObj.type === "warning"; }
@HostBinding("class.cds--actionable-notification--warning-alt") get isWarningAlt() { return this.notificationObj.type === "warning-alt"; }
@HostBinding("class.cds--actionable-notification--warning-alt") get isWarningAlt() {
return this.notificationObj.type === "warning-alt";
}
@HostBinding("class.cds--actionable-notification--low-contrast") get isLowContrast() { return this.notificationObj.lowContrast; }
@HostBinding("class.cds--actionable-notification--hide-close-button") get isCloseHidden() { return !this._notificationObj.showClose; }

Expand Down
2 changes: 1 addition & 1 deletion src/number-input/number.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export class NumberComponent implements ControlValueAccessor {
}

handleFocus(event: FocusEvent) {
if ("type" in event.target && (<HTMLInputElement>event.target).type === "button") {
if ("type" in event.target && (event.target as HTMLInputElement).type === "button") {
this._isFocused = false;
} else {
this._isFocused = event.type === "focus";
Expand Down
6 changes: 3 additions & 3 deletions src/pagination/pagination-nav/pagination-nav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface PaginationNavTranslations {
<cds-pagination-nav-item
page="1"
(click)="currentPage = 1"
[isActive]="currentPage == 1">
[isActive]="currentPage === 1">
</cds-pagination-nav-item>
}
@if (frontCuts) {
Expand All @@ -81,7 +81,7 @@ export interface PaginationNavTranslations {
<cds-pagination-nav-item
[page]="page"
(click)="currentPage = page"
[isActive]="currentPage == page">
[isActive]="currentPage === page">
</cds-pagination-nav-item>
}
@if (backCuts) {
Expand All @@ -95,7 +95,7 @@ export interface PaginationNavTranslations {
<cds-pagination-nav-item
[page]="totalNumbersArray.length"
(click)="currentPage = totalNumbersArray.length"
[isActive]="currentPage == totalNumbersArray.length">
[isActive]="currentPage === totalNumbersArray.length">
</cds-pagination-nav-item>
}
<li class="cds--pagination-nav__list-item">
Expand Down
9 changes: 5 additions & 4 deletions src/pagination/pagination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ export interface PaginationTranslations {
*/
@Component({
selector: "cds-pagination, ibm-pagination",
template: `
<div
template:
/* eslint-disable max-len */
`<div
class="cds--pagination"
[ngClass]="{
'cds--skeleton': skeleton
Expand Down Expand Up @@ -210,8 +211,8 @@ export interface PaginationTranslations {
</div>
</div>
}
</div>
`
</div>`
/* eslint-enable max-len */
})
export class Pagination {
static paginationCounter = 0;
Expand Down
Loading

0 comments on commit 5b9c1c7

Please sign in to comment.