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

[core] Remove file-wide disables of no-use-before-define #27984

Merged
merged 2 commits into from
Aug 30, 2021

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Aug 27, 2021

We've had two remaining instances of file-wide disables of no-use-before-define:

  1. demos with data
  2. colorManipulator

It's clear that no-use-before-define is just a hinderance in the demo sources. The goal is usually to declare the data after the component implementation since the component implementation is more relevant than the data.

This temporal dead zone (TDZ) is safe since components aren't rendered until the module is completely evaluated.

This will allow actuall unsafe TDZs but so far we haven't had any issues in demos.

For colorManipulator we can resolve it by just re-ordering the function declarations. We generally don't rely on hoisting of function declarations (since it's potentially unsafe with let/const) so let's not start in one-off instances.

@eps1lon eps1lon added the core Infrastructure work going on behind the scenes label Aug 27, 2021
@eps1lon eps1lon force-pushed the test/no-use-before-define-demos branch from 7c4230f to 2a2d4c8 Compare August 27, 2021 10:01
@mui-pr-bot
Copy link

mui-pr-bot commented Aug 27, 2021

Details of bundle changes (experimental)

Generated by 🚫 dangerJS against 2a2d4c8

@eps1lon eps1lon marked this pull request as ready for review August 27, 2021 10:26
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

👌 It's great that we don't have to add eslint-disabled for this in the demos

@eps1lon eps1lon merged commit 3c4d70e into mui:next Aug 30, 2021
@eps1lon eps1lon deleted the test/no-use-before-define-demos branch August 30, 2021 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants