Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 59 additions & 57 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,70 @@ import {
} from '@mui/internal-code-infra/eslint';
import nPlugin from 'eslint-plugin-n';

export default defineConfig(
createBaseConfig({ baseDirectory: import.meta.dirname }),
{
files: [`**/*${EXTENSION_TS}`],
plugins: {
n: nPlugin,
export default /** @type {import('eslint').Linter.Config[]} */ (
defineConfig(
createBaseConfig({ baseDirectory: import.meta.dirname }),
{
files: [`**/*${EXTENSION_TS}`],
plugins: {
n: nPlugin,
},
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',
'material-ui/no-empty-box': 'off',
},
settings: {
'import/resolver': {
typescript: {
project: ['tsconfig.json'],
},
},
},
},
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',
'material-ui/no-empty-box': 'off',
{
files: [
// matching the pattern of the test runner
`**/*${EXTENSION_TEST_FILE}`,
],
extends: createTestConfig(),
},
settings: {
'import/resolver': {
typescript: {
project: ['tsconfig.json'],
},
{
files: [`apps/**/*${EXTENSION_TS}`],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
},
{
files: [
// matching the pattern of the test runner
`**/*${EXTENSION_TEST_FILE}`,
],
extends: createTestConfig(),
},
{
files: [`apps/**/*${EXTENSION_TS}`],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
{
files: ['renovate/**/*.json'],
language: 'json/jsonc',
},
},
{
files: ['renovate/**/*.json'],
language: 'json/jsonc',
},
{
files: [`packages/babel-*/**/*${EXTENSION_TS}`],
rules: {
'@typescript-eslint/no-require-imports': 'off',
{
files: [`packages/babel-*/**/*${EXTENSION_TS}`],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
},
{
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',
},
],
{
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',
},
],
},
},
},
)
);
2 changes: 1 addition & 1 deletion packages/code-infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@babel/preset-typescript": "^7.28.5",
"@eslint/compat": "^1.4.0",
"@eslint/js": "^9.38.0",
"@eslint/json": "^0.13.2",
"@eslint/json": "^0.14.0",
"@inquirer/confirm": "^5.1.19",
"@inquirer/select": "^4.4.0",
"@mui/internal-babel-plugin-display-name": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/code-infra/src/eslint/material-ui/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ const airbnbJsxA11y = {
/**
* @param {Object} [options]
* @param {boolean} [options.enableReactCompiler] - Whether the config is for spec files.
* @returns {import('eslint').Linter.Config[]}
*/
export function createCoreConfig(options = {}) {
return defineConfig([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ const rule = {
callee.name === 'useDefaultProps' || callee.name === 'useThemeProps';
if (isUseDefaultPropsCall) {
let isCalledFromCustomHook = false;
let { parent } = node;
/** @type {import('eslint').Rule.Node | null} */
let parent = node.parent;
while (parent != null) {
if (parent.type === 'FunctionExpression' || parent.type === 'FunctionDeclaration') {
if (
Expand All @@ -112,7 +113,8 @@ const rule = {

if (nameLiteral !== null) {
let componentName = null;
let { parent } = node;
/** @type {import('eslint').Rule.Node | null} */
let parent = node.parent;
while (parent != null && componentName === null) {
if (parent.type === 'FunctionExpression' || parent.type === 'FunctionDeclaration') {
componentName = /** @type {import('estree').Identifier} */ (parent.id).name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export default {
* @param {import("estree").CallExpression & import("eslint").Rule.NodeParentExtension} hookCallNode
*/
function getComponentBlockNode(hookCallNode) {
/** @type {import("eslint").Rule.Node | null} */
let node = hookCallNode.parent;
while (node !== undefined) {
while (node) {
if (node.type === 'BlockStatement') {
return node;
}
Expand Down
Loading
Loading