Skip to content

Some variables get -- replaced to - #273

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

Open
Tofandel opened this issue Apr 8, 2025 · 1 comment · May be fixed by #275
Open

Some variables get -- replaced to - #273

Tofandel opened this issue Apr 8, 2025 · 1 comment · May be fixed by #275
Assignees
Labels
bug Something isn't working

Comments

@Tofandel
Copy link

Tofandel commented Apr 8, 2025

When using the migrator with npx sass-migrator module --migrate-deps src/theme/theme.scss

Some variables get renamed

Example

- $--color-info-light: mix($--color-white, $--color-info, 80%) !default;
- $--color-success-light: mix($--color-white, $--color-success, 80%) !default;
- $--color-warning-light: mix($--color-white, $--color-warning, 80%) !default;
- $--color-danger-light: mix($--color-white, $--color-danger, 80%) !default;
+ $-color-success-light: color.mix($-color-white, $-color-success, 80%) !default;
+ $-color-warning-light: color.mix($-color-white, $-color-warning, 80%) !default;
+ $-color-danger-light: color.mix($-color-white, $-color-danger, 80%) !default;
+ $--color-info-light: color.mix($-color-white, $-color-info, 80%) !default;

I do not want this renaming to happen, I tried with --remove-prefix=app but that changed nothing

/// If [declaration] should be renamed, adds it to [renamedMembers].
///
/// Members are renamed if they start with [prefixesToRemove] or if they start
/// with `-` or `_` and are referenced outside the stylesheet they were
/// declared in.
void _renameDeclaration(MemberDeclaration declaration) {
if (declaration.isForwarded) return;
var name = declaration.name;
if (name.startsWith('-') &&
references.referencedOutsideDeclaringStylesheet(declaration)) {
// Remove leading `-` since private members can't be accessed outside
// the module they're declared in.
name = name.substring(1);
}
name = _unprefix(name);
if (name != declaration.name) {
renamedMembers[declaration] = name;
if (_upstreamStylesheets.isEmpty) _needsImportOnly = true;
}
}

Seems there is no way to opt out, every variable starting with - will have one - removed if it's referenced outside the file

Repro:

//test.scss
@import "test2";
$color-black: $--color-black;

//test2.scss
$--color-black: #000000 !default;

npx sass-migrator module --migrate-deps test.scss

And also

npx sass-migrator module --migrate-deps test.scss --remove-prefix=--

Results in

@use "test";
$color-black: test.$-color-black;

Which is unexpected

@Tofandel
Copy link
Author

Tofandel commented Apr 8, 2025

Related issue: running the migrator with

npx sass-migrator module test.scss --remove-prefix=app

$app-color-black: #000000 !default;

Results in

$acolor-black: #000000 !default;

Instead of the expected $-color-black

@nex3 nex3 added the bug Something isn't working label Apr 8, 2025
@nex3 nex3 assigned jathak and nex3 and unassigned jathak Apr 8, 2025
@nex3 nex3 linked a pull request Apr 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants