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

Fix sass deprecation warnings #1379

Closed
wants to merge 19 commits into from
Closed

Fix sass deprecation warnings #1379

wants to merge 19 commits into from

Conversation

nmajor25
Copy link
Contributor

@nmajor25 nmajor25 commented Jan 9, 2025

Shortcut Story ID: [sc-57510]

Main deprecation updates:

  • Switch from deprecated map-get() to map.get().
  • Switch from using deprecated @import's to @use & @forward instead.
    • More info on the deprecation here.

@nmajor25 nmajor25 requested a review from paulfalgout January 9, 2025 18:08
Copy link

coderabbitai bot commented Jan 9, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nmajor25
Copy link
Contributor Author

nmajor25 commented Jan 9, 2025

I've got this PR set as a draft. I'd like to do more testing in my local dev environment. To make sure all the styles are working as before.

@@ -32,7 +32,6 @@ const css = {
scss: {
additionalData: `
@use 'sass:math';
@use 'sass:color';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't find anywhere this is being used.

@@ -1,3 +1,5 @@
@use '../provider-variables' as *;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The sass preprocessorOptions in the vite.config.js file adds @use 'src/scss/provider-variables.scss' as *; to the top of all our sass files? Or just the ones that are imported via javascript?

Because that didn't happen for these /src/scss/core sass files. I had to add these here for the $ prefixed variables to work.

Copy link
Member

Choose a reason for hiding this comment

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

imports never needed this because they were effectively combined into the provider-core file which would have the include but @forward compiles and namespaces an export rather than putting each partial into the same namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense 👍

@@ -6,8 +6,10 @@
// Main Colors
// -------------------------------------

@use 'sass:map';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eh this line should probably be placed above the Main Color comment...

Copy link
Member

@paulfalgout paulfalgout left a comment

Choose a reason for hiding this comment

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

Bah.. I dislike this change to sass.. but we gotta do something.. up for whichever TBH

@@ -1,3 +1,5 @@
@use '../provider-variables' as *;
Copy link
Member

Choose a reason for hiding this comment

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

imports never needed this because they were effectively combined into the provider-core file which would have the include but @forward compiles and namespaces an export rather than putting each partial into the same namespace

@import 'core/space';
@import 'core/text';
@import 'core/typography';
@forward 'core/reset';
Copy link
Member

Choose a reason for hiding this comment

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

So.. I'm not certain, but what we might be able to do here is:

@use '../provider-variables' as *;

@use 'core/reset';
...
@use 'core/typography';

@forward 'core/base';
...
@forward 'core/typography';

I think that would put them all in the same namespace and the export them all with the shared namespacing.. but I'm not 💯 on that.

I'm also not sure that it's better..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm interesting, that's worth investigating. Not sure if that will work either, but would be nice if it did!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't get this to work 😞

Copy link
Member

Choose a reason for hiding this comment

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

one other thought that might be a hair cleaner.. at least for now.. we could make a js file at the very top of index called provider-core-styles.js.. remove this file and all the _d file names.. or something and instead of using sass partials just import all of these at the top.. then they'd get the additionalData and we wouldn't have to add that to the partials.

@use 'sass:math';
@use 'sass:color';
@import 'src/scss/provider-variables.scss';
@use 'src/scss/provider-variables.scss' as *;
Copy link
Member

Choose a reason for hiding this comment

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

It's possible that we should remove this altogether and break up the variables into separate @use namespaces imports.. at least that seems to be what scss wants us to do.. but.. I dunno.. this pattern of having a few global scss vars hasn't hurt us at all.. and the imports would be everywhere...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So to implement this we'd need to add @use src/scss/provider-variables.scss in every .scss file? With relative paths too? Like @use ../../scss/provider-variables.scss?

When working on this I thought about doing that. But I couldn't figure out another way besides having the @use in a ton of different files.

Copy link
Member

Choose a reason for hiding this comment

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

yeah.. well I think that's sass intention in deprecating @import. They want explicit and obvious dependencies.. and for people to only use them when necessary... so they'd probably suggest against using as * and rather using as colors or something where the sass ends up color: colors.blue; In theory I agree... but in practice.. yeah.. it's so many @use when our global "if you see a $variable, you'll find it in our short list of provider-variables.scss" seems to work pretty well for us. The additionalData was always a little hacky.. but in some ways the more we fight the standard the more hacky our solutions are starting to look.. but as you said.. the alternative is just so much @use which doesn't really seem to clarify anything IMO. So I dunno. sass sucks.

Copy link

cypress bot commented Jan 10, 2025

RoundingWell Care Ops Frontend    Run #7171

Run Properties:  status check failed Failed #7171  •  git commit acb9ad814b: Add `return null;`s to our vite plugins
Project RoundingWell Care Ops Frontend
Branch Review sass-deprecations
Run status status check failed Failed #7171
Run duration 02m 45s
Commit git commit acb9ad814b: Add `return null;`s to our vite plugins
Committer Nick Major
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 312
View all changes introduced in this branch ↗︎

Tests for review

Failed  test/integration/forms/form.js • 1 failed test • care-ops-e2e

View Output

Test Artifacts
Noncontext Form > getIcd Test Replay Screenshots
Flakiness  forms/form.js • 1 flaky test • care-ops-e2e

View Output

Test Artifacts
Noncontext Form > update patient field Test Replay Screenshots
Flakiness  patients/sidebar/filter-sidebar.js • 1 flaky test • care-ops-e2e

View Output

Test Artifacts
filter sidebar > states sorted by sequence value Test Replay Screenshots

@coveralls
Copy link

Pull Request Test Coverage Report for Build 38e295ae-97d7-44e0-b97f-9314043c8c4c

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 99.987%

Totals Coverage Status
Change from base Build 47b04e92-a6eb-4322-a3cf-6fcb0cf52e1a: 0.03%
Covered Lines: 6079
Relevant Lines: 6079

💛 - Coveralls

paulfalgout and others added 15 commits January 14, 2025 11:35
ws service supports models now.
Part of the filters work, this can currently always be added
We didn’t ever use this.  Likely never will
if a socket just opens by default it’s not an issue.
It reopens during changing tests
…plugin-stylelint npm packages

To support vite 6
…external @modyfi/vite-plugin-yaml npm package

@modyfi/vite-plugin-yaml npm package is no longer being maintained and is blocking us from moving to vite v6
Temporarily setting `css.preprocessorOptions.scss.api: 'legacy'` for vite 6 to work. We will remove that at a later date when we update sass to use the modern js api
@nmajor25
Copy link
Contributor Author

Closing this PR and switching to a new one: #1382. I messed up a rebase.

@nmajor25 nmajor25 closed this Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants