-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.mjs
More file actions
114 lines (113 loc) · 3.65 KB
/
eslint.config.mjs
File metadata and controls
114 lines (113 loc) · 3.65 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
import eslint from '@eslint/js';
import json from '@eslint/json';
import nlDesignSystemConfig from '@nl-design-system/eslint-config/configs/nl-design-system.config.mjs';
import vitest from '@vitest/eslint-plugin';
import prettier from 'eslint-config-prettier';
import perfectionist from 'eslint-plugin-perfectionist';
import react from 'eslint-plugin-react';
import eslintPluginZod from 'eslint-plugin-zod';
import { defineConfig, globalIgnores } from 'eslint/config';
import tseslint from 'typescript-eslint';
export default defineConfig([
// use the built-in globalIgnores utility to globally ignore files in the project
globalIgnores(['**/dist/', '**/build/', '**/coverage/', '**/.astro/', '**/.vercel/']),
{
// Use the Perfectionist recommended/natural configuration for all possible JavaScript, TypeScript and JSX files
name: 'perfectionist/recommended/natural',
files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'],
plugins: { perfectionist },
...perfectionist.configs['recommended/natural'],
rules: {
// Sort import declarations
'perfectionist/sort-imports': [
'error',
{
ignoreCase: false,
newlinesBetween: 0,
},
],
// Sort objects sensibly, allow `id` and `name` properties to go first and `overrides` to go last
'perfectionist/sort-objects': [
'error',
{
customGroups: [
{
elementNamePattern: '^(?:id|name)$',
groupName: 'first',
selector: 'property',
},
{
elementNamePattern: '^(?:overrides)$',
groupName: 'last',
selector: 'property',
},
],
groups: ['first', 'unknown', 'last'],
},
],
},
},
{
// Use the @eslint/js recommended configuration to lint JavaScript, TypeScript, JSX and TSX files
name: 'eslint/js/recommended',
files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'],
...eslint.configs.recommended,
},
{
// Use the typescript-eslint recommended configuration to lint TypeScript and TSX files
name: 'typescript-eslint/recommended',
extends: [tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
},
{
// Use the @eslint/json recommended configuration to lint JSON files
name: 'eslint/json/recommended',
files: ['**/*.json'],
language: 'json/json',
...json.configs.recommended,
},
{
name: 'eslint-plugin-react',
files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'],
plugins: { react },
...react.configs.flat.recommended,
...react.configs.flat['jsx-runtime'],
},
{
// NL Design System specific rules
extends: [nlDesignSystemConfig],
files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'],
},
{
name: 'eslint-config-prettier',
...prettier,
},
{
name: 'eslint-plugin-zod',
...eslintPluginZod.configs.recommended,
},
{
name: '@vitest',
files: ['**/*.test.ts'],
plugins: {
vitest,
},
rules: {
...vitest.configs.recommended.rules,
'vitest/consistent-test-filename': 'error',
'vitest/consistent-test-it': [
'error',
{
fn: 'it',
withinDescribe: 'it',
},
],
'vitest/consistent-vitest-vi': 'error', // error when calling `vitest.mock()` instead of `vi.mock()`
'vitest/no-focused-tests': ['warn', { fixable: false }], // Warn when using it.only(), do not auto-fix
'vitest/prefer-each': 'error', // prefer it.each([a, b])('test %s', (thing) => {})
'vitest/prefer-todo': 'warn', // warn when test has empty or no body
'vitest/valid-title': ['error', { allowArguments: true }],
'vitest/warn-todo': ['warn'],
},
},
]);