Skip to content
This repository has been archived by the owner on Sep 13, 2018. It is now read-only.

Commit

Permalink
Update makefiles, jshint/jscs -> eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolas committed Aug 30, 2017
1 parent 3a21689 commit 1177f0f
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 45 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,8 @@
1.11.0
===================

* Use eslint instead of jshint/jscs

1.10.0 (2015-06-05)
===================

Expand Down
5 changes: 3 additions & 2 deletions ccnmtldjango/template/django.mk
@@ -1,6 +1,7 @@
# VERSION=1.4.0
# VERSION=1.5.0

# CHANGES:
# 1.5.0 - 2017-08-24 - remove jshint/jscs in favor of eslint
# 1.4.0 - 2017-06-06 - backout the switch to eslint. that's not really ready yet.
# 1.3.0 - 2017-06-05 - pypi location is not needed anymore
# 1.2.0 - 2016-12-15 - bump wheel version to 0.29
Expand All @@ -22,7 +23,7 @@ INTERFACE ?= localhost
RUNSERVER_PORT ?= 8000
PY_DIRS ?= $(APP)

jenkins: check flake8 test jshint jscs
jenkins: check flake8 test eslint

$(PY_SENTINAL): $(REQUIREMENTS) $(VIRTUALENV) $(SUPPORT_DIR)*
rm -rf $(VE)
Expand Down
1 change: 1 addition & 0 deletions ccnmtldjango/template/docker.mk
Expand Up @@ -30,6 +30,7 @@ $(WHEELHOUSE)/requirements.txt: $(REQUIREMENTS)
cp $(REQUIREMENTS) $@
touch $@

# Run this target to rebuild the django image
build: $(WHEELHOUSE)/requirements.txt
docker build -t $(IMAGE) .

Expand Down
89 changes: 89 additions & 0 deletions ccnmtldjango/template/eslintrc.js
@@ -0,0 +1,89 @@
module.exports = {
"env": {
"browser": true,
"amd": true,
"jquery": true
},
"plugins": [
"security",
"scanjs-rules",
"no-unsafe-innerhtml"
],
"extends": [
"eslint:recommended",
"plugin:security/recommended"
],
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"no-unused-vars": [
"error",
{"vars": "all", "args": "none"}
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
/** no-unsafe-innerhtml rule **/
"no-unsafe-innerhtml/no-unsafe-innerhtml" : 2,

/** ScanJS rules **/
"scanjs-rules/assign_to_hostname": 1,
"scanjs-rules/assign_to_href": 1,
"scanjs-rules/assign_to_location": 1,
"scanjs-rules/assign_to_onmessage": 1,
"scanjs-rules/assign_to_pathname": 1,
"scanjs-rules/assign_to_protocol": 1,
"scanjs-rules/assign_to_search": 1,
"scanjs-rules/assign_to_src": 1,
"scanjs-rules/call_Function": 1,
"scanjs-rules/call_addEventListener": 1,
"scanjs-rules/call_addEventListener_deviceproximity": 1,
"scanjs-rules/call_addEventListener_message": 1,
"scanjs-rules/call_connect": 1,
"scanjs-rules/call_eval": 1,
"scanjs-rules/call_execScript": 1,
"scanjs-rules/call_hide": 0, /* hide used often. overly cautious */
"scanjs-rules/call_open_remote=true": 1,
"scanjs-rules/call_parseFromString": 1,
"scanjs-rules/call_setImmediate": 1,
"scanjs-rules/call_setInterval": 1,
"scanjs-rules/call_setTimeout": 1,
"scanjs-rules/identifier_indexedDB": 1,
"scanjs-rules/identifier_localStorage": 1,
"scanjs-rules/identifier_sessionStorage": 1,
"scanjs-rules/new_Function": 1,
"scanjs-rules/property_addIdleObserver": 1,
"scanjs-rules/property_createContextualFragment": 1,
"scanjs-rules/property_geolocation": 1,
"scanjs-rules/property_getUserMedia": 1,
"scanjs-rules/property_indexedDB": 1,
"scanjs-rules/property_localStorage": 1,
"scanjs-rules/property_mgmt": 1,
"scanjs-rules/property_sessionStorage": 1,

'security/detect-buffer-noassert': 1,
'security/detect-child-process': 1,
'security/detect-disable-mustache-escape': 1,
'security/detect-eval-with-expression': 1,
'security/detect-new-buffer': 1,
'security/detect-no-csrf-before-method-override': 1,
'security/detect-non-literal-fs-filename': 1,
'security/detect-non-literal-regexp': 1,
'security/detect-non-literal-require': 0, /* requirejs conflict */
'security/detect-object-injection': 0, /* several false positives */
'security/detect-possible-timing-attacks': 1,
'security/detect-pseudoRandomBytes': 1,
'security/detect-unsafe-regex': 1
}
};
29 changes: 20 additions & 9 deletions ccnmtldjango/template/js.mk
@@ -1,25 +1,36 @@
# VERSION=1.0.0
# VERSION=1.3.0

# CHANGES:
# 1.3.0 - restore eslint
# 1.2.0 - restore jshint/jscs

# expect JS_FILES to be set from the main Makefile, but default
# to everything in media/js otherwise.
#
# When setting a custom value for this variable in your own Makefile,
# the line should look like this:
# JS_FILES=media/js/src media/js/tests
#
# and not:
# JS_FILES="media/js/src media/js/tests"
#
# Using quotes here will cause eslint to ignore this argument.
#
JS_FILES ?= media/js

NODE_MODULES ?= ./node_modules
JS_SENTINAL ?= $(NODE_MODULES)/sentinal
JSHINT ?= $(NODE_MODULES)/jshint/bin/jshint
JSCS ?= $(NODE_MODULES)/jscs/bin/jscs
ESLINT ?= $(NODE_MODULES)/.bin/eslint

$(JS_SENTINAL): package.json
rm -rf $(NODE_MODULES)
npm install
touch $(JS_SENTINAL)

jshint: $(JS_SENTINAL)
$(JSHINT) $(JS_FILES)

jscs: $(JS_SENTINAL)
$(JSCS) $(JS_FILES)
eslint: $(JS_SENTINAL)
$(ESLINT) $(JS_FILES)

jstest: $(JS_SENTINAL)
npm test

.PHONY: jshint jscs jstest
.PHONY: eslint jstest
5 changes: 0 additions & 5 deletions ccnmtldjango/template/jscsrc

This file was deleted.

24 changes: 0 additions & 24 deletions ccnmtldjango/template/jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion ccnmtldjango/template/media/js/tests/example-test.js
@@ -1,4 +1,4 @@
/* jshint mocha: true */
/* eslint-env mocha */

var assert = require('assert');
var requirejs = require('requirejs');
Expand Down
2 changes: 1 addition & 1 deletion ccnmtldjango/template/media/js/tests/test-runner.js
@@ -1,4 +1,4 @@
/* jshint node: true */
/* eslint-env node */

var requirejs = require('requirejs');
requirejs.config({
Expand Down
6 changes: 4 additions & 2 deletions ccnmtldjango/template/package.json_tmpl
Expand Up @@ -7,8 +7,10 @@
"test": "mocha"
},
"devDependencies": {
"jscs": "~3.0.7",
"jshint": "~2.9.4",
"eslint": "~4.5.0",
"eslint-plugin-no-unsafe-innerhtml": "~1.0.16",
"eslint-plugin-scanjs-rules": "~0.2.1",
"eslint-plugin-security": "~1.4.0",
"mocha": "~3.1.2",
"requirejs": "~2.3.2",
"sinon": "~1.17.6"
Expand Down
2 changes: 1 addition & 1 deletion run_tests.sh
Expand Up @@ -10,7 +10,7 @@ virtualenv temp/outer-ve
cd temp
./outer-ve/bin/paster create --template=ccnmtldjango testproject
cd testproject
mv jscsrc .jscsrc
mv eslintrc.js .eslintrc.js
chmod +x manage.py

# run our tests (finally!)
Expand Down

0 comments on commit 1177f0f

Please sign in to comment.