diff --git a/.circleci/config.yml b/.circleci/config.yml index 95775e99323..79e9b7d537c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/package.json b/package.json index 5ccba1e10f8..eef09202e17 100644 --- a/package.json +++ b/package.json @@ -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)", diff --git a/tasks/show_eval_lines.sh b/tasks/show_eval_lines.sh new file mode 100755 index 00000000000..dc4e17122a4 --- /dev/null +++ b/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