Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic support for namespacing get-function calls (#13)
* Add ability to test printed text during migration * Add basic support for namespacing get-function Resolves #11. If the argument passed to get-function is a string literal, we'll add a namespace if necessary. For all other get-function calls, we'll emit a warning saying that a namespace may be required. We might eventually be able to detect some of these with some more sophisticated logic here, but for now we'll just handle the basics. * Use correct syntax for get-function migration Also changes warning message to use span.message and updates tests to use only ASCII characters for checking log. * Quote namespace and add additional tests * Add comment about module named "true"
- Loading branch information
Showing
5 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<==> input/entrypoint.scss | ||
@import "library"; | ||
@import "true"; | ||
|
||
$fn1: get-function(increment); | ||
// This function's namespace is `true`, which is a boolean when unquoted. | ||
// This tests that the $module parameter is a quoted string. | ||
$fn2: get-function($name: "false"); | ||
$fn3: get-function("str-length"); | ||
$fn4: get-function("incre" + "ment"); | ||
|
||
$x: "increment"; | ||
$fn5: get-function($x); | ||
|
||
<==> input/_library.scss | ||
@function increment($x) { | ||
@return $x + 1; | ||
} | ||
|
||
<==> input/_true.scss | ||
@function false($x) { | ||
@return not $x; | ||
} | ||
|
||
<==> output/entrypoint.scss | ||
@use "sass:meta"; | ||
@use "sass:string"; | ||
@use "library"; | ||
@use "true"; | ||
|
||
$fn1: meta.get-function(increment, $module: "library"); | ||
// This function's namespace is `true`, which is a boolean when unquoted. | ||
// This tests that the $module parameter is a quoted string. | ||
$fn2: meta.get-function($name: "false", $module: "true"); | ||
$fn3: meta.get-function("length", $module: "string"); | ||
$fn4: meta.get-function("incre" + "ment"); | ||
|
||
$x: "increment"; | ||
$fn5: meta.get-function($x); | ||
|
||
<==> log.txt | ||
line 9, column 20 of $TEST_DIR/entrypoint.scss: WARNING - get-function call may require $module parameter | ||
, | ||
9 | $fn4: get-function("incre" + "ment"); | ||
| ^^^^^^^^^^^^^^^^ | ||
' | ||
line 12, column 20 of $TEST_DIR/entrypoint.scss: WARNING - get-function call may require $module parameter | ||
, | ||
12 | $fn5: get-function($x); | ||
| ^^ | ||
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters