-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.ts
More file actions
123 lines (120 loc) · 3.6 KB
/
eslint.config.ts
File metadata and controls
123 lines (120 loc) · 3.6 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
import type { ESLint } from 'eslint';
import tanstackQueryPlugin from '@tanstack/eslint-plugin-query';
import { getConfig } from '@xsynaptic/eslint-config';
import astroPlugin from 'eslint-plugin-astro';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';
const isStrictLint = process.env.ESLINT_STRICT === '1';
export default getConfig(
[
{
ignores: [
'node_modules/**/*',
'**/.astro/**/*',
'**/.cache/**/*',
'**/dist/**/*',
'deploy/**/*',
'packages/content/**/*',
'**/.mdxlintrc.mjs',
'**/temp/**/*',
],
},
{
rules: {
// Conflicts with Remeda's sort function
'unicorn/no-array-sort': 'off',
// Conflicts with Prettier, which always uppercases hex digits and is not configurable
'unicorn/number-literal-case': 'off',
// Expensive type-aware rules; only run in strict mode
'@typescript-eslint/no-deprecated': isStrictLint ? 'error' : 'off',
'@typescript-eslint/no-unsafe-assignment': isStrictLint ? 'error' : 'off',
'@typescript-eslint/no-misused-promises': isStrictLint ? 'error' : 'off',
},
},
/**
* JSX
*/
{
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts', '**/*.astro'],
rules: {
'no-restricted-syntax': [
'error',
{
message:
'Use a ternary returning undefined (condition ? <Element /> : undefined) instead of && for conditional rendering.',
selector:
':matches(JSXElement, JSXFragment) > JSXExpressionContainer > LogicalExpression[operator="&&"]',
},
],
},
},
/**
* React
*/
{
files: ['packages/react-map-component/**/*.{js,jsx,ts,tsx}'],
plugins: {
'@tanstack/query': tanstackQueryPlugin as unknown as ESLint.Plugin,
'react-hooks': reactHooksPlugin as unknown as ESLint.Plugin,
},
rules: {
...tanstackQueryPlugin.configs.recommended.rules,
...reactHooksPlugin.configs['recommended-latest'].rules,
'react-hooks/component-hook-factories': 'warn',
'react-hooks/config': 'warn',
'react-hooks/error-boundaries': 'warn',
'react-hooks/gating': 'warn',
'react-hooks/globals': 'warn',
'react-hooks/immutability': 'warn',
'react-hooks/incompatible-library': 'warn',
'react-hooks/preserve-manual-memoization': 'warn',
'react-hooks/purity': 'warn',
'react-hooks/refs': 'warn',
'react-hooks/set-state-in-effect': 'warn',
'react-hooks/set-state-in-render': 'warn',
'react-hooks/static-components': 'warn',
'react-hooks/unsupported-syntax': 'warn',
'react-hooks/use-memo': 'warn',
},
},
// These files run in the browser and might need the browser globals
{
files: ['src/components/**/*'],
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.node).map(([key]) => [key, 'off'])),
...globals.browser,
},
},
rules: {
// This conflicts with how some client-side code is handled
'unicorn/prefer-global-this': 'off',
},
},
/**
* Astro
*/
...astroPlugin.configs['flat/recommended'],
...astroPlugin.configs['jsx-a11y-strict'],
// Split into two blocks so disableTypeChecked doesn't clobber our parserOptions
{
files: ['**/*.astro'],
languageOptions: {
parserOptions: {
parser: tseslint.parser,
extraFileExtensions: ['.astro'],
},
},
},
// Type-aware rules can't properly resolve types in .astro files; `astro check` handles this
// Keep frontmatter thin and push logic into .ts files for full lint coverage
{
files: ['**/*.astro'],
...tseslint.configs.disableTypeChecked,
},
],
{
customGlobals: { mode: 'readonly' },
},
);