launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #21712
[Merge] lp:~cjwatson/launchpad/eslint into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/eslint into lp:launchpad with lp:~cjwatson/launchpad/yarn as a prerequisite.
Commit message:
Use eslint to lint JavaScript files.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/eslint/+merge/327884
It's much pickier than pocketlint, has found several real bugs so far for me, and has a very low false positive rate.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/eslint into lp:launchpad.
=== added file '.eslintignore'
--- .eslintignore 1970-01-01 00:00:00 +0000
+++ .eslintignore 2017-07-21 14:49:41 +0000
@@ -0,0 +1,6 @@
+# Third-party module, albeit modified somewhat for Launchpad.
+lib/lp/app/javascript/sorttable/sorttable.js
+
+# Minified third-party files.
+lib/lp/app/tour/jquery-*.pack.js
+lib/lp/app/tour/selector.js
=== added file '.eslintrc.json'
--- .eslintrc.json 1970-01-01 00:00:00 +0000
+++ .eslintrc.json 2017-07-21 14:49:41 +0000
@@ -0,0 +1,28 @@
+{
+ "env": {
+ "browser": true
+ },
+ "extends": "eslint:recommended",
+ "globals": {
+ "$": false,
+ "LP": true,
+ "YUI": false,
+ "YUI_config": true
+ },
+ "rules": {
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "no-unused-vars": [
+ "error",
+ {
+ "args": "none"
+ }
+ ],
+ "semi": [
+ "error",
+ "always"
+ ]
+ }
+}
=== modified file 'package.json'
--- package.json 2017-07-21 14:49:41 +0000
+++ package.json 2017-07-21 14:49:41 +0000
@@ -11,5 +11,11 @@
"license": "AGPL-3.0",
"dependencies": {
"yui": "3.10.3"
+ },
+ "devDependencies": {
+ "eslint": "^4.2.0"
+ },
+ "scripts": {
+ "lint": "eslint 'lib/lp/**/*.js'"
}
}
=== modified file 'utilities/lint'
--- utilities/lint 2017-01-17 22:23:39 +0000
+++ utilities/lint 2017-07-21 14:49:41 +0000
@@ -31,10 +31,21 @@
fi
# Sample data contains auto generated files with long lines.
-pocketlint_files=`echo "$files" | env -i grep -v ".sql$"`
+pocketlint_files=`echo "$files" | env -i grep -v '\.sql$'`
if [ -z "$pocketlint_files" ]; then
exit 0
fi
-
-echo ""
-pocketlint $pocketlint_files 2>&1
+pocketlint_files=`echo "$pocketlint_files" | tr " " "\n"`
+
+non_js_files=`echo "$pocketlint_files" | env -i grep -v '\.js$'`
+js_files=`echo "$pocketlint_files" | env -i grep '\.js$'`
+
+ret=0
+if [ "$non_js_files" ]; then
+ echo ""
+ pocketlint $non_js_files 2>&1 || ret=$?
+fi
+if [ "$js_files" ]; then
+ nodejs node_modules/.bin/eslint $js_files 2>&1 || ret=$?
+fi
+exit $ret
Follow ups