Page Menu
Home
Wildfire Games
Search
Configure Global Search
Log In
Paste
P273
eslint0ad
Active
Public
Actions
Authored by
Langbart
on May 19 2022, 5:43 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
function
eslint0ad
{
CURRENT_DIR
=
$(
pwd
)
cd
~/0ad
load_help_section
()
{
cat
<<EOF
Linting of modified files up to a certain commit (HEAD by default) and optionally attempt to autofix problems.
IMPORTANT: eslint-plugin-brace-rules and eslint must be installed
(no input) Display possible warnings/ errors
-h, --help Show help
-f, --fix Autofix as many issues as possible
<COMMIT> To what commit shall modified files be linted e.g HEAD~5
EOF
return
1
}
FIX
=
''
COMMIT
=
''
# the path to node_modules which contains the eslint-plugin-brace-rules plugin is a different path on Windows
NODE_MODULE_PATH
=
"/usr/local/lib/node_modules"
for
i in
"
$@
"
;
do
if
[[
"
$i
"
=
"-h"
]]
||
[[
"
$i
"
=
"--help"
]]
;
then
load_help_section
elif
[[
"
$i
"
=
"-f"
]]
||
[[
"
$i
"
=
"--fix"
]]
;
then
FIX
=
'--fix'
else
COMMIT
+=(
$i
)
fi
done
if
!
command
-v eslint
&
>/dev/null
;
then
echo
"eslint NOT found, install it with:\nnpm i -g eslint"
return
1
elif
[[
! -d
"
${
NODE_MODULE_PATH
}
/eslint-plugin-brace-rules"
]]
;
then
echo
"eslint-plugin-brace-rules NOT found, install it with:\nnpm i -g eslint-plugin-brace-rules"
return
1
fi
# Untracked files need to be added for linting
REGEX
=
"(.*)\.(jsx|js|tsx|ts)
$
"
git ls-files -o --exclude-standard
|
grep -E
$REGEX
|
xargs git add
# Guidance: https://gist.github.com//oroce/11282380
# IMPORTANT (--diff-filter=d) ensures that deleted files are filtered out, otherwise eslint would crash.
eslint --config
'build/arclint/configs/eslintrc.json'
--resolve-plugins-relative-to
$NODE_MODULE_PATH
$FIX
$(
git diff-index --name-only --diff-filter
=
d
${
COMMIT
:-
'HEAD'
}
|
grep -E
$REGEX
|
xargs
)
cd
$CURRENT_DIR
}
Event Timeline
Langbart
created this paste.
May 19 2022, 5:43 AM
Langbart
updated the paste's language from
autodetect
to
bash
.
May 19 2022, 7:42 PM
Langbart
edited the content of this paste.
(Show Details)
Langbart
changed the visibility from "All Users" to "Public (No Login Required)".
Langbart
removed a subscriber:
wraitii
.
Log In to Comment