mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-07-17 13:35:42 +00:00
Swap to eslint (#154)
* 311 problems (173 errors, 138 warnings) * Make a start... * swap to react config * Literally a handful left * Clean. * any removal * Use Record * Adjust versions * Update with latest eslint-standard ruleset * Update defaults.ts
This commit is contained in:
@@ -7,14 +7,14 @@ import { ColorGen } from './types';
|
||||
import newSeeder from './seeder';
|
||||
import newColors from './colors';
|
||||
|
||||
describe('colors', () => {
|
||||
describe('colors', (): void => {
|
||||
let colors: ColorGen;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach((): void => {
|
||||
colors = newColors(newSeeder());
|
||||
});
|
||||
|
||||
it('generates using default alpha', () => {
|
||||
it('generates using default alpha', (): void => {
|
||||
expect(
|
||||
colors()
|
||||
).toEqual(
|
||||
@@ -23,7 +23,7 @@ describe('colors', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('applies specified alpha', () => {
|
||||
it('applies specified alpha', (): void => {
|
||||
expect(
|
||||
colors(0.5)
|
||||
).toEqual(
|
||||
@@ -32,7 +32,7 @@ describe('colors', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('rolates colors', () => {
|
||||
it('rolates colors', (): void => {
|
||||
colors();
|
||||
|
||||
expect(
|
||||
@@ -40,7 +40,7 @@ describe('colors', () => {
|
||||
).not.toEqual('hsla(166.70000000000005, 98.6%, 27.6%, 0.9)');
|
||||
});
|
||||
|
||||
it('works in edge conditions (0xff)', () => {
|
||||
it('works in edge conditions (0xff)', (): void => {
|
||||
const u8a = new Uint8Array(32);
|
||||
|
||||
u8a.fill(255);
|
||||
|
||||
@@ -13,7 +13,7 @@ const WOBBLE = 30;
|
||||
|
||||
export default function colors (seeder: Seeder): ColorGen {
|
||||
const amount = (seeder() * WOBBLE) - (WOBBLE / 2);
|
||||
const all = COLORS.map((hex) =>
|
||||
const all = COLORS.map((hex): Color =>
|
||||
Color(hex).rotate(amount)
|
||||
);
|
||||
|
||||
|
||||
@@ -4,38 +4,40 @@
|
||||
|
||||
import container from './container';
|
||||
|
||||
describe('container', () => {
|
||||
it('applies default styles', () => {
|
||||
describe('container', (): void => {
|
||||
it('applies default styles', (): void => {
|
||||
expect(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(container(100).style as any)._values
|
||||
).toMatchObject({
|
||||
'background': 'white',
|
||||
background: 'white',
|
||||
'border-radius': '50px',
|
||||
'display': 'inline-block',
|
||||
'height': '100px',
|
||||
'margin': '0px',
|
||||
'overflow': 'hidden',
|
||||
'padding': '0px',
|
||||
'width': '100px'
|
||||
display: 'inline-block',
|
||||
height: '100px',
|
||||
margin: '0px',
|
||||
overflow: 'hidden',
|
||||
padding: '0px',
|
||||
width: '100px'
|
||||
});
|
||||
});
|
||||
|
||||
it('overrides with supplied styles', () => {
|
||||
it('overrides with supplied styles', (): void => {
|
||||
expect(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(container(50, 'black', '', { display: 'block' }).style as any)._values
|
||||
).toMatchObject({
|
||||
'background': 'black',
|
||||
background: 'black',
|
||||
'border-radius': '25px',
|
||||
'display': 'block',
|
||||
'height': '50px',
|
||||
'margin': '0px',
|
||||
'overflow': 'hidden',
|
||||
'padding': '0px',
|
||||
'width': '50px'
|
||||
display: 'block',
|
||||
height: '50px',
|
||||
margin: '0px',
|
||||
overflow: 'hidden',
|
||||
padding: '0px',
|
||||
width: '50px'
|
||||
});
|
||||
});
|
||||
|
||||
it('applies the specified className', () => {
|
||||
it('applies the specified className', (): void => {
|
||||
expect(
|
||||
container(100, 'blue', 'testClass').className
|
||||
).toEqual('testClass');
|
||||
|
||||
@@ -19,8 +19,8 @@ export default function container (diameter: number, background: string = 'white
|
||||
element.className = className;
|
||||
element.style.background = background;
|
||||
|
||||
Object.keys(style).forEach((key: any) => {
|
||||
element.style[key] = style[key];
|
||||
Object.keys(style).forEach((key: unknown): void => {
|
||||
element.style[key as number] = style[key as number];
|
||||
});
|
||||
|
||||
return element;
|
||||
|
||||
@@ -3,17 +3,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
const COLORS: Array<string> = [
|
||||
// '#01888C', // teal
|
||||
// '#FC7500', // bright orange
|
||||
// '#034F5D', // dark teal
|
||||
// '#F73F01', // orangered
|
||||
// '#FC1960', // magenta
|
||||
// '#C7144C', // raspberry
|
||||
// '#F3C100', // goldenrod
|
||||
// '#1598F2', // lightning blue
|
||||
// '#2465E1', // sail blue
|
||||
// '#F19E02' // gold
|
||||
const COLORS: string[] = [
|
||||
// https://sashat.me/2017/01/11/list-of-20-simple-distinct-colors/
|
||||
'#ffe119', '#4363d8', '#f58231', '#fabebe', '#e6beff', '#800000', '#000075', '#a9a9a9', '#ffffff', '#000000'
|
||||
];
|
||||
|
||||
@@ -6,8 +6,8 @@ import xmlserializer from 'xmlserializer';
|
||||
|
||||
import identicon from '.';
|
||||
|
||||
describe('identicon', () => {
|
||||
it('generates a basic [0,..,0] identicon', () => {
|
||||
describe('identicon', (): void => {
|
||||
it('generates a basic [0,..,0] identicon', (): void => {
|
||||
expect(
|
||||
xmlserializer.serializeToString(
|
||||
identicon(new Uint8Array(32))
|
||||
@@ -17,7 +17,7 @@ describe('identicon', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('allows overrides', () => {
|
||||
it('allows overrides', (): void => {
|
||||
expect(
|
||||
xmlserializer.serializeToString(
|
||||
identicon(new Uint8Array(32), 100, 'testClass', { display: 'block' })
|
||||
|
||||
@@ -6,20 +6,20 @@ import { Seeder } from './types';
|
||||
|
||||
import newSeeder from './seeder';
|
||||
|
||||
describe('seeder', () => {
|
||||
describe('seeder', (): void => {
|
||||
let seeder: Seeder;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach((): void => {
|
||||
seeder = newSeeder(new Uint8Array([1, 2, 3, 4]));
|
||||
});
|
||||
|
||||
it('generates numbers using 2 spaces', () => {
|
||||
it('generates numbers using 2 spaces', (): void => {
|
||||
expect(
|
||||
seeder()
|
||||
).toEqual(0.0156402587890625);
|
||||
});
|
||||
|
||||
it('generates numbers using 2 spaces (incremented)', () => {
|
||||
it('generates numbers using 2 spaces (incremented)', (): void => {
|
||||
seeder();
|
||||
|
||||
expect(
|
||||
|
||||
@@ -15,7 +15,7 @@ export default function seeder (_seed: string | Uint8Array = new Uint8Array(32))
|
||||
|
||||
let index = (seed[Math.floor(seed.length / 2)] % seed.length) - 1;
|
||||
|
||||
const next = () => {
|
||||
const next = (): number => {
|
||||
index += 1;
|
||||
|
||||
if (index === seed.length) {
|
||||
|
||||
@@ -7,8 +7,8 @@ import xmlserializer from 'xmlserializer';
|
||||
import seeder from '../seeder';
|
||||
import circle from './circle';
|
||||
|
||||
describe('circle', () => {
|
||||
it('creates a circle shape', () => {
|
||||
describe('circle', (): void => {
|
||||
it('creates a circle shape', (): void => {
|
||||
expect(
|
||||
xmlserializer.serializeToString(
|
||||
circle(seeder(), 'blue', 50, 2)
|
||||
|
||||
@@ -6,8 +6,8 @@ import xmlserializer from 'xmlserializer';
|
||||
|
||||
import circle from './circle';
|
||||
|
||||
describe('circle', () => {
|
||||
it('creates a basic SVG circle element', () => {
|
||||
describe('circle', (): void => {
|
||||
it('creates a basic SVG circle element', (): void => {
|
||||
expect(
|
||||
xmlserializer.serializeToString(
|
||||
circle(123, 12, 34)
|
||||
|
||||
@@ -6,8 +6,8 @@ import xmlserializer from 'xmlserializer';
|
||||
|
||||
import element from './element';
|
||||
|
||||
describe('element', () => {
|
||||
it('creates a basic SVG element', () => {
|
||||
describe('element', (): void => {
|
||||
it('creates a basic SVG element', (): void => {
|
||||
expect(
|
||||
xmlserializer.serializeToString(
|
||||
element(123)
|
||||
|
||||
@@ -6,8 +6,8 @@ import xmlserializer from 'xmlserializer';
|
||||
|
||||
import rect from './rect';
|
||||
|
||||
describe('rect', () => {
|
||||
it('creates a basic SVG rect element', () => {
|
||||
describe('rect', (): void => {
|
||||
it('creates a basic SVG rect element', (): void => {
|
||||
expect(
|
||||
xmlserializer.serializeToString(
|
||||
rect(123)
|
||||
|
||||
@@ -6,8 +6,8 @@ import xmlserializer from 'xmlserializer';
|
||||
|
||||
import svg from './svg';
|
||||
|
||||
describe('svg', () => {
|
||||
it('creates a basic SVG element', () => {
|
||||
describe('svg', (): void => {
|
||||
it('creates a basic SVG element', (): void => {
|
||||
expect(
|
||||
xmlserializer.serializeToString(
|
||||
svg('rect')
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
|
||||
export type Seeder = () => number;
|
||||
|
||||
export type ColorGen = {
|
||||
(alpha?: number): string
|
||||
};
|
||||
export interface ColorGen {
|
||||
(alpha?: number): string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user