Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to eslint 9 #521

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .eslintignore

This file was deleted.

61 changes: 0 additions & 61 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
plugins: ['prettier-plugin-ember-template-tag'],
overrides: [
{
files: '*.{js,ts,gjs,gts}',
files: '*.{js,ts,gjs,gts,mjs,cjs}',
options: {
singleQuote: true,
templateSingleQuote: false,
Expand Down
2 changes: 1 addition & 1 deletion addon/components/au-date-picker.gts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class AuDatePicker extends Component<AuDatePickerSignature> {

constructor(owner: unknown, args: AuDatePickerSignature['Args']) {
super(owner, args);
this.registerDuetDatePicker();
void this.registerDuetDatePicker();
}

get adapter() {
Expand Down
6 changes: 3 additions & 3 deletions addon/components/au-file-upload.gts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class AuFileUpload extends Component<AuFileUploadSignature> {

@action
upload(file: UploadFile): void | undefined {
this.uploadTask.perform(file);
void this.uploadTask.perform(file);
}

uploadTask = task(async (file: UploadFile) => {
Expand All @@ -114,10 +114,10 @@ export default class AuFileUpload extends Component<AuFileUploadSignature> {
const response = await file.upload(this.endPoint, {
contentType: 'multipart/form-data',
});
const body = await response.json();
const body = (await response.json()) as { data: { id: number } };
const fileId = body?.data?.id;
return fileId;
} catch (e) {
} catch {
this.addError(file);
this.removeFileFromQueue(file);
return null;
Expand Down
1 change: 0 additions & 1 deletion addon/components/au-toaster.gjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-undef -- This is a workaround for a false-positive bug: https://github.com/ember-cli/eslint-plugin-ember/issues/1747 */
import { AuAlert } from '@appuniversum/ember-appuniversum';
import { fn } from '@ember/helper';
import { inject as service } from '@ember/service';
Expand Down
126 changes: 62 additions & 64 deletions addon/private/modifiers/floating-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,77 +99,75 @@ function floatingUi(
);
}

const update = async () => {
const { x, y, placement, middlewareData } = await computePosition(
referenceElement,
floatingElement,
{
middleware,
placement: defaultPlacement,
},
);

Object.assign(floatingElement.style, {
transform: `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`,
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible',
});

if (middlewareData.arrow) {
const { x } = middlewareData.arrow;
const [side, alignment] = placement.split('-') as [
'top' | 'bottom',
'string' | undefined,
];
const isAligned = alignment != null;

const unsetSides = {
top: '',
bottom: '',
left: '',
right: '',
};

const rotation = {
top: '180deg',
bottom: '0deg',
}[side];

Object.assign(arrowElement!.style, {
...unsetSides,
transform: `rotate(${rotation})`,
const update = () => {
void computePosition(referenceElement, floatingElement, {
middleware,
placement: defaultPlacement,
}).then(({ x, y, placement, middlewareData }) => {
Object.assign(floatingElement.style, {
transform: `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`,
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible',
});

if (isAligned) {
const crossSide = {
'top-start': 'left',
'top-end': 'right',
'bottom-start': 'left',
'bottom-end': 'right',
}[placement as 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'];
if (middlewareData.arrow) {
const { x } = middlewareData.arrow;
const [side, alignment] = placement.split('-') as [
'top' | 'bottom',
'string' | undefined,
];
const isAligned = alignment != null;

const unsetSides = {
top: '',
bottom: '',
left: '',
right: '',
};

const rotation = {
top: '180deg',
bottom: '0deg',
}[side];

Object.assign(arrowElement!.style, {
[crossSide]:
typeof options.arrow?.position === 'string'
? options.arrow.position
: `${options.arrow?.position}px`,
});
} else {
Object.assign(arrowElement!.style, {
left: x != null ? `${x}px` : '',
...unsetSides,
transform: `rotate(${rotation})`,
});
}

const mainSide = {
top: 'bottom',
bottom: 'top',
}[side];

if (options.arrow?.offset) {
Object.assign(arrowElement!.style, {
[mainSide]: `${-options.arrow?.offset}px`,
});
if (isAligned) {
const crossSide = {
'top-start': 'left',
'top-end': 'right',
'bottom-start': 'left',
'bottom-end': 'right',
}[
placement as 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'
];

Object.assign(arrowElement!.style, {
[crossSide]:
typeof options.arrow?.position === 'string'
? options.arrow.position
: `${options.arrow?.position}px`,
});
} else {
Object.assign(arrowElement!.style, {
left: x != null ? `${x}px` : '',
});
}

const mainSide = {
top: 'bottom',
bottom: 'top',
}[side];

if (options.arrow?.offset) {
Object.assign(arrowElement!.style, {
[mainSide]: `${-options.arrow?.offset}px`,
});
}
}
}
});
};

const cleanup = autoUpdate(referenceElement, floatingElement, update);
Expand Down
Loading
Loading