Update config files to TS

This commit is contained in:
Fred Boniface 2023-07-24 11:05:08 +01:00
parent 8dc0b102a0
commit 69949fb8f4
8 changed files with 125 additions and 108 deletions

View File

@ -1,17 +1,31 @@
module.exports = { module.exports = {
root: true, root: true,
extends: ['eslint:recommended', 'plugin:svelte/recommended', 'prettier'], extends: [
parserOptions: { 'eslint:recommended',
sourceType: 'module', 'plugin:@typescript-eslint/recommended',
ecmaVersion: 2020, 'plugin:svelte/recommended',
extraFileExtensions: ['.svelte'] 'prettier'
}, ],
env: { parser: '@typescript-eslint/parser',
browser: true, plugins: ['@typescript-eslint'],
es2017: true, parserOptions: {
node: true sourceType: 'module',
}, ecmaVersion: 2020,
rules: { extraFileExtensions: ['.svelte']
indent: ['error', 2, { SwitchCase: 2 }] },
} env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
}; };

View File

@ -3,14 +3,14 @@
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .", "lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ." "format": "prettier --plugin-search-dir . --write ."
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-static": "^2.0.2", "@sveltejs/adapter-static": "^2.0.2",

View File

@ -1,5 +1,6 @@
<script> <script>
import Reason from '$lib/raw-fetchers/reason.svelte'; import Reason from '$lib/raw-fetchers/reason.svelte';
import { tocs as tocMap } from '$lib/stores/tocMap';
export let services; export let services;
export let click; export let click;
@ -196,7 +197,7 @@
</tr> </tr>
<tr> <tr>
<td class="tableTxt" colspan="8"> <td class="tableTxt" colspan="8">
{service.operator} {tocMap.get(service.operatorCode.toLowerCase()) || service.operatorCode}
{#if service.isCharter}charter{/if} {#if service.isCharter}charter{/if}
{#if serviceData.length} | {serviceData.length} carriages{/if} {#if serviceData.length} | {serviceData.length} carriages{/if}
{#if service.delayReason} {#if service.delayReason}

View File

@ -1,53 +1,44 @@
const tocMap = { export const tocs = new Map<string, string>([
gw: 'Great Western Railway', [ 'gw', 'Great Western Railway' ],
sw: 'South Western Railway', [ 'sw', 'South Western Railway' ],
id: 'Island Line', [ 'id', 'Island Line' ],
nt: 'Northern', [ 'nt', 'Northern' ],
aw: 'Transport for Wales', [ 'aw', 'Transport for Wales' ],
cc: 'c2c', [ 'cc', 'c2c' ],
cs: 'Caledonian Sleeper', [ 'cs', 'Caledonian Sleeper' ],
ch: 'Chiltern Railways', [ 'ch', 'Chiltern Railways' ],
xc: 'CrossCountry', [ 'xc', 'CrossCountry' ],
em: 'East Midlands Railway', [ 'em', 'East Midlands Railway' ],
es: 'Eurostar', [ 'es', 'Eurostar' ],
ht: 'Hull Trains', [ 'ht', 'Hull Trains' ],
tl: 'Thameslink', [ 'tl', 'Thameslink' ],
gc: 'Grand Central', [ 'gc', 'Grand Central' ],
gx: 'Gatwick Express', [ 'gx', 'Gatwick Express' ],
hx: 'Heathrow Express', [ 'hx', 'Heathrow Express' ],
ls: 'Locomotive Services Limited', [ 'ls', 'Locomotive Services Limited' ],
me: 'Merseyrail', [ 'me', 'Merseyrail' ],
lr: 'Network Rail OTM', [ 'lr', 'Network Rail OTM' ],
xr: 'TfL Elizabeth Line', [ 'xr', 'TfL Elizabeth Line' ],
se: 'SouthEastern', [ 'se', 'Southeastern' ],
sn: 'Southern', [ 'sn', 'Southern' ],
le: 'Greater Anglia', [ 'le', 'Greater Anglia' ],
lm: 'West Midlands Railway', [ 'ga', 'Greater Anglia' ],
sr: 'ScotRail', [ 'lm', 'West Midlands Railway' ],
gn: 'Great Northern', [ 'sr', 'ScotRail' ],
lt: 'TfL London Underground', [ 'gn', 'Great Northern' ],
lo: 'TfL London Overground', [ 'lt', 'TfL London Underground' ],
sj: 'Sheffield SuperTram', [ 'lo', 'TfL London Overground' ],
tp: 'TransPennine Express', [ 'sj', 'Sheffield SuperTram' ],
vt: 'Avanti West Coast', [ 'tp', 'TransPennine Express' ],
gr: 'LNER', [ 'vt', 'Avanti West Coast' ],
wc: 'West Coast Railway', [ 'gr', 'LNER' ],
ty: 'Vintage Trains', [ 'wc', 'West Coast Railway' ],
ld: 'Lumo', [ 'ty', 'Vintage Trains' ],
so: 'Rail Adventure', [ 'ld', 'Lumo' ],
ln: 'Grand Union Trains', [ 'so', 'Rail Adventure' ],
zz: 'Freight/Charter Company', [ 'ln', 'Grand Union Trains' ],
wm: 'West Midlands Railway (WMT)', [ 'zz', 'Freight/Charter Company' ],
uk: 'Unknown Operator' [ 'wm', 'West Midlands Railway (WMT)' ],
}; [ 'uk', 'Unknown Operator' ]
]
const tocs = new Map<string, string>([ )
['uk', 'Unknown Operator'],
['wm', 'West Midlands Railway (WMT)'],
['zz', 'Freight/Charter Operation'],
['ln', 'Grand Union Trains'],
['so', 'Rail Adventure']
])
export default tocMap;
export { tocs }

View File

@ -1,13 +1,14 @@
<script> <script lang="ts">
import tocMap from "$lib/stores/tocMap"; export let toc: string
export let toc = "" export let full: boolean = false;
export let full = false;
let text = "" import { tocs as map } from "$lib/stores/tocMap";
let text: string
$: { $: {
if (full) { if (full) {
text = tocMap[toc.toLowerCase()] || toc; text = map.get(toc.toLowerCase()) || toc;
} else { } else {
text = toc; text = toc;
} }
@ -23,6 +24,8 @@
border-radius: 5px; border-radius: 5px;
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
background-color: white;
color: black;
} }
.gw { /* GWR */ .gw { /* GWR */
background-color: #07352d; background-color: #07352d;
@ -85,7 +88,7 @@
background-color: rgb(40, 40, 40); background-color: rgb(40, 40, 40);
color: rgb(219, 123, 5); color: rgb(219, 123, 5);
} }
.le { /*Greater Anglia */ .le, .ga { /*Greater Anglia */
background-color: rgb(122, 124, 154); background-color: rgb(122, 124, 154);
color: rgb(151, 0, 0); color: rgb(151, 0, 0);
border-color: red; border-color: red;
@ -175,4 +178,8 @@
background-color: rgb(89, 89, 89); background-color: rgb(89, 89, 89);
color: white; color: white;
} }
.uk {
background-color: whitesmoke;
color: black;
}
</style> </style>

View File

@ -1,14 +1,17 @@
import adapter from '@sveltejs/adapter-static'; import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
/** @type {import('@sveltejs/kit').Config} */
const config = { const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: { kit: {
adapter: adapter({ // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
pages: 'build', // If your environment is not supported or you settled on a specific environment, switch out the adapter.
assets: 'build', // See https://kit.svelte.dev/docs/adapters for more information about adapters.
fallback: 'index.html', adapter: adapter()
precompress: true,
strict: true
})
} }
}; };

View File

@ -1,17 +1,18 @@
{ {
"extends": "./.svelte-kit/tsconfig.json", "extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": { "compilerOptions": {
"allowJs": true, "allowJs": true,
"checkJs": true, "checkJs": true,
"esModuleInterop": true, "esModuleInterop": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"skipLibCheck": true, "skipLibCheck": true,
"sourceMap": true, "sourceMap": true,
"strict": true "strict": true,
} "outDir": "./dist"
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias and https://kit.svelte.dev/docs/configuration#files }
// // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes //
// from the referenced tsconfig.json - TypeScript does not merge them in // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
} }