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 = {
root: true,
extends: ['eslint:recommended', 'plugin:svelte/recommended', 'prettier'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
rules: {
indent: ['error', 2, { SwitchCase: 2 }]
}
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
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",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-static": "^2.0.2",

View File

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

View File

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

View File

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

View File

@ -1,15 +1,18 @@
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 = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: 'index.html',
precompress: true,
strict: true
})
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
}
};
export default config;
export default config;

View File

@ -1,17 +1,18 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias and https://kit.svelte.dev/docs/configuration#files
//
// 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
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"outDir": "./dist"
}
// 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
}