-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy patheslint.config.mjs
More file actions
132 lines (113 loc) · 3.51 KB
/
eslint.config.mjs
File metadata and controls
132 lines (113 loc) · 3.51 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
import eslint from '@eslint/js'
import json from '@eslint/json'
import markdown from '@eslint/markdown'
import tsPlugin from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import vitest from '@vitest/eslint-plugin'
import eslintConfigPrettier from 'eslint-config-prettier'
import baselineJs from 'eslint-plugin-baseline-js'
import importPlugin from 'eslint-plugin-import-x'
import perfectionist from 'eslint-plugin-perfectionist'
import { defineConfig } from 'eslint/config'
import globals from 'globals'
import { baselineRules, coreRules, importRules, perfectionistRules, tsRules } from './eslint.rules.mjs'
import reactIconsConfig from './packages-proprietary/react-icons/eslint.config-partial.mjs'
import reactConfig from './packages/react/eslint.config-partial.mjs'
import storybookConfig from './storybook/eslint.config-partial.mjs'
const jsAndTsFiles = ['**/*.{js,jsx,mjs,ts,tsx}']
const testFiles = ['**/*.{test,spec}.{js,jsx,ts,tsx}']
const nodeScriptFiles = ['**/*.{config,setup}.{js,mjs,ts}', '**/rollup.config.mjs', 'plopfile.mjs']
export default defineConfig([
// Global
{
name: 'amsterdam-design-system/global-ignores',
ignores: ['**/vendor/', '**/build/', '**/coverage/', '**/dist/', '**/tmp/', '**/AGENTS.md'],
},
{
name: 'amsterdam-design-system/linter-options',
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
{
name: 'amsterdam-design-system/language-options',
files: jsAndTsFiles,
languageOptions: {
globals: { ...globals.browser, ...globals.es6 },
},
},
{
// Keep Node globals scoped to tooling and config scripts.
name: 'amsterdam-design-system/node-language-options',
files: nodeScriptFiles,
languageOptions: {
globals: { ...globals.node },
},
},
// JavaScript and TypeScript
{
name: 'amsterdam-design-system/javascript-typescript',
extends: [eslint.configs.recommended, perfectionist.configs['recommended-natural']],
files: jsAndTsFiles,
languageOptions: {
parser: tsParser,
},
plugins: {
'@typescript-eslint': tsPlugin,
'baseline-js': baselineJs,
'import-x': importPlugin,
},
rules: {
...tsRules,
...coreRules,
...baselineRules,
...importRules,
...perfectionistRules,
},
settings: {
'import-x/resolver': {
typescript: true,
},
},
},
// Tests
{
name: 'amsterdam-design-system/tests',
extends: [vitest.configs.recommended],
files: testFiles,
languageOptions: {
globals: { ...vitest.environments.env.globals },
},
},
// React (owned by packages/react/eslint.config-partial.mjs)
...reactConfig,
// React-icons (owned by packages-proprietary/react-icons/eslint.config-partial.mjs)
...reactIconsConfig,
// JSON
{
...json.configs.recommended,
name: 'amsterdam-design-system/json',
files: ['**/*.json'],
language: 'json/json',
},
// Markdown
{
name: 'amsterdam-design-system/markdown',
files: ['**/*.md'],
ignores: ['CHANGELOG.md'],
plugins: { markdown },
processor: 'markdown/markdown',
rules: {
...markdown.configs.recommended.rules,
'markdown/line-length': 'off',
'markdown/no-inline-html': 'off',
},
},
// MDX and Storybook (owned by storybook/eslint.config-partial.mjs)
...storybookConfig,
// Prettier — must be last so it can override stylistic rules from earlier presets
{
name: 'amsterdam-design-system/prettier',
...eslintConfigPrettier,
},
])