exercism / lua

Exercism exercises in Lua.
https://exercism.org/tracks/lua
MIT License
41 stars 57 forks source link

Proposal: Adding a LuaFormatter config to the repository #422

Closed imolein closed 11 months ago

imolein commented 11 months ago

I would like to suggest to add a LuaFormatter configuration to the repository and include it under the Setup dev environment for contributing headline in the README.md. (I just saw that the Readme needs some rework anyway :D )

This is a configuration (config file description) which I quickly created, reading @ryanplusplus comments from #420:

column_limit: 80
indent_width: 2
use_tab: false
tab_width: 4
continuation_indent_width: 4
spaces_before_call: 1
keep_simple_control_block_one_line: true
keep_simple_function_one_line: false
align_args: true
break_after_functioncall_lp: false
break_before_functioncall_rp: false
spaces_inside_functioncall_parens: false
spaces_inside_functiondef_parens: false
align_parameter: true
chop_down_parameter: false
break_after_functiondef_lp: false
break_before_functiondef_rp: false
align_table_field: true
break_after_table_lb: true
break_before_table_rb: true
chop_down_table: false
chop_down_kv_table: true
table_sep: ","
column_table_limit: 0
extra_sep_at_table_end: false
spaces_inside_table_braces: true
break_after_operator: true
double_quote_to_single_quote: false
single_quote_to_double_quote: false
spaces_around_equals_in_field: true
line_breaks_after_function_body: 1
line_separator: input
Diff of high-scores_spec.lua after running LuaFormatter on it ```diff index 336f6db..1672557 100644 --- a/exercises/practice/high-scores/high-scores_spec.lua +++ b/exercises/practice/high-scores/high-scores_spec.lua @@ -9,7 +9,7 @@ describe('high-scores', function() if #a ~= #b then return false end - + for i = 1, #a do if a[i] ~= b[i] then return false @@ -25,90 +25,90 @@ describe('high-scores', function() end) it('Table of scores', function() - local values = {30, 50, 20, 70} - local scores = high_scores{values} - local expected = {30, 50, 20, 70} + local values = { 30, 50, 20, 70 } + local scores = high_scores { values } + local expected = { 30, 50, 20, 70 } assert.True(same_values_in_order(expected, scores:scores())) end) it('Latest score', function() - local values = {100, 0, 90, 30} - local scores = high_scores{values} + local values = { 100, 0, 90, 30 } + local scores = high_scores { values } local expected = 30 assert.equal(expected, scores:latest()) end) it('Personal best', function() - local values = {40, 100, 70} - local scores = high_scores{values} + local values = { 40, 100, 70 } + local scores = high_scores { values } local expected = 100 assert.equal(expected, scores:personal_best()) end) it('Personal top three from a list of scores', function() - local values = {10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70} - local scores = high_scores{values} - local expected = {100, 90, 70} + local values = { 10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70 } + local scores = high_scores { values } + local expected = { 100, 90, 70 } assert.True(same_values_in_order(expected, scores:personal_top_three())) end) it('Personal top highest to lowest', function() - local values = {20, 10, 30} - local scores = high_scores{values} - local expected = {30, 20, 10} + local values = { 20, 10, 30 } + local scores = high_scores { values } + local expected = { 30, 20, 10 } assert.True(same_values_in_order(expected, scores:personal_top_three())) end) it('Personal top when there is a tie', function() - local values = {40, 20, 40, 30} - local scores = high_scores{values} - local expected = {40, 40, 30} + local values = { 40, 20, 40, 30 } + local scores = high_scores { values } + local expected = { 40, 40, 30 } assert.True(same_values_in_order(expected, scores:personal_top_three())) end) it('Personal top when there are less than 3', function() - local values = {30, 70} - local scores = high_scores{values} - local expected = {70, 30} + local values = { 30, 70 } + local scores = high_scores { values } + local expected = { 70, 30 } assert.True(same_values_in_order(expected, scores:personal_top_three())) end) it('Personal top when there is only one', function() - local values = {40} - local scores = high_scores{values} - local expected = {40} + local values = { 40 } + local scores = high_scores { values } + local expected = { 40 } assert.True(same_values_in_order(expected, scores:personal_top_three())) end) it('Latest score after personal top scores', function() - local values = {70, 50, 20, 30} - local scores = high_scores{values} + local values = { 70, 50, 20, 30 } + local scores = high_scores { values } local _ = scores:personal_top_three() local expected = 30 assert.equal(expected, scores:latest()) end) it('Scores after personal top scores', function() - local values = {30, 50, 20, 70} - local scores = high_scores{values} + local values = { 30, 50, 20, 70 } + local scores = high_scores { values } local _ = scores:personal_top_three() - local expected = {30, 50, 20, 70} + local expected = { 30, 50, 20, 70 } assert.True(same_values_in_order(expected, scores:scores())) end) it('Latest score after personal best', function() - local values = {20, 70, 15, 25, 30} - local scores = high_scores{values} + local values = { 20, 70, 15, 25, 30 } + local scores = high_scores { values } local _ = scores:personal_best() local expected = 30 assert.equal(expected, scores:latest()) end) it('Scores after personal best', function() - local values = {20, 70, 15, 25, 30} - local scores = high_scores{values} + local values = { 20, 70, 15, 25, 30 } + local scores = high_scores { values } local _ = scores:personal_best() - local expected = {20, 70, 15, 25, 30} + local expected = { 20, 70, 15, 25, 30 } assert.True(same_values_in_order(expected, scores:scores())) end) ```
ryanplusplus commented 11 months ago

:heart: