-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.base.js
More file actions
82 lines (81 loc) · 2.44 KB
/
Copy patheslint.config.base.js
File metadata and controls
82 lines (81 loc) · 2.44 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
import prettier from 'eslint-config-prettier';
import js from '@eslint/js';
import { includeIgnoreFile } from '@eslint/compat';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import ts from 'typescript-eslint';
// The linted code lives in the workspaces, and each has a Svelte config and an
// ignore file of its own: they call this with theirs.
export default function config({ svelteConfig, gitignorePath }) {
return ts.config(
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs.recommended,
prettier,
...svelte.configs.prettier,
{
languageOptions: {
globals: { ...globals.browser, ...globals.node }
},
rules: {
'no-undef': 'off',
// A leading underscore is how the code already says a binding is
// there for its position, not for its value.
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
],
'no-restricted-syntax': [
'error',
{
selector: 'TSAsExpression[typeAnnotation.type="TSUnknownKeyword"]',
message:
'`as unknown as` turns off every check between the two types. Fix the type where it is declared, or narrow with a type guard.'
}
]
}
},
{
// Every service editor is handed the same props by the loader that
// mounts it, which knows the contract while the service does not:
// leaving out the ones a given editor has no use for would make each
// signature differ from the next for no reason.
files: ['**/lib/services/*/editor.svelte'],
rules: {
'svelte/no-unused-props': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^(_|dn$|origin$|readonly$|type$)',
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
]
}
},
{
// Fixtures stand in for models a test does not fully build, and
// generated clients answer to their generator, not to this rule.
files: ['**/*.test.ts', '**/*.spec.ts', '**/*.gen.ts'],
rules: { 'no-restricted-syntax': 'off' }
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
languageOptions: {
parserOptions: {
projectService: true,
extraFileExtensions: ['.svelte'],
parser: ts.parser,
svelteConfig
}
}
}
);
}