StyLua

An opinionated Lua code formatter

MPL-2.0 License

Downloads
8.2K
Stars
1.6K
Committers
38

Bot releases are visible (Hide)

StyLua - v0.20.0 Latest Release

Published by github-actions[bot] 9 months ago

[0.20.0] - 2024-01-20

Added

  • Introduced a new release artifact stylua-linux-x86_64-musl (#834)

Changed

  • Files excluded by git (via .gitignore or global git configuration), as well as in an .ignore file (used by ripgrep and The Silver Searcher)
    will now also be ignored by StyLua (as if they were all .styluaignore files). (#833)

Fixed

General

  • The CLI tool will now only write files if the contents differ, and not modify the file if there is no change after formatting (#827)
  • Fixed function body parentheses being placed on multiple lines unnecessarily when there are no parameters (#830)
  • Fixed directory paths w/o globs in .styluaignore not matching when using --respect-ignores (#845)

Luau

  • Fixed handling of floor division (//) syntax when only Luau command line flag is enabled
  • Fixed missing space when table is inside of Luau interpolated string expression ({{ is invalid syntax)
  • Fixed parentheses around a Luau compound type inside of a type table indexer being removed causing a syntax error (#828)

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.19.1...v0.20.0

StyLua - v0.19.1

Published by github-actions[bot] 11 months ago

[0.19.1] - 2023-11-15

This release has no changes. It resolves an issue in our test suite that may affect downstream package management tooling
failing tests (#824)

StyLua - v0.19.0

Published by github-actions[bot] 11 months ago

[0.19.0] - 2023-11-12

Added

  • Added flag --respect-ignores. By default, files explicitly passed to stylua (e.g. stylua foo.lua) will always be formatted, regardless of whether the file is ignored. Enabling this flag will consider .styluaignore or glob matches before formatting the file. (#765)
    • Note: for backwards compatibility reasons, formatting via stdin always respects ignores. This behaviour will change in the next major release

Changed

  • Updated parser crate with following changes:

    • Support Luau floor division (//)
    • Fix Luau string interpolation parsing
    • Fix Luau \z escape parsing
  • 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.
  • Multiline comments before commas will now remain in place and not move to after the comma. This is to support type-assertions-via-comments that is commonly used by some language servers. (#778)

Fixed

  • Wasm build now correctly supports configuring sort requires (#818)
StyLua - v0.18.2

Published by github-actions[bot] about 1 year ago

[0.18.2] - 2023-09-10

Fixed

  • Fixed LuaJIT suffixes LL/ULL causing a panic when running in --verify mode (#750)
  • Fixed incorrect formatting of conditionals when collapse_simple_statement is enabled and the block begins with an empty line (#744)
  • Fixed formatting of dot function call chains with comment between dot and names (#747)

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.18.1...v0.18.2

StyLua - v0.18.1

Published by github-actions[bot] over 1 year ago

[0.18.1] - 2023-07-15

Fixed

Luau

  • Fixed parentheses around a single Luau type pack in a generic being removed causing syntax errors (#729)
StyLua - v0.18.0

Published by github-actions[bot] over 1 year ago

[0.18.0] - 2023-06-14

Added

  • Multiline ignores (-- stylua: ignore start / -- stylua: ignore end) will now work within table fields:
require("foo").bar {
	-- stylua: ignore start
	baz      =0, -- < not formatted
	foo   =   2, -- < not formatted
	-- stylua: ignore end
	bar        =     1234 -- < formatted
}
  • Added option "Input" to call_parentheses setting, where call parentheses are retained based on their presence in the original input code.
    Note: this setting removes all automation in determining call parentheses, and consistency is not enforced.

Changed

  • Improved heuristics around Luau type excess parentheses removal, so unnecessary parentheses around types are removed in more locations

Fixed

  • Function calls are now formatted onto multiple lines if the opening brace { of a multiline table forces one of the lines over width
  • Fixed missing option --sort-requires to enable sort requires on the command line
$ stylua --sort-requires test.lua
  • Fixed parentheses removed around Luau optional type (B?) causing syntax errors when present in an intersection A & (B?)
  • Fixed comments lost when parentheses removed around Luau types
  • Fixed race condition where if a file is passed more than once as an argument to format, then it could potentially be wiped completely (for example, if an ancestor directory is passed and recursively searched, as well as the file itself)
StyLua - v0.17.1

Published by github-actions[bot] over 1 year ago

[0.17.1] - 2023-03-30

Fixed

  • Bumped internal parser dependency which should fix parsing problems for comments with Chinese characters, and multiline string escapes
  • Fixed comments in punctuated lists for return statements or assignments being incorrectly formatted leading to syntax errors (#662)
  • Fixed line endings not being correctly formatted in multiline string literals and comments (#665)

What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.17.0...v0.17.1

StyLua - v0.17.0

Published by github-actions[bot] over 1 year ago

[0.17.0] - 2023-03-11

Added

  • Added support for "sort requires", which sorts top-level statements of the form local NAME = require(EXPR) lexicographically on NAME.
    We do this by treating a group of consecutive requires as a "block", and then sorting only within the block. Any other statement, or an empty line, between require statements will split the group into two separate blocks (and can be used to separate the sorting). A block of requires will not move around the file.
    Roblox Luau statements of the form local NAME = game:GetService(EXPR) will also be sorted separately.

This feature is disabled by default. To enable it, add the following to your stylua.toml:

[sort_requires]
enabled = true

Note: we assume that all requires are pure with no side effects. It is not recommended to use this feature if the ordering of your requires matter.

  • Added support for EditorConfig, which is taken into account only if no stylua.toml was found.

This feature is enabled by default, it can be disabled using --no-editorconfig.


What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.16.1...v0.17.0

StyLua - v0.16.1

Published by github-actions[bot] over 1 year ago

[0.16.1] - 2023-02-10

Fixed

General

  • Fixed mistransformation of a function argument in a multilined function call when the argument contains a comment, causing a syntax error. We now attempt to hang the expression (#648)

Luau

  • Fixed verify AST flagging a false positive for parentheses removed around a Luau type (#643)

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.16.0...v0.16.1

StyLua - v0.16.0

Published by github-actions[bot] almost 2 years ago

[0.16.0] - 2023-01-15

Added

Luau

  • Unnecessary parentheses around Luau types will now be removed (#611)

Lua 5.2 / Lua 5.3 / Lua 5.4

  • Collapse a body containing only a goto statement when collapse_simple_statement is set (#618)

Changed

General

  • Update internal parser:
    • (lua52) Support Lua 5.2 fractional hexidecimal / hexidecimal with exponents (#621)
    • (lua52) Support LuaJIT number suffixes LL/ULL/i (#621)
    • (lua52) Support \z escape sequences in strings (#613)
    • (luau) Support Luau string interpolation (#607)
  • Several optimisations applied to formatting functions to reduce time taken. Files which previously did not terminate (6MB+) now finish in reasonable time. (#591)
  • Assignments of the form local name = function will no longer hang at the equals token, and instead force parameters multiline, to reduce unnecessary indentation. (#595)

Fixed

General

  • Fixed an anonymous function assignment local x = function() being unnecessarily indented if the function body contains a comment (#627)
  • Fixed malformed formatting when there is a newline between a return token and the expressions (#605)
  • Fixed malformed formatting of multi-assignment or multi-returns where there is a comment within the expressions list (#637)

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.15.3...v0.16.0

StyLua - v0.15.3

Published by github-actions[bot] almost 2 years ago

[0.15.3] - 2022-12-07

Fixed

General

  • Fixed necessary parentheses removed in (-X) ^ Y causing change in semantics (#623)
  • Take into account function token size when formatting an anonymous function function() end (particularly relevant when collapsing simple statements) (#619)

Luau

  • Support hanging inside of Luau type arrays { T } to fix formatting issues when comments are present (#617)

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.15.2...v0.15.3

StyLua - v0.15.2

Published by github-actions[bot] almost 2 years ago

[0.15.2] - 2022-10-31

Fixed

  • Fix incorrect indentation level used for hanging expressions in if expression syntax (#596)
  • Fixed Luau return type in parentheses containing a comment on the last item being collapsed causing a syntax error (#608)
  • Fix parentheses removed which highlight precedence in (not X) == Y causing linting errors (#609)
  • Fix build script for @johnnymorganz/stylua to include all lua and luau features (#614)

What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.15.1...v0.15.2

StyLua - v0.15.1

Published by github-actions[bot] about 2 years ago

[0.15.1] - 2022-09-22

Fixed

  • Updated parser to fix comments and string parsing issues (#585, #587)
StyLua - v0.15.0

Published by github-actions[bot] about 2 years ago

This release introduces support for Lua 5.3 and Lua 5.4!

When compiling/installing with cargo, pass --features lua53 or --features lua54 respectively. By default, the GitHub Releases build with Lua 5.3 and 5.4 enabled (but note issues such as https://github.com/JohnnyMorganz/StyLua/issues/407)

Changes to GitHub Release Artifacts

This release changes the naming for binary artifacts. We now append the arch to the end of all artifacts

  • stylua-win64.zip -> stylua-windows-x86_64.zip
  • stylua-macos.zip -> stylua-macos-x86_64.zip
  • stylua-linux.zip -> stylua-linux-x86_64.zip

Linux aarch64 is also now supported, alongside macOS aarch64.

The old artifact naming is kept temporarily for backwards compatibility. We recommend any references to be changed, as these artifacts will no longer be produced in future versions.


[0.15.0] - 2022-09-21

Added

  • Added support for Lua 5.3, gated behind the lua53 feature flag (#534)
  • Added support for Lua 5.4, gated behind the lua54 feature flag (#533)
  • Added --allow-hidden flag to allow entering and formatting hidden files/directories (#562)
  • Added --output-format=summary which can be used with --check to output a summary of the list of files not correctly formatted (#573)

Changed

  • We will no longer expand function calls when it contains an inlined multiline comment (#543, #561)

Fixed

  • Precommit hook now supports downloading aarch64 binary for M1 macs (#558)
  • Fixed mistransformations of generic for loop with comments in the expression list (#579)
  • Fixed then/else token not taken into account when formatting an if-expression (#582)
  • Fixed macos-aarch64 artifact for real

What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.14.3...v0.15.0

StyLua - v0.14.3

Published by github-actions[bot] about 2 years ago

[0.14.3] - 2022-08-27

Fixed

General

  • Fixed macOS aarch64 target in release workflow (#528)
  • Fixed leading comments lost from an expression when excessive parentheses are removed from it (#530)
  • Fixed comments present in a complex expression not forcing multiline hanging leading to a syntax error (#524)
  • Take into account the extra line created when hanging at equals token in an assignment. This should prevent unnecessary hanging (#542)
  • Fixed comments added to a newly created trailing comment not being formatted (#547)
  • Fixed call chain with a small prefix not being kept inlined causing unstable formatting (#514)
  • Fixed shape computation for table fields causing unnecessary expansion (#551)
  • Fixed hanging the prefix string in ("str"):call unnecessarily when it provides no benefit (#508)
  • Fixed table field value being expanded when it could be hanged instead (#541)

Luau

  • Long union/interesection types inside of a parentheses will now cause the parentheses to expand multiline (#531)
  • Fixed unnecessary break on else in an if-expression when the expression contains a comment (#520)

What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.14.2...v0.14.3

StyLua - v0.14.2

Published by github-actions[bot] about 2 years ago

[0.14.2] - 2022-07-27

Fixed

  • Fixed var expression with trailing comments on initial prefix being collapsed leading to malformed formatting (#509)
  • Fixed return with comment between return and expression being collapsed leading to malformed formatting (#504)
  • Fixed release assets for precommit by marking release artifacts as application/zip (#496)

What's Changed

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.14.1...v0.14.2

StyLua - v0.14.1

Published by github-actions[bot] about 2 years ago

[0.14.1] - 2022-07-21

Changed

  • Chained var expression formatting will now follow the exact same steps as chained function call formatting

Fixed

  • Fixed var expression with comments collapsing leading to malformed formatting (#500)
  • Fixed ignore behavior for --stdin-filepath (#495)

What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.14.0...v0.14.1

StyLua - v0.14.0

Published by github-actions[bot] over 2 years ago

[0.14.0] - 2022-07-06

Added

  • --output-format=json now outputs all (error) messages in JSON format (#453)
  • Added WASM build support. Stylua is available on npm for consumption in Node.js or a browser (using a bundler) - https://www.npmjs.com/package/@johnnymorganz/stylua
  • Ignore comments will now be respected before fields inside tables (#448)
  • Stylua library (stylua_lib) now exposes a format_ast(ast, config, range, verification) function to format a full-moon AST directly (#482)
  • Added collapse_simple_statement option. It can take the values Never (default), FunctionOnly, ConditionalOnly or Always. When enabled, "simple" functions or if statements (ones where they only return a value or have a simple statement such as a function call) will be collapsed onto a single line where possible.

Changed

  • We now attempt to first hang the equals token in an assignment before expanding the RHS expression, provided the expression is not "complex" (#292, #489)
  • We now use the current indent level of comments preceding an elseif/else token to determine whether they should still be indented one level or inlined with the elseif/else token. (#254)
  • Static chained function calls (i.e., foo.bar().baz()) will now hang if necessary (#368)
  • The first call in a chained function call will now inline with the prefix if the prefix begins with an uppercase letter or the prefix is smaller (in length) than the indent width
  • A chained function call will not expand if the first call gets inlined and there is only 2 calls

Fixed

  • [Luau] Fixed spacing lost before a comment within a type generic (#446)
  • [Luau] Removed unnecessary expansion of a type generic with a single table as the parameter (#442)
  • Fixed incorrect extra indentation of an expanded parentheses passed as a function call argument (#456)
  • [Luau] Increased the shape size of the expression in a type assertion so that it will correctly hang if over width (#466)
  • Fixed binary expression in a table field containing a comment being collapsed leading to malformed formatted (#471)
  • Fixed end parentheses of a function call with a multiline comment internally being expanded onto a new line unnecessarily (#473)
  • Fixed severe performance regression with complex nested function calls (#477)

What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.13.1...v0.14.0

StyLua - v0.13.1

Published by github-actions[bot] over 2 years ago

[0.13.1] - 2022-04-11

Fixed

General

  • Fixed leading trivia on semicolon lost when semicolon is removed (#431)
  • Fixed shape calculation of the RHS of a binary expression not correctly reset when hanging, causing it to expand unnecessarily (#432)
  • Fixed unstable formatting of tables at column width boundary (#436)
  • Fixed assignments no longer hanging at equals token if a comment is present, but the expression is not hangable at a binop. (#439)

Luau

  • Fixed unstable formatting around comments within type declarations (#397, #430)
  • Fixed parentheses around type assertions in a binary expression being removed leading to incorrect semantics. (#441)

What's Changed

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.13.0...v0.13.1

StyLua - v0.13.0

Published by github-actions[bot] over 2 years ago

NOTE: This release removes the version from the release file names (https://github.com/JohnnyMorganz/StyLua/issues/343). If you have automated tooling to download StyLua releases, you may need to update them to exclude the version from the name

[0.13.0] - 2022-03-31

Added

General

  • Added support for alternative diff outputs. You can now use --output-format=unified or --output-format=json to output a unified diff or json mismatches list respectively. A unified diff can be fed into other tools such as patch or delta, whilst a JSON diff provides a more machine readable format useful for extensions. (#230)

Changed

General

  • Migrate internal dependency for CLI arguments handling, with improved help messages.
  • Generic fors will no longer expand onto multiple lines if the expression looping over is a function call with a single table argument (e.g., ipairs({ ... })) (#405)
  • When hanging an assignment of an expression contained within parentheses, we do not add an extra indentation. The formatting is now consistent with expanded tables and function calls. (#274)

Luau

  • Type declarations consisting of unions/intersections where an inner type has a multiline comment will now force hanging
  • Excess parentheses around a type assertion will now be removed. (#383, #425)

Fixed

General

  • Fixed issue through static linking where Windows binary would not execute due to missing VCRUNTIME140.dll. (#413)
  • Fixed assignment with comment sometimes not hanging leading to malformed syntax. (#416)
  • Fixed block ignores not applied when multiple leading block ignore comments are present at once. (#421)
  • Fixed ordering of comments when semicolon after statement is removed. (#423)

What's Changed

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.12.5...v0.13.0

Package Rankings
Top 5.92% on Alpine-v3.18
Top 8.43% on Npmjs.org
Top 9.08% on Crates.io
Top 7.56% on Proxy.golang.org
Top 12.68% on Alpine-v3.17
Top 10.54% on Alpine-edge
Top 15.0% on Formulae.brew.sh
Badges
Extracted from project README
Community Packages