Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
149 lines (147 loc) · 3.95 KB
/
Copy patheslint.config.mjs
File metadata and controls
149 lines (147 loc) · 3.95 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
import { defineConfig } from 'eslint/config';
import {
createBaseConfig,
createTestConfig,
createDocsConfig,
EXTENSION_TEST_FILE,
EXTENSION_TS,
} from '@mui/internal-code-infra/eslint';
import { lintJavascriptDemoFocus } from '@mui/internal-docs-infra/pipeline/lintJavascriptDemoFocus';
import remarkConfig from './.remarkrc.mjs';
const config = defineConfig(
createBaseConfig({
baseDirectory: import.meta.dirname,
}),
// eslint-plugin-mdx loads `.remarkrc.mjs` itself, but ESLint doesn't know
// that file is a config dependency, so `--cache` doesn't invalidate when
// it changes. Embedding the imported value in a setting puts its content
// into the resolved-config hash, forcing cache invalidation on edits.
{ settings: { remarkConfig } },
{
files: [`**/*${EXTENSION_TS}`],
rules: {
// Not needed in this repo
'compat/compat': 'off',
// No time for this
'react/prop-types': 'off',
'jsx-a11y/control-has-associated-label': 'off',
'jsx-a11y/no-autofocus': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
// Enforce using node: protocol for builtin modules
'n/prefer-node-protocol': 'error',
'mui/material-ui-no-empty-box': 'off',
'mui/no-presentation-role': 'error',
},
settings: {
'import/resolver': {
typescript: {
project: ['tsconfig.json'],
},
},
},
},
{
files: [
// Matching the pattern of the test runner
`**/*${EXTENSION_TEST_FILE}`,
],
extends: createTestConfig(),
},
{
files: [`packages/docs-infra/**/*${EXTENSION_TEST_FILE}`],
rules: {
// TODO @dav-is
'vitest/no-conditional-expect': 'off',
},
},
{
files: [`packages/typescript-api-extractor/**/*${EXTENSION_TS}`],
rules: {
// The TypeScript compiler API reports symbol, type, and node flags as bit sets.
'no-bitwise': 'off',
},
},
{
files: [`packages/typescript-api-extractor/**/*${EXTENSION_TEST_FILE}`],
rules: {
'vitest/expect-expect': [
'error',
{
assertFunctionNames: [
'expect',
'expectTypeOf',
'expectKind',
'expectExternalAliases',
'expectReferenceFormExports',
],
},
],
},
},
{
files: ['docs/**/*'],
extends: createDocsConfig(),
settings: {
'import/resolver': {
typescript: {
project: ['docs/tsconfig.json'],
},
},
},
rules: {
'@next/next/no-img-element': 'off',
},
},
{
files: ['docs/app/**/demos/**/*.tsx', 'docs/app/**/demos/**/*.jsx'],
// page.tsx/page.jsx are Next.js route wrappers, not demo previews, so they
// are exempt from the demo-focus rule at any demo depth (including the
// nested "demo of demo" structure, demos/<slug>/demo-*/page.tsx).
ignores: ['docs/app/**/demos/*/page.tsx', 'docs/app/**/demos/*/page.jsx'],
plugins: {
'docs-infra': { rules: { 'require-demo-focus': lintJavascriptDemoFocus } },
},
rules: {
'docs-infra/require-demo-focus': ['error', { wrapReturn: true }],
},
},
{
files: [`apps/**/*${EXTENSION_TS}`],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
files: ['renovate/**/*.json'],
language: 'json/jsonc',
},
{
// The babel plugin packages are ESM-only, so relative imports carry their extension.
files: [`packages/babel-*/**/*${EXTENSION_TS}`],
rules: {
'import/extensions': [
'error',
'ignorePackages',
{
js: 'always',
mjs: 'always',
},
],
},
},
{
files: [`packages/bundle-size-checker/**/*${EXTENSION_TS}`],
rules: {
// Allow .js file extensions in import statements for ESM compatibility
'import/extensions': [
'error',
'ignorePackages',
{
js: 'always',
mjs: 'always',
},
],
},
},
);
export default config;