-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy patheslint.config.js
More file actions
183 lines (176 loc) · 5.04 KB
/
Copy patheslint.config.js
File metadata and controls
183 lines (176 loc) · 5.04 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* https://sveltejs.github.io/eslint-plugin-svelte/user-guide/ */
import js from '@eslint/js'
import markdown from '@eslint/markdown'
import { getIgnores } from './scripts/utils/ignores.js'
import prettier from 'eslint-config-prettier'
import svelte from 'eslint-plugin-svelte'
import { defineConfig, globalIgnores } from 'eslint/config'
import globals from 'globals'
import ts from 'typescript-eslint'
import emptyMarkdownLinks from './eslint/plugin-empty-markdown-links.js'
import markdownScripts from './eslint/plugin-markdown-scripts.js'
import svelteConfig from './svelte.config.js'
// See https://typescript-eslint.io/troubleshooting/typed-linting/performance#changes-to-extrafileextensions-with-projectservice
const EXTRA_FILE_EXTENSIONS = ['.svelte']
export default defineConfig(
js.configs.recommended,
...ts.configs.recommended,
prettier,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
},
parserOptions: {
extraFileExtensions: EXTRA_FILE_EXTENSIONS,
project: ['./tsconfig.check.json']
}
}
},
{
ignores: getIgnores()
},
{
ignores: ['**/*.md'],
extends: [
// Just warn about type-checked rules for now
ts.configs.recommendedTypeCheckedOnly.map((config) => {
if (!config.rules) return config
const warnedRules = Object.fromEntries(
Object.entries(config.rules).map(([key, value]) => [key, value.replace('error', 'warn')])
)
return { ...config, rules: warnedRules }
})
]
},
{
files: ['**/*.md'],
extends: [markdown.configs.recommended],
plugins: {
emptyMarkdownLinks
},
rules: {
'markdown/fenced-code-language': 'off',
'markdown/no-missing-atx-heading-space': 'off', // rule is broken
'markdown/no-missing-label-refs': 'off',
'markdown/require-alt-text': 'warn',
'no-irregular-whitespace': 'off', // not supported by markdown parser
'emptyMarkdownLinks/no-empty-link-text': 'error'
}
},
{
files: ['src/posts/**/*.md'],
plugins: {
markdownScripts
},
rules: {
'markdownScripts/no-script-with-src': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'heading[depth=1]',
message: 'h1 is disallowed in posts. The title is already provided in the frontmatter.'
}
]
}
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
extends: [svelte.configs.recommended],
// See more details at: https://typescript-eslint.io/packages/parser/
languageOptions: {
parserOptions: {
project: ['./tsconfig.json'],
// Defined globally instead:
// extraFileExtensions: ['.svelte'], // Add support for additional file extensions, such as .svelte
parser: ts.parser,
// Specify a parser for each language, if needed:
// parser: {
// ts: ts.parser,
// js: espree, // Use espree for .js files (add: import espree from 'espree')
// typescript: ts.parser
// },
// We recommend importing and specifying svelte.config.js.
// By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly.
// While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it,
// explicitly specifying it ensures better compatibility and functionality.
svelteConfig
}
},
rules: {
// Override or add rule settings here, such as:
// 'svelte/rule-name': 'error'
// disabled
'svelte/no-navigation-without-resolve': 'off',
'svelte/require-each-key': 'off',
'no-useless-assignment': 'off', // False positive due to Svelte's reactive syntax
// enabled
'svelte/no-restricted-html-elements': [
'warn',
{
elements: ['a'],
message:
'Use $lib/components/Link.svelte or $lib/components/LinkWithoutIcon.svelte instead'
}
],
'svelte/html-self-closing': 'warn',
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/custom'],
message:
'This component serves as an adapter for mdsvex, import the corresponding component directly instead'
}
]
}
]
}
},
{
rules: {
// configured
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
]
}
},
{
files: ['src/**/*'],
rules: {
'no-restricted-properties': [
'error',
{
object: 'process',
property: 'env',
message: 'Use $env/static/private or $env/dynamic/private (or $lib/env.server) instead'
}
],
'no-restricted-syntax': [
'error',
{
// selector for import.meta.env
selector: 'MemberExpression[object.type="MetaProperty"][property.name="env"]',
message: 'Use $env/static/public or $env/dynamic/public (or $lib/env) instead'
},
{
selector:
'CallExpression[callee.name=/^(asError|redirectAsError)$/]:not(ThrowStatement > CallExpression)',
message:
'Use asError and redirectAsError only as `throw asError(...)` or `throw redirectAsError(...)`.'
}
]
}
},
globalIgnores([
// TODO remove when done
'src/routes/api/write',
'src/routes/write'
])
)