Skip to content

Commit

Permalink
fix(): fix lint problems (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawqss authored Sep 27, 2024
1 parent f607935 commit e541198
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 47 deletions.
17 changes: 0 additions & 17 deletions __tests__/App.test.tsx

This file was deleted.

42 changes: 21 additions & 21 deletions app/http/types.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
export interface WeatherResponse {
cod: number;
calctime: number;
cnt: number;
list: WeatherItem[];
}

export interface WeatherItem {
id: number;
dt: number;
name: string;
coord: Coordinates;
main: MainWeather;
visibility: number;
wind: Wind;
rain: Rain | null;
snow: Snow | null;
clouds: Clouds;
weather: WeatherDescription[];
}

export interface Coordinates {
Lon: number;
Lat: number;
Expand Down Expand Up @@ -58,3 +37,24 @@ interface WeatherDescription {
description: string;
icon: string;
}

export interface WeatherItem {
id: number;
dt: number;
name: string;
coord: Coordinates;
main: MainWeather;
visibility: number;
wind: Wind;
rain: Rain | null;
snow: Snow | null;
clouds: Clouds;
weather: WeatherDescription[];
}

export interface WeatherResponse {
cod: number;
calctime: number;
cnt: number;
list: WeatherItem[];
}
10 changes: 4 additions & 6 deletions app/http/utils.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { WeatherItem } from './types.ts';

const normalizeCityName = (name: string) => {
return name
const normalizeCityName = (name: string) =>
name
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase();
};

export const getUniqueCities = (cities: WeatherItem[]): WeatherItem[] => {
return cities.filter((city, index, self) => {
export const getUniqueCities = (cities: WeatherItem[]): WeatherItem[] =>
cities.filter((city, index, self) => {
const normalizedName = normalizeCityName(city.name);
return (
index ===
self.findIndex((c) => normalizeCityName(c.name) === normalizedName)
);
});
};
2 changes: 1 addition & 1 deletion app/http/weatherApiBase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OPEN_WEATHER_MAP_API_KEY } from '@env';
import { OPEN_WEATHER_MAP_API_KEY } from 'react-native-dotenv';
import axios from 'axios';

const weatherApiBase = axios.create({
Expand Down
2 changes: 1 addition & 1 deletion app/types/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module '@env' {
declare module 'react-native-dotenv' {
export const OPEN_WEATHER_MAP_API_KEY: string;
}
7 changes: 6 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
'module:react-native-dotenv',
[
'module:react-native-dotenv',
{
moduleName: 'react-native-dotenv'
}
],
[
'module-resolver',
{
Expand Down

0 comments on commit e541198

Please sign in to comment.