Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Apr 25, 2024

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Apr 21, 2024

A step to simplify the eslint config in the codebase.

@oliviertassinari oliviertassinari added the scope: code-infra Specific to the core-infra product label Apr 21, 2024
rules: {
'import/no-cycle': ['error', { ignoreExternal: true }],
Copy link
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

rules: {
'import/no-cycle': ['error', { ignoreExternal: true }],
'no-restricted-imports': ['error', noRestrictedImports],
Copy link
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

.eslintrc.js Outdated
Comment on lines 104 to 105
// Personal preference
'no-underscore-dangle': 'off',
Copy link
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
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.

Copy link
Member Author

@oliviertassinari oliviertassinari Apr 22, 2024

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
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 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
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')

},
],
'@typescript-eslint/return-await': 'off',
'no-restricted-imports': ['error', noRestrictedImports],
Copy link
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.

},
overrides: [
...baseline.overrides,
Copy link
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 */
Copy link
Member

@Janpot Janpot Apr 22, 2024

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.

@Janpot
Copy link
Member

Janpot commented Apr 22, 2024

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
Copy link
Member Author

oliviertassinari commented Apr 22, 2024

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.

Copy link
Member

@Janpot Janpot left a comment

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
12 checks passed
@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 Specific to the core-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants