Skip to content

Commit

Permalink
Fix wasm output
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMorganz committed Nov 11, 2023
1 parent 452e43b commit 095e2b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Simplified access and modification patterns for StyLua configuration. You can now access the properties directly
- **Deprecated:** the old access patterns of `.property()` and `.with_property()` are now deprecated
- **Breaking Change (WASM):** due to JS/TS lack of differentiation between `.property` / `.property()` implementation, the `.property()` functions were removed from WASM output.

### Fixed

Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl SortRequiresConfig {
SortRequiresConfig::default()
}
#[deprecated(since = "0.19.0", note = "access `.enabled` directly instead")]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn enabled(&self) -> bool {
self.enabled
}
Expand Down Expand Up @@ -188,36 +189,42 @@ impl Config {

/// Returns the current configured column width
#[deprecated(since = "0.19.0", note = "access `.column_width` directly instead")]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn column_width(&self) -> usize {
self.column_width
}

/// Returns the current configured line endings
#[deprecated(since = "0.19.0", note = "access `.line_endings` directly instead")]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn line_endings(&self) -> LineEndings {
self.line_endings
}

/// Returns the current configured indent type
#[deprecated(since = "0.19.0", note = "access `.indent_type` directly instead")]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn indent_type(&self) -> IndentType {
self.indent_type
}

/// Returns the current configured indent width
#[deprecated(since = "0.19.0", note = "access `.indent_width` directly instead")]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn indent_width(&self) -> usize {
self.indent_width
}

/// Returns the current configured quote style
#[deprecated(since = "0.19.0", note = "access `.quote_style` directly instead")]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn quote_style(&self) -> QuoteStyle {
self.quote_style
}

/// Returns the current configured call parentheses style
#[deprecated(since = "0.19.0", note = "access `.call_parentheses` directly instead")]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn call_parentheses(&self) -> CallParenType {
self.call_parentheses
}
Expand All @@ -226,12 +233,14 @@ impl Config {
since = "0.19.0",
note = "access `.collapse_simple_statement` directly instead"
)]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn collapse_simple_statement(&self) -> CollapseSimpleStatement {
self.collapse_simple_statement
}

/// Returns the current sort requires codemod configuration
#[deprecated(since = "0.19.0", note = "access `.sort_requires` directly instead")]
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
pub fn sort_requires(&self) -> SortRequiresConfig {
self.sort_requires
}
Expand Down
5 changes: 4 additions & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ fn test_sort_requires() {
let contents = std::fs::read_to_string(path).unwrap();
insta::assert_snapshot!(format_code(
&contents,
Config { sort_requires: SortRequiresConfig { enabled: true }, ..Config::default()},
Config {
sort_requires: SortRequiresConfig { enabled: true },
..Config::default()
},
None,
OutputVerification::None
)
Expand Down

0 comments on commit 095e2b0

Please sign in to comment.