From 0457239fd3d093d320007daddb9f77f7ff849f7c Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Wed, 27 Oct 2021 18:02:45 +0200 Subject: [PATCH] Configs & packages for svelte kit setup --- .eslintrc.cjs | 20 ++++++++++++++++++++ .prettierrc | 6 ++++++ package.json | 33 +++++++++++++++++++++++++++++++++ svelte.config.js | 17 +++++++++++++++++ tsconfig.json | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 .eslintrc.cjs create mode 100644 .prettierrc create mode 100644 package.json create mode 100644 svelte.config.js create mode 100644 tsconfig.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..fba3861 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,20 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], + plugins: ['svelte3', '@typescript-eslint'], + ignorePatterns: ['*.cjs'], + overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], + settings: { + 'svelte3/typescript': () => require('typescript') + }, + parserOptions: { + sourceType: 'module', + ecmaVersion: 2019 + }, + env: { + browser: true, + es2017: true, + node: true + } +}; diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..ff2677e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "useTabs": true, + "singleQuote": true, + "trailingComma": "none", + "printWidth": 100 +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..a1faaed --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "kevinmidboe", + "version": "0.0.1", + "scripts": { + "dev": "svelte-kit dev", + "build": "svelte-kit build", + "start": "node ./.svelte-kit/output/server/app.js", + "preview": "svelte-kit preview", + "check": "svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", + "lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", + "format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ." + }, + "devDependencies": { + "@sveltejs/adapter-node": "^1.0.0-next.53", + "@sveltejs/kit": "next", + "@types/cookie": "^0.4.1", + "@typescript-eslint/eslint-plugin": "^4.31.1", + "@typescript-eslint/parser": "^4.31.1", + "eslint": "^7.32.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-svelte3": "^3.2.1", + "node-sass": "6.0.1", + "prettier": "^2.4.1", + "prettier-plugin-svelte": "^2.4.0", + "svelte": "^3.34.0", + "svelte-check": "^2.2.6", + "svelte-preprocess": "^4.9.4", + "tslib": "^2.3.1", + "typescript": "^4.4.3" + }, + "type": "module" +} diff --git a/svelte.config.js b/svelte.config.js new file mode 100644 index 0000000..a58f2e9 --- /dev/null +++ b/svelte.config.js @@ -0,0 +1,17 @@ +import preprocess from 'svelte-preprocess'; +import node from '@sveltejs/adapter-node'; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + // Consult https://github.com/sveltejs/svelte-preprocess + // for more information about preprocessors + preprocess: preprocess(), + + kit: { + // hydrate the
element in src/app.html + target: '#svelte', + adapter: node({ out: 'build' }) + } +}; + +export default config; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..9a71b68 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "es2020", + "lib": ["es2020", "DOM"], + "target": "es2019", + /** + svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript + to enforce using \`import type\` instead of \`import\` for Types. + */ + "importsNotUsedAsValues": "error", + "isolatedModules": true, + "resolveJsonModule": true, + /** + To have warnings/errors of the Svelte compiler at the correct position, + enable source maps by default. + */ + "sourceMap": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "baseUrl": ".", + "allowJs": true, + "checkJs": true, + "paths": { + "$lib": ["src/lib"], + "$lib/*": ["src/lib/*"], + "$sass": ["src/sass"], + "$sass/*": ["src/sass/*"] + } + }, + "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"] +}