forked from Dsek-LTH/web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
84 lines (84 loc) · 3.01 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/stylistic",
// "plugin:@typescript-eslint/recommended-type-checked", // type-checked rules seem to not understand svelte's generated types
"plugin:svelte/recommended",
"plugin:svelte/prettier",
"prettier",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
parserOptions: {
// project: true, // TODO: enable for type-checked rules
// tsconfigRootDir: __dirname, // TODO: enable for type-checked rules
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",
},
},
],
reportUnusedDisableDirectives: true,
/**
* Rule overrides and additions.
* In general, we want to use the recommended rules.
* However, there are some aspects that we may want to be stricter about
* to keep the code more maintainable.
*/
rules: {
"eslint-comments/require-description": "warn", // Helpful for understanding why a rule is disabled.
"no-restricted-imports": [
// Forces the folder structure to reflect the dependency graph.
// This makes it easier to understand how code may be coupled.
"warn",
{
patterns: [
{
// any path beginning with ../ and ending with /<folder>/<file>
// e.g. import { foo } from "../bar/baz";
group: ["../**/*[a-zA-Z0-9_-]*/*"],
message:
"\nIt looks like you're importing from a different subtree. " +
"Consider whether the imported code should really be shared. Suggestions:\n" +
"1) Write new code specific to your usage.\n" +
"2) Move the imported code to a shared location, e.g. a parent folder.\n" +
"3) Verify that you're using the correct path alias, e.g. $lib.",
},
{
importNamePattern: "^(goto|redirect)",
group: [
"$app/navigation",
"sveltekit-flash-message/server",
"@sveltejs/kit",
],
message:
"Use the goto and redirect wrappers from $lib/utils/redirect instead",
},
{
importNamePattern: "^(superForm)",
group: ["sveltekit-superforms", "sveltekit-superforms/client"],
message:
"Use the superForm from $lib/utils/client/superForms instead",
},
],
},
],
"@typescript-eslint/consistent-type-definitions": "off", // Using either type or interface is fine.
"@typescript-eslint/array-type": ["error", { default: "array-simple" }], // When defining arrays of complex types, use the `Array<type>` syntax.
},
};