mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-21 14:21:46 +00:00
chore: apply prettier on the entire project
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import js from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
import eslintConfigPrettier from "eslint-config-prettier";
|
||||
import eslintPluginPrettier from "eslint-plugin-prettier";
|
||||
import gitignore from "eslint-config-flat-gitignore";
|
||||
|
||||
export default tseslint.config(
|
||||
gitignore({ strict: false }),
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
eslintConfigPrettier,
|
||||
{
|
||||
plugins: {
|
||||
prettier: eslintPluginPrettier,
|
||||
},
|
||||
rules: {
|
||||
"prettier/prettier": "error",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
||||
],
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: ["node_modules"],
|
||||
},
|
||||
);
|
||||
+2
-1
@@ -38,6 +38,7 @@
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.5",
|
||||
"prettier": "3.8.3",
|
||||
"prettier-plugin-organize-imports": "^4.3.0"
|
||||
"prettier-plugin-organize-imports": "^4.3.0",
|
||||
"typescript-eslint": "^8.58.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { idSchema, idParamSchema, nonEmptyString, isoDateTime } from './primitives.schema';
|
||||
import { paginationQuerySchema } from './pagination.schema';
|
||||
import {
|
||||
idSchema,
|
||||
idParamSchema,
|
||||
nonEmptyString,
|
||||
isoDateTime,
|
||||
} from './primitives.schema';
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('@trek/shared primitives', () => {
|
||||
it('idSchema accepts positive integers, rejects others', () => {
|
||||
@@ -29,11 +35,16 @@ describe('@trek/shared primitives', () => {
|
||||
describe('@trek/shared pagination', () => {
|
||||
it('applies defaults and coerces', () => {
|
||||
expect(paginationQuerySchema.parse({})).toEqual({ page: 1, perPage: 50 });
|
||||
expect(paginationQuerySchema.parse({ page: '2', perPage: '10' })).toEqual({ page: 2, perPage: 10 });
|
||||
expect(paginationQuerySchema.parse({ page: '2', perPage: '10' })).toEqual({
|
||||
page: 2,
|
||||
perPage: 10,
|
||||
});
|
||||
});
|
||||
|
||||
it('enforces bounds', () => {
|
||||
expect(paginationQuerySchema.safeParse({ perPage: 0 }).success).toBe(false);
|
||||
expect(paginationQuerySchema.safeParse({ perPage: 999 }).success).toBe(false);
|
||||
expect(paginationQuerySchema.safeParse({ perPage: 999 }).success).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
weatherQuerySchema,
|
||||
detailedWeatherQuerySchema,
|
||||
weatherResultSchema,
|
||||
} from './weather.schema';
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('weatherQuerySchema', () => {
|
||||
it('accepts lat/lng and defaults lang to "de"', () => {
|
||||
const parsed = weatherQuerySchema.parse({ lat: '52.5', lng: '13.4' });
|
||||
@@ -12,41 +13,80 @@ describe('weatherQuerySchema', () => {
|
||||
});
|
||||
|
||||
it('keeps an explicit lang and optional date', () => {
|
||||
const parsed = weatherQuerySchema.parse({ lat: '1', lng: '2', date: '2026-07-01', lang: 'en' });
|
||||
const parsed = weatherQuerySchema.parse({
|
||||
lat: '1',
|
||||
lng: '2',
|
||||
date: '2026-07-01',
|
||||
lang: 'en',
|
||||
});
|
||||
expect(parsed.lang).toBe('en');
|
||||
expect(parsed.date).toBe('2026-07-01');
|
||||
});
|
||||
|
||||
it('rejects missing lat/lng', () => {
|
||||
expect(weatherQuerySchema.safeParse({ lng: '13.4' }).success).toBe(false);
|
||||
expect(weatherQuerySchema.safeParse({ lat: '', lng: '13.4' }).success).toBe(false);
|
||||
expect(weatherQuerySchema.safeParse({ lat: '', lng: '13.4' }).success).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('detailedWeatherQuerySchema', () => {
|
||||
it('requires a date', () => {
|
||||
expect(detailedWeatherQuerySchema.safeParse({ lat: '1', lng: '2' }).success).toBe(false);
|
||||
expect(detailedWeatherQuerySchema.safeParse({ lat: '1', lng: '2', date: '2026-07-01' }).success).toBe(true);
|
||||
expect(
|
||||
detailedWeatherQuerySchema.safeParse({ lat: '1', lng: '2' }).success,
|
||||
).toBe(false);
|
||||
expect(
|
||||
detailedWeatherQuerySchema.safeParse({
|
||||
lat: '1',
|
||||
lng: '2',
|
||||
date: '2026-07-01',
|
||||
}).success,
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('weatherResultSchema', () => {
|
||||
it('accepts a minimal current-weather result', () => {
|
||||
const r = weatherResultSchema.parse({ temp: 21, main: 'Clear', description: 'Klar', type: 'current' });
|
||||
const r = weatherResultSchema.parse({
|
||||
temp: 21,
|
||||
main: 'Clear',
|
||||
description: 'Klar',
|
||||
type: 'current',
|
||||
});
|
||||
expect(r.temp).toBe(21);
|
||||
});
|
||||
|
||||
it('accepts a detailed result with hourly entries and a no_forecast error', () => {
|
||||
expect(
|
||||
weatherResultSchema.safeParse({
|
||||
temp: 0, main: '', description: '', type: '', error: 'no_forecast',
|
||||
temp: 0,
|
||||
main: '',
|
||||
description: '',
|
||||
type: '',
|
||||
error: 'no_forecast',
|
||||
}).success,
|
||||
).toBe(true);
|
||||
expect(
|
||||
weatherResultSchema.safeParse({
|
||||
temp: 18, main: 'Rain', description: 'Regen', type: 'forecast',
|
||||
sunrise: '05:30', sunset: '21:10', precipitation_sum: 2.4,
|
||||
hourly: [{ hour: 9, temp: 17, precipitation: 0.1, precipitation_probability: 20, main: 'Clouds', wind: 12, humidity: 80 }],
|
||||
temp: 18,
|
||||
main: 'Rain',
|
||||
description: 'Regen',
|
||||
type: 'forecast',
|
||||
sunrise: '05:30',
|
||||
sunset: '21:10',
|
||||
precipitation_sum: 2.4,
|
||||
hourly: [
|
||||
{
|
||||
hour: 9,
|
||||
temp: 17,
|
||||
precipitation: 0.1,
|
||||
precipitation_probability: 20,
|
||||
main: 'Clouds',
|
||||
wind: 12,
|
||||
humidity: 80,
|
||||
},
|
||||
],
|
||||
}).success,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user