Skip to content

Commit

Permalink
chore(eslint): eslint warn arrow-body-style (#41)
Browse files Browse the repository at this point in the history
## Summary
how about eslint `arrow-body-style` warn
If we want to use this rule, I think automation by eslint is better

![Sep-24-2023
22-26-25](https://github.com/fepack/image/assets/61593290/8a7e12ee-dac3-49ad-9baa-47aaa2bce3e9)

<!-- Please summarize your changes. -->

<!-- Please link to any applicable information (forum posts, bug
reports, etc.). -->

## Checks

<!-- For completed items, change [ ] to [x]. -->

<!-- If you leave this checklist empty, your PR will very likely be
closed. -->

Please check the following:

- [x] I have written documents and tests, if needed.
  • Loading branch information
manudeli authored Sep 24, 2023
1 parent f2ecafd commit d29136d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions configs/eslint-config-js/noimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ module.exports = {
extends: ["plugin:vitest/recommended"],
},
],
rules: {
"arrow-body-style": ["warn", "as-needed"],
},
};
10 changes: 4 additions & 6 deletions packages/image/src/extractColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ interface PaletteOptions {
* @param {string} imageUrl - The URL of the image.
* @param {PaletteOptions} [options] - The extraction options.
*/
export const extractColors = (imageUrl: string, options?: PaletteOptions) => {
return loadImageFromUrl(imageUrl)
export const extractColors = (imageUrl: string, options?: PaletteOptions) =>
loadImageFromUrl(imageUrl)
.then(extractImage)
.then((data) => {
if (!data) {
Expand All @@ -22,7 +22,6 @@ export const extractColors = (imageUrl: string, options?: PaletteOptions) => {
const count = options?.colorCount || pixels.length;
return pixels.slice(0, count);
});
};

/**
* Extracts pixel data from an image.
Expand All @@ -47,15 +46,14 @@ const extractImage = (img: HTMLImageElement) => {
* Loads an image from a given URL.
* @param {string} url - The URL of the image to load.
*/
const loadImageFromUrl = (url: string) => {
return new Promise<HTMLImageElement>((resolve, reject) => {
const loadImageFromUrl = (url: string) =>
new Promise<HTMLImageElement>((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = reject;
img.crossOrigin = "Anonymous";
img.src = url;
});
};

/**
* Filters and extracts relevant pixels from image data based on quality setting.
Expand Down

0 comments on commit d29136d

Please sign in to comment.