Skip to content

Commit

Permalink
display lines above function constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jul 30, 2021
1 parent 2f2ad35 commit ca23d60
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Expand Up @@ -275,6 +275,9 @@ jobs:
- run:
name: Test plotly bundles againt unexpected characters
command: npm run no-bad-char
- run:
name: Display function constructors in plotly.js bundle
command: npm run log-new-func
- run:
name: Test certain bundles against function constructors
command: npm run no-new-func
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -37,6 +37,7 @@
"watch": "node tasks/watch.js",
"lint": "eslint --version && eslint .",
"lint-fix": "eslint . --fix || true",
"log-new-func": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-new-func: error}' dist/plotly.js 2>&1 | ./tasks/show_eval_lines.sh",
"no-new-func": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-new-func: error}' $(find dist -type f -iname '*.js' | grep -v plotly-gl* | grep -v plotly-with-meta.* | grep -v plotly.js | grep -v plotly.min.js)",
"no-bad-char": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-misleading-character-class: error}' $(find dist -type f -iname '*.js' | grep plotly)",
"no-dup-keys": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-dupe-keys: error}' $(find dist -type f -iname '*.js' | grep plotly)",
Expand Down
26 changes: 26 additions & 0 deletions tasks/show_eval_lines.sh
@@ -0,0 +1,26 @@
#! /bin/bash
err=0
src=""
while IFS= read -r str
do
if [[ "$str" == *"plotly.js/dist"* ]]; then
src="$str"
fi

if [[ "$str" == *"error The Function constructor is eval no-new-func"* ]]; then
str=${str%error*}
col=${str#*:}
row=${str%:*}
pre=$((row-10))
err=$((err+1))
echo "________________________________________________________________________________"
sed -n "${pre},${row}p" "$src"

for ((i = 0 ; i <= col + 10 ; i++)); do
echo -n "^"
done
echo

echo "Count: $err | Line: $row"
fi
done

0 comments on commit ca23d60

Please sign in to comment.