mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 05:57:05 +02:00
chore(v2): Fix more eslint errors (#2976)
This commit is contained in:
parent
3611c96f90
commit
6e43c9bd34
81 changed files with 375 additions and 237 deletions
|
@ -7,10 +7,9 @@
|
|||
|
||||
import path from 'path';
|
||||
import Vibrant from 'node-vibrant';
|
||||
import {Palette} from 'node-vibrant/lib/color';
|
||||
|
||||
// @ts-ignore
|
||||
import {toPalette, toBase64} from '../utils';
|
||||
// @ts-ignore
|
||||
import lqip from '../lqip';
|
||||
|
||||
describe('lqip-loader', () => {
|
||||
|
@ -24,8 +23,8 @@ describe('lqip-loader', () => {
|
|||
});
|
||||
|
||||
describe('toPalette', () => {
|
||||
let correctTestSwatch: object = {};
|
||||
let testSwatchWithNull: object = {};
|
||||
let correctTestSwatch: Palette = {};
|
||||
let testSwatchWithNull: Palette & {Vibrant?: null} = {};
|
||||
|
||||
beforeAll(() => {
|
||||
const imgPath = path.join(__dirname, '__fixtures__', 'endi.jpg');
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @ts-check
|
||||
|
||||
const sortBy = require('lodash.sortby');
|
||||
|
||||
/**
|
||||
|
@ -12,7 +14,7 @@ const sortBy = require('lodash.sortby');
|
|||
* @description it returns a Base64 image string with required formatting
|
||||
* to work on the web (<img src=".." /> or in CSS url('..'))
|
||||
*
|
||||
* @param extMimeType: image mime type string
|
||||
* @param {string} extMimeType: image mime type string
|
||||
* @param data: base64 string
|
||||
* @returns {string}
|
||||
*/
|
||||
|
@ -25,10 +27,11 @@ const toBase64 = (extMimeType, data) => {
|
|||
* @description takes a color swatch object, converts it to an array & returns
|
||||
* only hex color
|
||||
*
|
||||
* @param swatch
|
||||
* @returns {{palette: Array}}
|
||||
* @param {import("node-vibrant/lib/color").Palette} swatch
|
||||
* @returns {string[]}
|
||||
*/
|
||||
const toPalette = (swatch) => {
|
||||
/** @type {Array<{popularity: number, hex: string}>} */
|
||||
let palette = Object.keys(swatch).reduce((result, key) => {
|
||||
if (swatch[key] !== null) {
|
||||
result.push({
|
||||
|
@ -39,8 +42,7 @@ const toPalette = (swatch) => {
|
|||
return result;
|
||||
}, []);
|
||||
palette = sortBy(palette, ['popularity']);
|
||||
palette = palette.map((color) => color.hex).reverse();
|
||||
return palette;
|
||||
return palette.map((color) => color.hex).reverse();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue