-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy patheslint.config.mjs
More file actions
172 lines (160 loc) · 5.07 KB
/
eslint.config.mjs
File metadata and controls
172 lines (160 loc) · 5.07 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import { defineConfig, globalIgnores } from 'eslint/config';
import js from '@eslint/js';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import reactHooks from 'eslint-plugin-react-hooks';
import importPlugin from 'eslint-plugin-import';
import tsParser from '@typescript-eslint/parser';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import stylistic from '@stylistic/eslint-plugin';
import prettier from 'eslint-plugin-prettier';
import jsdoc from 'eslint-plugin-jsdoc';
import eslintConfigPrettier from 'eslint-config-prettier';
import globals from 'globals';
import pluginNext from '@next/eslint-plugin-next';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default defineConfig([
// Global ignores
globalIgnores([
'lib/',
'packages/*/node_modules/',
'packages/*/lib/',
'packages/*/dist/',
'packages/create-content-sdk-app/src/templates/**/*',
'packages/create-content-sdk-app/src/templates/**/*.json',
]),
// Global linter settings
{
linterOptions: {
reportUnusedDisableDirectives: false,
},
},
// Base JS/TS config
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
parser: tsParser,
ecmaVersion: 2020,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
es6: true,
},
},
plugins: {
'@next/next': pluginNext,
'@typescript-eslint': typescriptEslint,
'@stylistic': stylistic,
'react-hooks': reactHooks,
import: importPlugin,
prettier,
jsdoc,
},
rules: {
...(pluginNext.configs?.recommended?.rules ?? {}),
...(pluginNext.configs?.['core-web-vitals']?.rules ?? {}),
'@next/next/no-html-link-for-pages': 'off',
'@next/next/no-img-element': 'off',
'@next/next/no-sync-scripts': 'off',
'@next/next/no-assign-module-variable': 'off',
// Include ESLint recommended rules
...(js.configs?.recommended?.rules ?? {}),
// Include JSDoc recommended rules
...(jsdoc.configs?.recommended?.rules ?? {}),
// JSDoc relaxations
'jsdoc/newline-after-description': 'off',
'jsdoc/require-property-description': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/no-undefined-types': 'off',
'jsdoc/require-returns-type': 'off',
// General
'no-use-before-define': 'off',
'no-useless-escape': 'off',
'no-unused-vars': ['error'],
'no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
},
],
'spaced-comment': 'error',
curly: ['error', 'multi-line'],
'eol-last': ['error', 'always'],
'guard-for-in': 'error',
'no-unused-labels': 'error',
'no-caller': 'error',
'no-bitwise': 'error',
'no-multiple-empty-lines': 'error',
'no-new-wrappers': 'error',
'no-eval': 'error',
'dot-notation': 'error',
'no-trailing-spaces': 'error',
'brace-style': 'error',
quotes: ['error', 'single'],
radix: 'error',
'default-case': 'error',
eqeqeq: 'error',
'jsx-quotes': ['error', 'prefer-double'],
// Formatting
'prettier/prettier': 'off', // handled via specific rules below
'@stylistic/space-before-function-paren': [
'error',
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
},
],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'import/no-anonymous-default-export': 'error',
// Prettier conflict resolution - must come LAST to override conflicting rules
...eslintConfigPrettier.rules,
},
},
// TypeScript-specific overrides
{
files: ['packages/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'typeLike',
format: ['PascalCase'],
custom: { regex: '^I[A-Z]', match: false },
},
],
'no-undef': 'off',
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/typedef': 'error',
'@typescript-eslint/no-use-before-define': ['error', { functions: false, variables: false }],
'@stylistic/type-annotation-spacing': 'error',
'@stylistic/semi': 'error',
// Relaxed TS rules
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
// Jest test files: enable Jest globals (describe, it, beforeEach, etc.)
{
files: ['**/*.test.{js,jsx,ts,tsx}', '**/__tests__/**/*.{js,jsx,ts,tsx}'],
languageOptions: {
globals: {
...globals.jest
},
},
},
]);