Skip to content

Commit

Permalink
feat(linters,formatters): fmt files
Browse files Browse the repository at this point in the history
  • Loading branch information
creativenull committed Aug 1, 2023
1 parent 755f77c commit 1133482
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion lua/efmls-configs/formatters/forge_fmt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ local command = string.format('%s fmt --raw -', fs.executable(formatter))
return {
formatCommand = command,
formatStdin = true,
rootMarkers = { "foundry.toml" },
rootMarkers = { 'foundry.toml' },
}
18 changes: 9 additions & 9 deletions lua/efmls-configs/formatters/prettier.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ return {
formatCommand = command,
formatStdin = true,
rootMarkers = {
".prettierrc",
".prettierrc.json",
".prettierrc.js",
".prettierrc.yml",
".prettierrc.yaml",
".prettierrc.json5",
".prettierrc.mjs",
".prettierrc.cjs",
".prettierrc.toml",
'.prettierrc',
'.prettierrc.json',
'.prettierrc.js',
'.prettierrc.yml',
'.prettierrc.yaml',
'.prettierrc.json5',
'.prettierrc.mjs',
'.prettierrc.cjs',
'.prettierrc.toml',
},
}
2 changes: 1 addition & 1 deletion lua/efmls-configs/formatters/prettier_d.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ return {
formatCanRange = true,
formatCommand = command,
formatStdin = true,
rootMarkers = require("efmls-configs.formatters.prettier").rootMarkers,
rootMarkers = require('efmls-configs.formatters.prettier').rootMarkers,
}
3 changes: 1 addition & 2 deletions lua/efmls-configs/formatters/stylua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ local fs = require('efmls-configs.fs')

local formatter = 'stylua'
local command = string.format(
'%s ${--indent-width:tabSize} ${--range-start:charStart} '
.. '${--range-end:charEnd} --color Never -',
'%s ${--indent-width:tabSize} ${--range-start:charStart} ' .. '${--range-end:charEnd} --color Never -',
fs.executable(formatter)
)

Expand Down
12 changes: 6 additions & 6 deletions lua/efmls-configs/linters/djlint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ local args = [[--linter-output-format 'I:{line}: {message}' --profile=django -]]
local command = string.format('%s %s', bin, args)

return {
prefix = linter,
lintCommand = command,
lintFormats = {'%t:%l:%c: %m'},
lintStdin = true,
lintIgnoreExitCode = true,
lintDebounce = "1s",
prefix = linter,
lintCommand = command,
lintFormats = { '%t:%l:%c: %m' },
lintStdin = true,
lintIgnoreExitCode = true,
lintDebounce = '1s',
}
32 changes: 18 additions & 14 deletions lua/efmls-configs/linters/slither.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ local args = '--json - "${INPUT}"'
-- 3. Pick out the marked results. It'll be the even-numbered fields,
-- example: junk|results|junk|results|junk.
-- 4. Turn the "lines" result (e.g. "1,2,3,4") into range (e.g. "1-4").
local command = string.format([=[
local command = string.format(
[=[
%s %s --solc-remaps "$([ -f remappings.txt ] && tr '\n' ' ' < remappings.txt | xargs)" \
| sed "s/filename_absolute/$(printf '%%b' '\0036')filename_absolute/g" \
| sed "s/lines/$(printf '%%b' '\0036')lines/g" \
Expand All @@ -28,7 +29,10 @@ local command = string.format([=[
| sed "s/\"elements\"[^$(printf '%%b' '\0036')]*\"$(printf '%%b' '\0036')filename_absolute\": \"\([^\"]*\)\"[^$(printf '%%b' '\0036')]*\"$(printf '%%b' '\0036')lines\": \[\([^]]*\)\][^0-9]*starting_column\": \([0-9]*\), \"ending_column\": \([0-9]*\)[^$(printf '%%b' '\0037')]*$(printf '%%b' '\0037')description\": \"\([^\"]*\)[^$(printf '%%b' '\0036')]*\"$(printf '%%b' '\0036')impact\": \"\([^\"]*\)\"/$(printf '%%b' '\0035')\2| \3-\4 of \1 (\6): \5$(printf '%%b' '\0035')/g" \
| awk -F "$(printf '%%b' '\0035')" '{for (i=2; i<=NF; i+=2) print $i}' \
| awk -F "|" '{split($1, a, ", "); $1=a[1] "-" a[length(a)] ":"; print $0}'
]=], bin, args)
]=],
bin,
args
)

return {
lintCategoryMap = {
Expand All @@ -45,19 +49,19 @@ return {
-- https://github.com/crytic/slither/issues/2057
lintStdin = false,
lintFormats = {
"%l-%e: %c-%k of %f (%tow): %m",
"%l-%e: %c-%k of %f (%tedium): %m",
"%l-%e: %c-%k of %f (%tigh): %m",
"%l-%e: %c-%k of %f (%tptimization): %m",
"%l-%e: %c-%k of %f (%tnformational): %m",
'%l-%e: %c-%k of %f (%tow): %m',
'%l-%e: %c-%k of %f (%tedium): %m',
'%l-%e: %c-%k of %f (%tigh): %m',
'%l-%e: %c-%k of %f (%tptimization): %m',
'%l-%e: %c-%k of %f (%tnformational): %m',
},
rootMarkers = {
"hardhat.config.js",
"hardhat.config.ts",
"foundry.toml",
"remappings.txt",
"truffle.js",
"truffle-config.js",
"ape-config.yaml",
'hardhat.config.js',
'hardhat.config.ts',
'foundry.toml',
'remappings.txt',
'truffle.js',
'truffle-config.js',
'ape-config.yaml',
},
}
2 changes: 1 addition & 1 deletion lua/efmls-configs/linters/stylelint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ return {
lintCommand = command,
lintStdin = true,
lintFormats = { '%.%#: line %l, col %c, %trror - %m', '%.%#: line %l, col %c, %tarning - %m' },
rootMarkers = { '.stylelintrc' }
rootMarkers = { '.stylelintrc' },
}
1 change: 0 additions & 1 deletion lua/efmls-configs/linters/yamllint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ return {
lintCommand = command,
lintStdin = true,
}

0 comments on commit 1133482

Please sign in to comment.