fix linting errors

This commit is contained in:
Tobias Maestrini 2024-10-06 02:20:41 +02:00
parent 8b4b96bce2
commit ac0d022411
3 changed files with 9 additions and 6 deletions

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
export interface IHierarchyEntry<T extends IHierarchyEntry<T>> {
links?: IHierarchyEntry<T>[];
}
@ -10,7 +12,7 @@ export class navLinkBuilder {
* @param order place order of the new link
* @returns navLinks
*/
public static build<T extends IHierarchyEntry<T>>(currentLinks: T[], newLink: T, order: number) {
public static build<T extends IHierarchyEntry<T>>(currentLinks: T[], newLink: T, order: number): void {
const lastIndex = currentLinks.length - 1;
const startorder:number = (currentLinks as any).__startorder || 0;

View File

@ -15,9 +15,9 @@ export class SPService {
private static GetAnchorUrl(headingValue: string): string {
let anchorUrl = `#${headingValue
.toLowerCase()
.replace(/[{}|\[\]\<\>#@"'^%`?;:\/=~\\\s\s]/g, " ")
.replace(/[{}|[\]<>#@"'^%`?;:/=~\\\s\s]/g, " ")
.replace(/^(-|\s)*|(-|\s)*$/g, "")
.replace(/\'|\?|\\|\/| |\&/g, "-")
.replace(/'|\?|\\|\/| |&/g, "-")
.replace(/-+/g, "-")
.replace(/[+]/g, "%2B") // https://github.com/pnp/sp-dev-fx-webparts/issues/3686
.substring(0, 128)}`;
@ -56,6 +56,7 @@ export class SPService {
const data = await context.spHttpClient.get(`${context.pageContext.web.absoluteUrl}/_api/sitepages/pages?$select=CanvasContent1&$filter=Url eq '${currentPageUrl}'`, SPHttpClient.configurations.v1);
const jsonData = await data.json();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let canvasContent1JSON: any[];
try {
const canvasContent1 = jsonData.value?.[0].CanvasContent1;

View File

@ -17,17 +17,17 @@ export default class PageNavigator extends React.Component<IPageNavigatorProps,
this.onLinkClick = this.onLinkClick.bind(this);
}
public componentDidMount() {
public componentDidMount(): void {
this.setState({ anchorLinks: this.props.anchorLinks, selectedKey: this.props.anchorLinks[0] ? this.props.anchorLinks[0].key : '' });
}
public componentDidUpdate(prevProps: IPageNavigatorProps) {
public componentDidUpdate(prevProps: IPageNavigatorProps): void {
if (JSON.stringify(prevProps.anchorLinks) !== JSON.stringify(this.props.anchorLinks)) {
this.setState({ anchorLinks: this.props.anchorLinks, selectedKey: this.props.anchorLinks[0] ? this.props.anchorLinks[0].key : '' });
}
}
private onLinkClick(ev: React.MouseEvent<HTMLElement>, item?: INavLink) {
private onLinkClick(ev: React.MouseEvent<HTMLElement>, item?: INavLink): void {
this.setState({ selectedKey: item.key });
}