Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
husa committed Aug 2, 2024
1 parent 6c2bc18 commit 610b2d8
Show file tree
Hide file tree
Showing 28 changed files with 41 additions and 70 deletions.
8 changes: 2 additions & 6 deletions src/common/animations/Animation.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React, { useRef } from 'react';
import { useRef } from 'react';
import { CSSTransition } from 'react-transition-group';

const TRANSITION_DURATION = 500;

const Animation = ({
name,
timeout,
children,
}) => {
const Animation = ({ name, timeout, children }) => {

Check warning on line 6 in src/common/animations/Animation.tsx

View workflow job for this annotation

GitHub Actions / build

'name' is missing in props validation

Check warning on line 6 in src/common/animations/Animation.tsx

View workflow job for this annotation

GitHub Actions / build

'timeout' is missing in props validation

Check warning on line 6 in src/common/animations/Animation.tsx

View workflow job for this annotation

GitHub Actions / build

'children' is missing in props validation
const nodeRef = useRef(null);
return (
<CSSTransition
Expand Down
4 changes: 1 addition & 3 deletions src/common/animations/FadeIn.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import './fadeIn.scss';

import React from 'react';

import Animation from './Animation';

const FadeIn = ({ children }) => (

Check warning on line 5 in src/common/animations/FadeIn.tsx

View workflow job for this annotation

GitHub Actions / build

'children' is missing in props validation
<Animation name='fadeIn' timeout={[400, 700, 700]}>
<Animation name="fadeIn" timeout={[400, 700, 700]}>
{children}
</Animation>
);
Expand Down
4 changes: 1 addition & 3 deletions src/common/animations/Slide.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import './slide.scss';

import React from 'react';

import Animation from './Animation';

const Slide = ({ children }) => (

Check warning on line 5 in src/common/animations/Slide.tsx

View workflow job for this annotation

GitHub Actions / build

'children' is missing in props validation
<Animation name='slide' timeout={[0, 200, 200]}>
<Animation name="slide" timeout={[0, 200, 200]}>
{children}
</Animation>
);
Expand Down
1 change: 0 additions & 1 deletion src/components/ColorPicker/ColorPicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import { ColorPicker } from './ColorPicker';
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/components/clock/Clock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './clock.scss';
import './Clock.scss';

import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import classNames from 'classnames';

//import Slide from '../../common/animations/Slide';
Expand Down Expand Up @@ -62,12 +62,12 @@ const Delimiter = ({ hidden = false, delimiterBlinking }) => {
return <span className={className}>:</span>;
};

const AmPm = ({ hours }: {hours: number}) => {
const AmPm = ({ hours }: { hours: number }) => {
const ampm = hours < 12 ? 'am' : 'pm';
return <span className="clock__ampm">{ampm}</span>;
};

const Clock = ({ className }: {className: string}) => {
const Clock = ({ className }: { className: string }) => {
const { state } = useSettingsSlice();
const { use24format: use24, delimiterBlinking, displaySeconds, animateDigits } = state;
const [{ minutes, hours, seconds }, setTime] = useState(newTime);
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './Settings.scss';

import React, { useRef, useState } from 'react';
import React, { useState } from 'react';
import classNames from 'classnames';

import SettingsGroups from './SettingsGroups/SettingsGroups';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import SettingsGroups from './SettingsGroups';
Expand Down
1 change: 0 additions & 1 deletion src/components/settings/SettingsGroups/SettingsGroups.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import './SettingsGroups.scss';

import classNames from 'classnames';

import SettingsGroupTile from '../SettingsGroupTile/SettingsGroupTile';
import type { SettingsGroup } from '../settings-groups';

Expand Down
3 changes: 2 additions & 1 deletion src/components/settings/SettingsPanel/SettingsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import classNames from 'classnames';
import './SettingsPanel.scss';

import classNames from 'classnames';

import { PropsWithChildren } from 'react';

type Props = PropsWithChildren<{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { colors, gradientAngles, gradients, images, patterns } from '../../../config';
import lang from '../../../services/lang';
import { ColorPicker } from '../../ColorPicker/ColorPicker';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { useSettingsSlice } from '../../../store/slices/settingsSlice';
import { SettingsPanel } from '../SettingsPanel/SettingsPanel';
import SwitchOption from '../SwitchOption/SwitchOption';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import lang from '../../../services/lang';
import { dock } from '../../../config';
import { DockURL } from '../../../config/dock';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ChangeEvent } from 'react';
import { ChangeEvent } from 'react';
import { colors, fonts } from '../../../config';
import lang from '../../../services/lang';
import { ColorPicker } from '../../ColorPicker/ColorPicker';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import { SettingsSection } from './SettingsSection';
Expand Down
3 changes: 2 additions & 1 deletion src/components/settings/SettingsSection/SettingsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import './SettingsSection.scss';
import React, { PropsWithChildren } from 'react';

import { PropsWithChildren } from 'react';

type Props = PropsWithChildren<{
title: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/Slider/Slider.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ChangeEvent, useState } from 'react';
import { ChangeEvent, useState } from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import { Slider } from './Slider';
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/Slider/Slider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './Slider.scss';

import React, { InputHTMLAttributes } from 'react';
import { InputHTMLAttributes } from 'react';

export const Slider = ({ min, max, value, ...rest }: InputHTMLAttributes<HTMLInputElement>) => {
const zeroBasedValue: number = parseFloat(value as string) - parseFloat(min as string);
Expand Down
1 change: 0 additions & 1 deletion src/components/settings/Switch/Switch.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import Switch from './Switch';
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/Switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './Switch.scss';

import React, { InputHTMLAttributes } from 'react';
import { InputHTMLAttributes } from 'react';
import classNames from 'classnames';

const Switch = ({ className, checked, ...rest }: InputHTMLAttributes<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import SwitchOption from './SwitchOption';
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/SwitchOption/SwitchOption.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './SwitchOption.scss';

import React, { PropsWithChildren } from 'react';
import { PropsWithChildren } from 'react';
import Switch from '../Switch/Switch';

type Props = PropsWithChildren<{
Expand Down
18 changes: 8 additions & 10 deletions src/components/weather/Current.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import './current.scss';

import * as React from 'react';

import Icon from './Icon';
import type { WeatherResponseCurrent, WeatherResponseLocation } from '../../types';

type Props = {
data: WeatherResponseCurrent,
location: WeatherResponseLocation,
temperatureUnits: 'c' | 'f',
data: WeatherResponseCurrent;
location: WeatherResponseLocation;
temperatureUnits: 'c' | 'f';
};

const CurrentWeather = ({ data, location, temperatureUnits }: Props) => (
<div className='weather-current'>
<div className='weather-current__city'>{location.city}</div>
<Icon className='weather-current__icon' code={data.code} title={data.text} />
<div className='weather-current__temperature'>{data.temp}</div>
<div className='weather-current__degrees'>°{temperatureUnits.toUpperCase()}</div>
<div className="weather-current">
<div className="weather-current__city">{location.city}</div>
<Icon className="weather-current__icon" code={data.code} title={data.text} />
<div className="weather-current__temperature">{data.temp}</div>
<div className="weather-current__degrees">°{temperatureUnits.toUpperCase()}</div>
</div>
);

Expand Down
4 changes: 1 addition & 3 deletions src/components/weather/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from 'react';

import lang from '../../services/lang';
import ErrorMessage from '../error/ErrorMessage';

Expand Down Expand Up @@ -33,7 +31,7 @@ const WeatherError = ({ error }: Props) => {
}
}

return <ErrorMessage className='weather__error'>{message}</ErrorMessage>;
return <ErrorMessage className="weather__error">{message}</ErrorMessage>;
};

export default WeatherError;
22 changes: 10 additions & 12 deletions src/components/weather/Forecast.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import './forecast.scss';

import * as React from 'react';

import type { WeatherResponseForecast } from '../../types';
import lang from '../../services/lang';
import Icon from './Icon';
Expand All @@ -21,19 +19,19 @@ export const getDay = (date: string) => {
};

type Props = {
data: WeatherResponseForecast,
data: WeatherResponseForecast;
};

const WeatherForecast = (props: Props) => (
<div className='weather-forecast'>
{props.data.map(day => (
<div className='weather-forecast__day' key={day.date}>
<div className='weather-forecast__day__name'>{getDay(day.date)}</div>
<Icon className='weather-forecast__day__icon' code={day.code} title={day.text} />
<div className='weather-forecast__day__temperature'>
<span className='weather-forecast__day__temperature--max'>{day.max}&deg;</span>
<span className='weather-forecast__day__temperature__separator'>/</span>
<span className='weather-forecast__day__temperature--min'>{day.min}&deg;</span>
<div className="weather-forecast">
{props.data.map((day) => (
<div className="weather-forecast__day" key={day.date}>
<div className="weather-forecast__day__name">{getDay(day.date)}</div>
<Icon className="weather-forecast__day__icon" code={day.code} title={day.text} />
<div className="weather-forecast__day__temperature">
<span className="weather-forecast__day__temperature--max">{day.max}&deg;</span>
<span className="weather-forecast__day__temperature__separator">/</span>
<span className="weather-forecast__day__temperature--min">{day.min}&deg;</span>
</div>
</div>
))}
Expand Down
1 change: 0 additions & 1 deletion src/components/weather/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './icon.scss';

import * as React from 'react';
import classNames from 'classnames';

type Props = {
Expand Down
12 changes: 3 additions & 9 deletions src/components/weather/__tests__/Current.test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Current from '../Current';


describe('Components > weather > Current', () => {
it('should match snapshot', () => {
const testData = {
code: '1',
date: '18 Jan 2018',
temp: -273,
text: 'test-text'
text: 'test-text',
};

const testLocation = {
city: 'TestCity'
city: 'TestCity',
};

const testTemperatureUnits = 'test-temp-unit';


const component = renderer.create(
<Current
data={testData}
location={testLocation}
temperatureUnits={testTemperatureUnits} />
<Current data={testData} location={testLocation} temperatureUnits={testTemperatureUnits} />,
);

const tree = component.toJSON();
Expand Down
3 changes: 1 addition & 2 deletions src/components/weather/__tests__/Forecast.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Forecast, { daysBetween, getDay } from '../Forecast';
Expand All @@ -8,7 +7,7 @@ describe('Components > weather > Forecast', () => {
/* global global */
const OriginalDate = Date;
// mock Date
global.Date = jest.fn().mockImplementation(a => new OriginalDate(a ? a : today));
global.Date = jest.fn().mockImplementation((a) => new OriginalDate(a ? a : today));
global.Date.now = OriginalDate.now;
// run function
fn();
Expand Down

0 comments on commit 610b2d8

Please sign in to comment.