-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy patheslint.config.js
More file actions
151 lines (150 loc) · 4.07 KB
/
Copy patheslint.config.js
File metadata and controls
151 lines (150 loc) · 4.07 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
import svelte_config from '@sveltejs/eslint-config';
import noExportsToRuntimeImports from './.eslint/no-exports-to-runtime-imports.js';
import noRuntimeToExportsImports from './.eslint/no-runtime-to-exports-imports.js';
import requirePathToFileURL from './.eslint/require-path-to-file-url.js';
/** @type {import('eslint').Linter.Config[]} */
export default [
...svelte_config,
{
rules: {
'no-undef': 'off',
// we have some non-reactive state in our runtime modules, and we don't want to be nagged about it
'svelte/prefer-svelte-reactivity': 'off'
}
},
{
files: ['packages/kit/src/exports/**/*.js'],
plugins: {
'kit-exports-custom': {
rules: {
'no-exports-to-runtime-imports': noExportsToRuntimeImports
}
}
},
rules: {
'kit-exports-custom/no-exports-to-runtime-imports': 'error'
}
},
{
files: ['packages/kit/src/runtime/**/*.js'],
plugins: {
'kit-custom': {
rules: {
'no-runtime-to-exports-imports': noRuntimeToExportsImports
}
}
},
rules: {
'kit-custom/no-runtime-to-exports-imports': 'error'
}
},
{
// code that ends up in user bundles must not pull in Vite or the build pipeline
files: [
'packages/kit/src/runtime/**/*.js',
'packages/kit/src/exports/**/*.js',
'packages/kit/src/utils/**/*.js'
],
ignores: ['packages/kit/src/exports/vite/**'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['vite', '**/vite/**', '**/core/**', '**/cli.js', '**/runner.js'],
message:
'This code is bundled into user apps and must not import Vite or the build pipeline (src/core, src/exports/vite).'
}
]
}
]
}
},
{
// code that runs in Node, where dynamic imports of absolute paths
// need `pathToFileURL` to work on Windows
files: [
'packages/kit/src/**/*.js',
'packages/adapter-*/*.js',
'packages/adapter-*/src/**/*.js',
'packages/package/src/**/*.js'
],
// the client runtime's dynamic imports are resolved by vite, not Node
ignores: ['packages/kit/src/runtime/**'],
plugins: {
'kit-node-custom': {
rules: {
'require-path-to-file-url': requirePathToFileURL
}
}
},
rules: {
'kit-node-custom/require-path-to-file-url': 'error'
}
},
{
ignores: [
'**/.svelte-kit',
'**/.netlify',
'**/.vercel',
'**/.wrangler',
'**/test-results',
'**/dist',
'**/.custom-out-dir',
'packages/adapter-node/files',
'packages/kit/src/core/config/fixtures/multiple', // dir contains svelte config with multiple extensions tripping eslint
'packages/kit/src/core/sync/create_manifest_data/test/samples/**/*',
'packages/kit/src/core/sync/write_types/test/*/**/*',
'packages/kit/types/index.d.ts', // generated file
'packages/*/test/apps/**/*',
'packages/*/test/**/build/**',
'packages/kit/test/build-errors/**/*',
'packages/kit/test/prerendering/**/*',
'packages/test-redirect-importer/index.js',
'packages/package/test/errors/**/*',
'packages/package/test/fixtures/**/*',
'packages/package/test/watch/expected/**/*',
'packages/package/test/watch/package/**/*',
'packages/adapter-node/smoke.spec_disabled.js'
]
},
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['packages/kit/src/runtime/app/service-worker/index.js']
}
}
},
rules: {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': [
'error',
{
// we turn these off because it's common to pass an async callback to
// a synchronous callback parameter such as `setTimeout(...)`
checksVoidReturn: {
arguments: false,
properties: false
}
}
],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true
}
]
}
}
];