Skip to content

Commit

Permalink
Remove deprecated access patterns on Config struct (#922)
Browse files Browse the repository at this point in the history
Remove deprecated access patterns
  • Loading branch information
JohnnyMorganz authored Nov 17, 2024
1 parent d11797b commit 2604767
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 187 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- For automated downloaders: the legacy release artifacts `stylua-win64.zip`, `stylua-linux.zip` and `stylua-macos.zip` are no longer produced in GitHub releases, in favour of more specific names (e.g., `stylua-windows-x86_64`, `stylua-linux-x86_64` and `stylua-macos-x86_64`).
- `--stdin-filepath` no longer respects ignore files by default, in line with passing files directly to the command line. Now, `stylua --stdin-filepath foo.lua -` will still format the stdin even if `foo.lua` was in a `.styluaignore` file. Use `--respect-ignores` to preserve the original behaviour.
- Removed deprecated access patterns on `Config` struct in stylua Rust library

### Added

Expand Down
187 changes: 0 additions & 187 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,151 +260,6 @@ impl Config {
pub fn new() -> Self {
Config::default()
}

/// 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
}

#[deprecated(
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
}

/// Returns a new config with the given column width
#[deprecated(since = "0.19.0", note = "modify `.column_width` directly instead")]
pub fn with_column_width(self, column_width: usize) -> Self {
Self {
column_width,
..self
}
}

/// Returns a new config with the given line endings
#[deprecated(since = "0.19.0", note = "modify `.line_endings` directly instead")]
pub fn with_line_endings(self, line_endings: LineEndings) -> Self {
Self {
line_endings,
..self
}
}

/// Returns a new config with the given indent type
#[deprecated(since = "0.19.0", note = "modify `.indent_type` directly instead")]
pub fn with_indent_type(self, indent_type: IndentType) -> Self {
Self {
indent_type,
..self
}
}

/// Returns a new config with the given indent width
#[deprecated(since = "0.19.0", note = "modify `.indent_width` directly instead")]
pub fn with_indent_width(self, indent_width: usize) -> Self {
Self {
indent_width,
..self
}
}

/// Returns a new config with the given quote style
#[deprecated(since = "0.19.0", note = "modify `.quote_style` directly instead")]
pub fn with_quote_style(self, quote_style: QuoteStyle) -> Self {
Self {
quote_style,
..self
}
}

/// Returns a new config with the given value for `no_call_parentheses`
#[deprecated(note = "use `call_parentheses")]
pub fn with_no_call_parentheses(self, no_call_parentheses: bool) -> Self {
#[allow(deprecated)]
Self {
no_call_parentheses,
..self
}
}

/// Returns a new config with the given call parentheses type
#[deprecated(since = "0.19.0", note = "modify `.call_parentheses` directly instead")]
pub fn with_call_parentheses(self, call_parentheses: CallParenType) -> Self {
Self {
call_parentheses,
..self
}
}

#[deprecated(
since = "0.19.0",
note = "modify `.collapse_simple_statement` directly instead"
)]
pub fn with_collapse_simple_statement(
self,
collapse_simple_statement: CollapseSimpleStatement,
) -> Self {
Self {
collapse_simple_statement,
..self
}
}

/// Returns a new config with the given sort requires configuration
#[deprecated(since = "0.19.0", note = "modify `.sort_requires` directly instead")]
pub fn with_sort_requires(self, sort_requires: SortRequiresConfig) -> Self {
Self {
sort_requires,
..self
}
}
}

impl Default for Config {
Expand Down Expand Up @@ -592,46 +447,4 @@ mod tests {
.unwrap();
assert_eq!(output, "local x = 1\n");
}

#[test]
#[allow(deprecated)]
fn test_config_column_width() {
let new_config = Config::new().with_column_width(80);
assert_eq!(new_config.column_width(), 80);
}

#[test]
#[allow(deprecated)]
fn test_config_line_endings() {
let new_config = Config::new().with_line_endings(LineEndings::Windows);
assert_eq!(new_config.line_endings(), LineEndings::Windows);
}

#[test]
#[allow(deprecated)]
fn test_config_indent_type() {
let new_config = Config::new().with_indent_type(IndentType::Spaces);
assert_eq!(new_config.indent_type(), IndentType::Spaces);
}

#[test]
#[allow(deprecated)]
fn test_config_indent_width() {
let new_config = Config::new().with_indent_width(2);
assert_eq!(new_config.indent_width(), 2);
}

#[test]
#[allow(deprecated)]
fn test_config_quote_style() {
let new_config = Config::new().with_quote_style(QuoteStyle::ForceDouble);
assert_eq!(new_config.quote_style(), QuoteStyle::ForceDouble);
}

#[test]
#[allow(deprecated)]
fn test_config_call_parentheses() {
let new_config = Config::new().with_call_parentheses(CallParenType::None);
assert_eq!(new_config.call_parentheses(), CallParenType::None);
}
}

0 comments on commit 2604767

Please sign in to comment.