-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
121 lines (115 loc) · 3.02 KB
/
eslint.config.js
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
import js from '@eslint/js';
import sveltePlugin from 'eslint-plugin-svelte';
import svelteParser from 'svelte-eslint-parser';
import tseslint from 'typescript-eslint';
import tsParser from '@typescript-eslint/parser';
import prettierPlugin from 'eslint-plugin-prettier';
import stylistic from '@stylistic/eslint-plugin';
import globals from 'globals';
const globalConfigs = [
stylistic.configs['recommended-flat'],
{
/**
* These are rules that will apply across all JavaScript,
* TypeScript, and Svelte files.
*/
files: ['**/*.js', '**/*.ts', '**/*.svelte'],
rules: {
'@stylistic/semi': ['error', 'always'],
'@stylistic/block-spacing': ['error', 'always'],
'@stylistic/space-before-function-paren': ['error', 'always'],
},
},
];
const jsConfigsArray = [
js.configs.recommended,
{
files: ['**/*.js'],
languageOptions: {
globals: {
...globals.node,
},
},
plugins: {
'prettier': prettierPlugin,
'@stylistic': stylistic,
},
},
];
const tsConfigsArray = [
...tseslint.config(...tseslint.configs.recommended, ...tseslint.configs.stylistic),
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
globals: {
...globals.browser,
},
},
plugins: {
'@stylistic': stylistic,
},
},
];
const svelteConfigsArray = [
...sveltePlugin.configs['flat/recommended'],
{
files: ['**/*.svelte'],
languageOptions: {
parser: svelteParser,
parserOptions: {
/**
* The `parser` option allows us to specify a parser for
* <script> tags in the Svelte file. Because we're using
* <script lang="ts">, we will specify TypeScript as our
* preferred parser.
*/
parser: {
ts: tsParser,
},
extraFileExtensions: ['.svelte'],
},
globals: {
/**
* This pulls-in variables that are global within the
* browser context (e.g., `document`, `console`, etc.).
*/
...globals.browser,
},
},
plugins: {
/**
* Because we specify `files` above, the plugins listed
* below will be available only to the files specified.
*/
'prettier': prettierPlugin,
'@stylistic': stylistic,
},
rules: {
'svelte/indent': 'error',
'indent': 'off',
'svelte/html-quotes': [
'error',
{
prefer: 'double',
dynamic: {
quoted: true,
},
},
],
},
},
];
const final = [
/**
* Important to note that each configuration array may contain
* properties or rules that override a previous configuration.
* If you notice that a rule is not being applied, it may be
* that a later configuration is overriding the rule.
*/
...globalConfigs,
...jsConfigsArray,
...tsConfigsArray,
...svelteConfigsArray,
];
export default final;