Skip to content

[code-infra] Closer sync with eslint config of codebase#3441

Merged
Janpot merged 7 commits into
mui:masterfrom
oliviertassinari:sync-eslint
Apr 25, 2024
Merged

[code-infra] Closer sync with eslint config of codebase#3441
Janpot merged 7 commits into
mui:masterfrom
oliviertassinari:sync-eslint

Conversation

@oliviertassinari

@oliviertassinari oliviertassinari commented Apr 21, 2024

Copy link
Copy Markdown
Member

A step to simplify the eslint config in the codebase.

@oliviertassinari oliviertassinari added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Apr 21, 2024
Comment thread .eslintrc.js
excludedFiles: ['*.d.ts', '*.spec.ts', '*.spec.tsx'],
files: ['**'],
rules: {
'import/no-cycle': ['error', { ignoreExternal: true }],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed seems to duplicate

Comment thread .eslintrc.js
files: ['**'],
rules: {
'import/no-cycle': ['error', { ignoreExternal: true }],
'no-restricted-imports': ['error', noRestrictedImports],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added until fixed in Toolpad

Comment thread .eslintrc.js
Comment on lines -104 to -105
// Personal preference
'no-underscore-dangle': 'off',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems marginally used

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a reason. examples don't contain eslint. So the code shouldn't contain eslint comments.

@oliviertassinari oliviertassinari Apr 22, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. Should we move this rule to the share eslint config then? It feels like we want this for all /examples folders through MUI codebase.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'm good with that as well

Comment thread .eslintrc.js
Comment on lines -28 to +54
'import/prefer-default-export': ['off'],
// TODO move to @mui/monorepo, codebase is moving away from default exports
'import/prefer-default-export': 'off',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax convention (['off'] -> 'off')

Comment thread .eslintrc.js
},
],
'@typescript-eslint/return-await': 'off',
'no-restricted-imports': ['error', noRestrictedImports],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to a variable, noRestrictedImports, to be able to extend it in specific paths.

Comment thread .eslintrc.js
'material-ui/no-hardcoded-labels': 'off', // We are not really translating the docs/website anymore
},
overrides: [
...baseline.overrides,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main difference

@@ -1,3 +1,4 @@
/* eslint-disable no-underscore-dangle */

@Janpot Janpot Apr 22, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we don't add eslint disable comments in examples, but turn off the rule in an eslint override.

Reason is that eslint is not used/installed in the example, so it shouldn't contain eslint comments after I download it.

Comment thread docs/data/toolpad/studio/components/list/List.js Outdated
@Janpot

Janpot commented Apr 22, 2024

Copy link
Copy Markdown
Member

Did you see that eslint is in the process of deprecating its config format? The new format seems considerably easier to understand in terms of extending lint configs.

@oliviertassinari

oliviertassinari commented Apr 22, 2024

Copy link
Copy Markdown
Member Author

The new format seems considerably easier to understand in terms of extending lint configs.

I briefly looked at it, but saw we are on ESLint v8 not v9 so I ignored it.

I have pushed in the past to not add any of those: https://github.com/mui/material-ui/blob/next/packages/api-docs-builder/.eslintrc.js. I'm happy it won't be possible anymore. If we want to prepare the migration, we could remove more of those.

@Janpot Janpot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the naming and brought back the rule for examples. With clearer comment. Want to merge this as I see PRs coming in that would fail the new naming rules.

@Janpot
Janpot enabled auto-merge (squash) April 25, 2024 15:33
@Janpot
Janpot merged commit f50f2bf into mui:master Apr 25, 2024
@oliviertassinari
oliviertassinari deleted the sync-eslint branch May 1, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants