Skip to content

Commit 83f42df

Browse files
committed
Add eslint & prettier
1 parent 6bb6d53 commit 83f42df

File tree

6 files changed

+3776
-408
lines changed

6 files changed

+3776
-408
lines changed

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore artifacts:
2+
build
3+
coverage
4+
5+
app/frontend/routes

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 80,
3+
"semi": false,
4+
"tabWidth": 2,
5+
"trailingComma": "all",
6+
"plugins": [
7+
"prettier-plugin-svelte",
8+
"prettier-plugin-tailwindcss"
9+
],
10+
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
11+
}

app/frontend/entrypoints/inertia.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { createInertiaApp, type ResolvedComponent } from '@inertiajs/svelte'
2-
import { mount } from 'svelte'
1+
import { type ResolvedComponent, createInertiaApp } from "@inertiajs/svelte"
2+
import { mount } from "svelte"
33

44
createInertiaApp({
55
// Set default page title
@@ -13,7 +13,7 @@ createInertiaApp({
1313
// progress: false,
1414

1515
resolve: (name) => {
16-
const pages = import.meta.glob<ResolvedComponent>('../pages/**/*.svelte', {
16+
const pages = import.meta.glob<ResolvedComponent>("../pages/**/*.svelte", {
1717
eager: true,
1818
})
1919
const page = pages[`../pages/${name}.svelte`]
@@ -35,8 +35,8 @@ createInertiaApp({
3535
mount(App, { target: el, props })
3636
} else {
3737
console.error(
38-
'Missing root element.\n\n' +
39-
'If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n' +
38+
"Missing root element.\n\n" +
39+
"If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n" +
4040
'Consider moving <%= vite_typescript_tag "inertia" %> to the Inertia-specific layout instead.',
4141
)
4242
}

eslint.config.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// eslint.config.js
2+
import js from '@eslint/js';
3+
import svelte from 'eslint-plugin-svelte';
4+
import globals from 'globals';
5+
import ts from 'typescript-eslint';
6+
import svelteConfig from './svelte.config.js';
7+
import eslintConfigPrettier from "eslint-config-prettier/flat";
8+
import importPlugin from "eslint-plugin-import"
9+
10+
export default ts.config(
11+
js.configs.recommended,
12+
...ts.configs.recommended,
13+
...svelte.configs.recommended,
14+
{
15+
languageOptions: {
16+
globals: {
17+
...globals.browser,
18+
...globals.node
19+
}
20+
}
21+
},
22+
{
23+
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
24+
// See more details at: https://typescript-eslint.io/packages/parser/
25+
languageOptions: {
26+
parserOptions: {
27+
projectService: true,
28+
extraFileExtensions: ['.svelte'], // Add support for additional file extensions, such as .svelte
29+
parser: ts.parser,
30+
// Specify a parser for each language, if needed:
31+
// parser: {
32+
// ts: ts.parser,
33+
// js: espree, // Use espree for .js files (add: import espree from 'espree')
34+
// typescript: ts.parser
35+
// },
36+
37+
// We recommend importing and specifying svelte.config.js.
38+
// By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly.
39+
// While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it,
40+
// explicitly specifying it ensures better compatibility and functionality.
41+
svelteConfig
42+
}
43+
}
44+
},
45+
{
46+
...importPlugin.flatConfigs.recommended,
47+
...importPlugin.flatConfigs.typescript,
48+
rules: {
49+
"import/order": [
50+
"error",
51+
{
52+
pathGroups: [
53+
{
54+
pattern: "@/**",
55+
group: "external",
56+
position: "after",
57+
},
58+
],
59+
"newlines-between": "always",
60+
"named": true,
61+
alphabetize: { order: "asc" },
62+
},
63+
],
64+
"import/first": "error",
65+
"import/extensions": ["error", "never", { "svg": "always", "png": "always", "jpg": "always", "webp": "always", "svelte": "always", "css": "always" }],
66+
"@typescript-eslint/consistent-type-imports": "error",
67+
},
68+
},
69+
eslintConfigPrettier,
70+
{
71+
rules: {
72+
// Override or add rule settings here, such as:
73+
// 'svelte/rule-name': 'error'
74+
}
75+
}
76+
);

0 commit comments

Comments
 (0)