Skip to content

Instantly share code, notes, and snippets.

@Duologic
Created July 20, 2020 09:28
Show Gist options
  • Save Duologic/e6f4cde8052d6992ebeee6bb3024e31d to your computer and use it in GitHub Desktop.
Save Duologic/e6f4cde8052d6992ebeee6bb3024e31d to your computer and use it in GitHub Desktop.
Naive linter that looks for method-use in Jsonnet
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
DIRNAME=$(dirname $0)
if [ "$#" != 1 ]; then
echo "Usage: `basename $0` <file_to_lint>"
exit 1
fi
OUTPUT=$(cat $1 | sed 's/^ \+//g' | sed 's/^\/\/.*$//g' | sed 's/\(else\|then\|for\)/ \1 /g' | sed ':begin;$!N;s/\n//;tbegin' | sed 's/}/}\n/g' | grep --color=always ')\.[a-zA-Z0-9]\+(')
L=$(echo $OUTPUT | wc -l)
if [[ $L -gt 0 ]]; then
echo $1:
echo -e $OUTPUT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment