Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0c2fac

Browse files
authored
Merge pull request plotly#5869 from plotly/log-new-functions
Utility to display location and number of function constructors in plotly.js source
2 parents 2f2ad35 + ca23d60 commit d0c2fac

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ jobs:
275275
- run:
276276
name: Test plotly bundles againt unexpected characters
277277
command: npm run no-bad-char
278+
- run:
279+
name: Display function constructors in plotly.js bundle
280+
command: npm run log-new-func
278281
- run:
279282
name: Test certain bundles against function constructors
280283
command: npm run no-new-func

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"watch": "node tasks/watch.js",
3838
"lint": "eslint --version && eslint .",
3939
"lint-fix": "eslint . --fix || true",
40+
"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",
4041
"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)",
4142
"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)",
4243
"no-dup-keys": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-dupe-keys: error}' $(find dist -type f -iname '*.js' | grep plotly)",

tasks/show_eval_lines.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#! /bin/bash
2+
err=0
3+
src=""
4+
while IFS= read -r str
5+
do
6+
if [[ "$str" == *"plotly.js/dist"* ]]; then
7+
src="$str"
8+
fi
9+
10+
if [[ "$str" == *"error The Function constructor is eval no-new-func"* ]]; then
11+
str=${str%error*}
12+
col=${str#*:}
13+
row=${str%:*}
14+
pre=$((row-10))
15+
err=$((err+1))
16+
echo "________________________________________________________________________________"
17+
sed -n "${pre},${row}p" "$src"
18+
19+
for ((i = 0 ; i <= col + 10 ; i++)); do
20+
echo -n "^"
21+
done
22+
echo
23+
24+
echo "Count: $err | Line: $row"
25+
fi
26+
done

0 commit comments

Comments
 (0)