[React] [tests] Using JSHint instead of JSLint

- for using jsx in React js
- grunt-jsxhint task added

Related to blueprint backbone-to-react

Change-Id: Icab0dce882699a518bb4959847f0294c90558658
This commit is contained in:
Alexandra Morozova 2014-07-23 19:18:30 +03:00 committed by Vitaly Kramskikh
parent 6304df2eb8
commit 5284ca6f97
8 changed files with 405 additions and 115 deletions

View File

@ -60,7 +60,7 @@ Setup for Nailgun Unit Tests
#. Run the Nailgun backend unit tests::
./run_tests.sh --no-jslint --no-webui
./run_tests.sh --no-lint-ui --no-webui
#. Run the Nailgun flake8 test::
@ -106,7 +106,7 @@ Setup for Web UI Tests
PostgreSQL)::
cd fuel-web
./run_tests.sh --jslint
./run_tests.sh --lint-ui
./run_tests.sh --webui
.. _running-nailgun-in-fake-mode:

View File

@ -49,9 +49,9 @@ implement this feature, these steps were followed:
#. Test your Nailgun changes::
cd fuel-web
./run_tests.sh --no-jslint --no-webui
./run_tests.sh --no-lint-ui --no-webui
./run_tests.sh --flake8
./run_tests.sh --jslint
./run_tests.sh --lint-ui
./run_tests.sh --webui
#. You should also test Nailgun in fake UI mode by following

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013 Mirantis, Inc.
* Copyright 2014 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
@ -49,25 +49,26 @@ module.exports = function(grunt) {
}
}
},
jslint: {
client: {
src: [
'static/js/**/*.js',
'!static/js/libs/**',
'!static/js/expression_parser.js'
],
directives: {
predef: ['requirejs', 'require', 'define', 'app', 'Backbone', '$', '_'],
ass: true,
browser: true,
unparam: true,
nomen: true,
eqeq: true,
vars: true,
white: true,
es5: false
}
}
jshint: {
options: {
reporter: require('jshint-stylish'),
eqeqeq: false,
browser: true,
bitwise: true,
newcap: false,
undef: true,
predef: ['requirejs', 'require', 'define', 'app', 'Backbone', '$', '_'],
strict: true,
lastsemic: true,
scripturl: true,
"-W041": false
},
all: [
'static/js/**/*.js',
'static/js/**/*.jsx',
'!static/js/libs/**',
'!static/js/expression_parser.js'
]
},
less: {
all: {
@ -244,5 +245,6 @@ module.exports = function(grunt) {
'clean:finalize_build'
]);
grunt.registerTask('default', ['build']);
grunt.registerTask('lint-ui', ['jshint']);
grunt.task.loadTasks('grunt');
};

View File

@ -266,7 +266,7 @@
"dependencies": {
"qs": {
"version": "0.6.6",
"from": "qs@~0.6.0"
"from": "qs@0.6.6"
},
"json-stringify-safe": {
"version": "5.0.0",
@ -368,7 +368,7 @@
},
"mkdirp": {
"version": "0.3.5",
"from": "mkdirp@~0.3.5"
"from": "mkdirp@0.3.5"
}
}
},
@ -410,7 +410,7 @@
"dependencies": {
"ansi-regex": {
"version": "0.2.1",
"from": "ansi-regex@^0.2.0"
"from": "ansi-regex@^0.2.1"
}
}
},
@ -420,7 +420,7 @@
"dependencies": {
"ansi-regex": {
"version": "0.2.1",
"from": "ansi-regex@^0.2.0"
"from": "ansi-regex@^0.2.1"
}
}
},
@ -536,7 +536,7 @@
"dependencies": {
"inherits": {
"version": "2.0.1",
"from": "inherits@2"
"from": "inherits@~2.0.1"
},
"minimatch": {
"version": "1.0.0",
@ -556,7 +556,7 @@
},
"graceful-fs": {
"version": "3.0.2",
"from": "graceful-fs@^3.0.2"
"from": "graceful-fs@~3.0.1"
},
"handlebars": {
"version": "1.3.0",
@ -696,7 +696,7 @@
"dependencies": {
"async": {
"version": "0.9.0",
"from": "async@^0.9.0"
"from": "async@~0.9.0"
},
"configstore": {
"version": "0.3.1",
@ -798,7 +798,7 @@
},
"mute-stream": {
"version": "0.0.4",
"from": "mute-stream@0.0.4"
"from": "mute-stream@~0.0.4"
},
"readline2": {
"version": "0.1.0",
@ -958,7 +958,7 @@
},
"mime": {
"version": "1.2.11",
"from": "mime@~1.2.9"
"from": "mime@~1.2.11"
}
}
},
@ -1042,7 +1042,7 @@
},
"lru-cache": {
"version": "2.5.0",
"from": "lru-cache@2"
"from": "lru-cache@~2.5.0"
},
"mkdirp": {
"version": "0.5.0",
@ -1060,7 +1060,7 @@
},
"nopt": {
"version": "3.0.1",
"from": "nopt@^3.0.0"
"from": "nopt@~3.0.0"
},
"opn": {
"version": "0.1.2",
@ -1114,7 +1114,7 @@
},
"mime": {
"version": "1.2.11",
"from": "mime@~1.2.11"
"from": "mime@~1.2.9"
},
"forever-agent": {
"version": "0.5.2",
@ -1150,7 +1150,7 @@
},
"async": {
"version": "0.9.0",
"from": "async@>= 0.1.18"
"from": "async@~0.9.0"
}
}
},
@ -1266,7 +1266,7 @@
},
"inherits": {
"version": "2.0.1",
"from": "inherits@2"
"from": "inherits@~2.0.1"
}
}
},
@ -1354,7 +1354,7 @@
},
"inherits": {
"version": "2.0.1",
"from": "inherits@~2.0.0"
"from": "inherits@~2.0.1"
},
"ini": {
"version": "1.2.1",
@ -1566,7 +1566,7 @@
},
"qs": {
"version": "0.6.6",
"from": "qs@~0.6.0"
"from": "qs@0.6.6"
},
"bytes": {
"version": "0.2.1",
@ -1638,7 +1638,7 @@
},
"mkdirp": {
"version": "0.3.5",
"from": "mkdirp@~0.3.5"
"from": "mkdirp@0.3.5"
},
"cookie": {
"version": "0.1.0",
@ -1678,7 +1678,7 @@
},
"async": {
"version": "0.2.10",
"from": "async@~0.2.6"
"from": "async@~0.2.8"
},
"glob": {
"version": "3.2.11",
@ -1748,57 +1748,307 @@
"version": "1.2.1",
"from": "grunt-jison@~1.2.1"
},
"grunt-jslint": {
"version": "1.1.12",
"from": "grunt-jslint@~1.1.1",
"grunt-jsxhint": {
"version": "0.2.0",
"from": "grunt-jsxhint@~0.2.0",
"dependencies": {
"jslint": {
"version": "0.6.2",
"from": "jslint@>=0.5.0",
"proxyquire": {
"version": "1.0.1",
"from": "proxyquire@~1.0.1"
},
"rewire": {
"version": "2.1.0",
"from": "rewire@~2.1.0"
},
"react-tools": {
"version": "0.11.1",
"from": "react-tools@~0.11.1",
"dependencies": {
"exit": {
"version": "0.1.2",
"from": "exit@^0.1.2"
},
"glob": {
"version": "4.0.5",
"from": "glob@~4.0.2",
"commoner": {
"version": "0.9.8",
"from": "commoner@^0.9.6",
"dependencies": {
"inherits": {
"version": "2.0.1",
"from": "inherits@2"
"q": {
"version": "1.0.1",
"from": "q@~1.0.1"
},
"minimatch": {
"version": "1.0.0",
"from": "minimatch@^1.0.0",
"recast": {
"version": "0.7.1",
"from": "recast@~0.7.0",
"dependencies": {
"lru-cache": {
"version": "2.5.0",
"from": "lru-cache@2"
"esprima-fb": {
"version": "5001.1.0-dev-harmony-fb",
"from": "esprima-fb@~5001.1.0-dev-harmony-fb"
},
"sigmund": {
"version": "1.0.0",
"from": "sigmund@~1.0.0"
"source-map": {
"version": "0.1.32",
"from": "source-map@0.1.32",
"dependencies": {
"amdefine": {
"version": "0.1.0",
"from": "amdefine@>=0.0.4"
}
}
},
"cls": {
"version": "0.1.5",
"from": "cls@~0.1.3"
},
"ast-types": {
"version": "0.4.9",
"from": "ast-types@~0.4.7"
}
}
},
"once": {
"version": "1.3.0",
"from": "once@^1.3.0"
"commander": {
"version": "2.2.0",
"from": "commander@~2.2.0"
},
"graceful-fs": {
"version": "3.0.2",
"from": "graceful-fs@^3.0.2"
"version": "2.0.3",
"from": "graceful-fs@~2.0.0"
},
"glob": {
"version": "3.2.11",
"from": "glob@~3.2.9",
"dependencies": {
"inherits": {
"version": "2.0.1",
"from": "inherits@2"
},
"minimatch": {
"version": "0.3.0",
"from": "minimatch@0.3",
"dependencies": {
"lru-cache": {
"version": "2.5.0",
"from": "lru-cache@2"
},
"sigmund": {
"version": "1.0.0",
"from": "sigmund@~1.0.0"
}
}
}
}
},
"mkdirp": {
"version": "0.3.5",
"from": "mkdirp@0.3.5"
},
"private": {
"version": "0.1.5",
"from": "private@~0.1.2"
},
"install": {
"version": "0.1.7",
"from": "install@~0.1.7",
"dependencies": {
"whiskey": {
"version": "0.6.13",
"from": "whiskey@0.6.x",
"dependencies": {
"sprintf": {
"version": "0.1.4",
"from": "sprintf@>= 0.1.1"
},
"async": {
"version": "0.9.0",
"from": "async@>= 0.1.18"
},
"magic-templates": {
"version": "0.1.1",
"from": "magic-templates@= 0.1.1"
},
"rimraf": {
"version": "1.0.1",
"from": "rimraf@= 1.0.1"
},
"terminal": {
"version": "0.1.3",
"from": "terminal@= 0.1.3"
},
"gex": {
"version": "0.0.1",
"from": "gex@= 0.0.1"
},
"simplesets": {
"version": "1.1.6",
"from": "simplesets@= 1.1.6"
},
"logmagic": {
"version": "0.1.4",
"from": "logmagic@= 0.1.4"
},
"underscore": {
"version": "1.7.0",
"from": "underscore@>= 1.4.2"
}
}
}
}
},
"iconv-lite": {
"version": "0.2.11",
"from": "iconv-lite@~0.2.11"
}
}
},
"nopt": {
"version": "3.0.1",
"from": "nopt@^3.0.0",
"esprima-fb": {
"version": "4001.3001.0-dev-harmony-fb",
"from": "esprima-fb@^4001.3001.0-dev-harmony-fb"
}
}
},
"grunt-contrib-jshint": {
"version": "0.10.0",
"from": "grunt-contrib-jshint@0.10.0",
"dependencies": {
"hooker": {
"version": "0.2.3",
"from": "hooker@~0.2.3"
}
}
},
"jshint": {
"version": "2.5.5",
"from": "jshint@~2.5.1",
"dependencies": {
"shelljs": {
"version": "0.3.0",
"from": "shelljs@0.3.x"
},
"underscore": {
"version": "1.6.0",
"from": "underscore@1.6.x"
},
"cli": {
"version": "0.6.4",
"from": "cli@0.6.x",
"dependencies": {
"abbrev": {
"version": "1.0.5",
"from": "abbrev@1"
"glob": {
"version": "3.2.11",
"from": "glob@~ 3.2.1",
"dependencies": {
"inherits": {
"version": "2.0.1",
"from": "inherits@2"
},
"minimatch": {
"version": "0.3.0",
"from": "minimatch@0.3",
"dependencies": {
"lru-cache": {
"version": "2.5.0",
"from": "lru-cache@2"
},
"sigmund": {
"version": "1.0.0",
"from": "sigmund@~1.0.0"
}
}
}
}
}
}
},
"minimatch": {
"version": "0.4.0",
"from": "minimatch@0.x.x",
"dependencies": {
"lru-cache": {
"version": "2.5.0",
"from": "lru-cache@2"
},
"sigmund": {
"version": "1.0.0",
"from": "sigmund@~1.0.0"
}
}
},
"htmlparser2": {
"version": "3.7.3",
"from": "htmlparser2@3.7.x",
"dependencies": {
"domhandler": {
"version": "2.2.0",
"from": "domhandler@2.2"
},
"domutils": {
"version": "1.5.0",
"from": "domutils@1.5"
},
"domelementtype": {
"version": "1.1.1",
"from": "domelementtype@1"
},
"readable-stream": {
"version": "1.1.13",
"from": "readable-stream@1.1",
"dependencies": {
"core-util-is": {
"version": "1.0.1",
"from": "core-util-is@~1.0.0"
},
"isarray": {
"version": "0.0.1",
"from": "isarray@0.0.1"
},
"string_decoder": {
"version": "0.10.31",
"from": "string_decoder@~0.10.x"
},
"inherits": {
"version": "2.0.1",
"from": "inherits@~2.0.1"
}
}
},
"entities": {
"version": "1.0.0",
"from": "entities@1.0"
}
}
},
"console-browserify": {
"version": "1.1.0",
"from": "console-browserify@1.1.x",
"dependencies": {
"date-now": {
"version": "0.1.4",
"from": "date-now@^0.1.4"
}
}
},
"exit": {
"version": "0.1.2",
"from": "exit@0.1.x"
},
"strip-json-comments": {
"version": "0.1.3",
"from": "strip-json-comments@0.1.x"
}
}
},
"jstransform": {
"version": "6.1.0",
"from": "jstransform@~6.1.0",
"dependencies": {
"base62": {
"version": "0.1.1",
"from": "base62@0.1.1"
},
"esprima-fb": {
"version": "4001.3001.0-dev-harmony-fb",
"from": "esprima-fb@~4001.3001.0-dev-harmony-fb"
},
"source-map": {
"version": "0.1.31",
"from": "source-map@0.1.31",
"dependencies": {
"amdefine": {
"version": "0.1.0",
"from": "amdefine@>=0.0.4"
}
}
}
@ -1856,7 +2106,7 @@
},
"graceful-fs": {
"version": "2.0.3",
"from": "graceful-fs@~2.0.3"
"from": "graceful-fs@~2.0.0"
},
"glob": {
"version": "3.2.11",
@ -1904,7 +2154,7 @@
},
"async": {
"version": "0.9.0",
"from": "async@~0.9.0"
"from": "async@>= 0.1.18"
},
"magic-templates": {
"version": "0.1.1",
@ -2010,7 +2260,7 @@
},
"source-map": {
"version": "0.1.39",
"from": "source-map@~0.1.33",
"from": "source-map@0.1.x",
"dependencies": {
"amdefine": {
"version": "0.1.0",
@ -2064,19 +2314,55 @@
}
}
},
"jslint": {
"version": "0.2.11",
"from": "jslint@~0.2.5",
"jshint-stylish": {
"version": "0.4.0",
"from": "jshint-stylish@~0.4.0",
"dependencies": {
"nopt": {
"version": "1.0.10",
"from": "nopt@~1.0.0",
"chalk": {
"version": "0.5.1",
"from": "chalk@^0.5.1",
"dependencies": {
"abbrev": {
"version": "1.0.5",
"from": "abbrev@1"
"ansi-styles": {
"version": "1.1.0",
"from": "ansi-styles@^1.1.0"
},
"escape-string-regexp": {
"version": "1.0.1",
"from": "escape-string-regexp@^1.0.0"
},
"has-ansi": {
"version": "0.1.0",
"from": "has-ansi@^0.1.0",
"dependencies": {
"ansi-regex": {
"version": "0.2.1",
"from": "ansi-regex@^0.2.1"
}
}
},
"strip-ansi": {
"version": "0.3.0",
"from": "strip-ansi@^0.3.0",
"dependencies": {
"ansi-regex": {
"version": "0.2.1",
"from": "ansi-regex@^0.2.1"
}
}
},
"supports-color": {
"version": "0.2.0",
"from": "supports-color@^0.2.0"
}
}
},
"log-symbols": {
"version": "1.0.0",
"from": "log-symbols@^1.0.0"
},
"text-table": {
"version": "0.2.0",
"from": "text-table@^0.2.0"
}
}
},
@ -2150,7 +2436,7 @@
},
"tough-cookie": {
"version": "0.12.1",
"from": "tough-cookie@^0.12.1",
"from": "tough-cookie@>=0.12.0",
"dependencies": {
"punycode": {
"version": "1.3.1",
@ -2174,7 +2460,7 @@
},
"async": {
"version": "0.9.0",
"from": "async@>= 0.1.18"
"from": "async@~0.9.0"
}
}
},
@ -2234,7 +2520,7 @@
},
"mkdirp": {
"version": "0.3.5",
"from": "mkdirp@0.3.5"
"from": "mkdirp@~0.3.5"
},
"clean-css": {
"version": "2.0.8",
@ -2276,7 +2562,7 @@
},
"source-map": {
"version": "0.1.39",
"from": "source-map@0.1.x",
"from": "source-map@~0.1.7",
"dependencies": {
"amdefine": {
"version": "0.1.0",

View File

@ -13,14 +13,14 @@
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-less": "~0.8.2",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-jison": "~1.2.1",
"grunt-jsxhint": "~0.2.0",
"grunt-debug-task": "~0.1.3",
"grunt-git-revision": "~0.0.1",
"grunt-jison": "~1.2.1",
"grunt-jslint": "~1.1.1",
"grunt-react": "~0.9.0",
"grunt-text-replace": "~0.3.12",
"jison": "~0.4.13",
"jslint": "~0.2.5",
"jshint-stylish": "~0.4.0",
"less": "~1.5.1",
"lodash-node": "~2.4.1",
"requirejs": "~2.1.9",

View File

@ -245,12 +245,12 @@ define(['require', 'expression_parser', 'react'], function(require, ExpressionPa
validateIpCorrespondsToCIDR: function(cidr, ip) {
var result = true;
if (cidr) {
/*jslint bitwise: true*/
/* jshint bitwise: false */
var networkAddressToInt = utils.ipIntRepresentation(cidr.split('/')[0]);
var netmask = ~((Math.pow(2, 32) - 1) >>> cidr.split('/')[1]);
var ipToInt = utils.ipIntRepresentation(ip);
result = (networkAddressToInt & netmask).toString(16) == (ipToInt & netmask).toString(16);
/*jslint bitwise: false*/
/* jshint bitwise: true */
}
return result;
},

View File

@ -159,7 +159,7 @@ function(React, utils, models, componentMixins, dialogs) {
showNodeInfo: function(id) {
var node = new models.Node({id: id});
node.deferred = node.fetch();
(new dialogViews.ShowNodeInfoDialog({node: node})).render();
(new dialogs.ShowNodeInfoDialog({node: node})).render();
},
toggle: function(visible) {
this.props.togglePopover(visible);

View File

@ -34,8 +34,8 @@ function usage {
echo " -S, --no-shotgun Don't run SHOTGUN tests"
echo " -p, --flake8 Run FLAKE8 and HACKING compliance check"
echo " -P, --no-flake8 Don't run static code checks"
echo " -j, --jslint Run JSLINT compliance checks"
echo " -J, --no-jslint Don't run JSLINT checks"
echo " -l, --lint-ui Run UI linting tasks"
echo " -L, --no-lint-ui Don't run UI linting tasks"
echo " -t, --tests Run a given test files"
echo " -h, --help Print this usage message"
echo ""
@ -63,8 +63,8 @@ function process_options {
-S|--no-shotgun) no_shotgun_tests=1;;
-p|--flake8) flake8_checks=1;;
-P|--no-flake8) no_flake8_checks=1;;
-j|--jslint) jslint_checks=1;;
-J|--no-jslint) no_jslint_checks=1;;
-l|--lint-ui) lint_ui_checks=1;;
-L|--no-lint-ui) no_lint_ui_checks=1;;
-t|--tests) certain_tests=1;;
-*) testropts="$testropts $arg";;
*) testrargs="$testrargs $arg"
@ -78,7 +78,7 @@ TESTRTESTS="nosetests"
FLAKE8="flake8"
PEP8="pep8"
CASPERJS="casperjs"
JSLINT="grunt jslint"
LINTUI="grunt lint-ui"
# test options
testrargs=
@ -112,16 +112,18 @@ shotgun_tests=0
no_shotgun_tests=0
flake8_checks=0
no_flake8_checks=0
jslint_checks=0
no_jslint_checks=0
lint_ui_checks=0
no_lint_ui_checks=0
certain_tests=0
function run_tests {
run_cleanup
# This variable collects all failed tests. It'll be printed in
# the end of this function as a small statistic for user.
local errors=""
# If tests was specified in command line then run only these tests
if [ $certain_tests -eq 1 ]; then
for testfile in $testrargs; do
@ -139,7 +141,7 @@ function run_tests {
$upgrade_system -eq 0 && \
$shotgun_tests -eq 0 && \
$flake8_checks -eq 0 && \
$jslint_checks -eq 0 ]]; then
$lint_ui_checks -eq 0 ]]; then
if [ $no_agent_tests -ne 1 ]; then agent_tests=1; fi
if [ $no_nailgun_tests -ne 1 ]; then nailgun_tests=1; fi
@ -148,7 +150,7 @@ function run_tests {
if [ $no_upgrade_system -ne 1 ]; then upgrade_system=1; fi
if [ $no_shotgun_tests -ne 1 ]; then shotgun_tests=1; fi
if [ $no_flake8_checks -ne 1 ]; then flake8_checks=1; fi
if [ $no_jslint_checks -ne 1 ]; then jslint_checks=1; fi
if [ $no_lint_ui_checks -ne 1 ]; then lint_ui_checks=1; fi
fi
# Run all enabled tests
@ -187,9 +189,9 @@ function run_tests {
run_shotgun_tests || errors+=" shotgun_tests"
fi
if [ $jslint_checks -eq 1 ]; then
echo "Starting JSLint tests..."
run_jslint || errors+=" jslint_checks"
if [ $lint_ui_checks -eq 1 ]; then
echo "Starting JSHint tests..."
run_lint_ui || errors+=" lint_ui_checks"
fi
# print failed tests
@ -443,13 +445,13 @@ function run_flake8 {
}
# Check javascript files with `jslint`. It's necessary to run it inside
# Check javascript files with `jshint`. It's necessary to run it inside
# `nailgun` folder, so we temporary change current dir.
function run_jslint {
function run_lint_ui {
pushd $ROOT/nailgun >> /dev/null
local result=0
${JSLINT} || result=1
${LINTUI} || result=1
popd >> /dev/null
return $result