Skip to content

Commit aaa038a

Browse files
committed
use jshint to lint
1 parent bce8d1a commit aaa038a

4 files changed

Lines changed: 18 additions & 20 deletions

File tree

.gitattributes

Lines changed: 0 additions & 17 deletions
This file was deleted.

.jshintrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"esversion": 5,
3+
"browser": true,
4+
"strict": "global",
5+
"unused": true,
6+
"undef": true,
7+
"curly": true,
8+
"eqeqeq": true,
9+
"forin": true,
10+
"devel": true
11+
}

js/i18n.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
'use strict';
12
var i18n = {};
3+
/* jshint -W069 */
24
i18n['en'] = {
35
won: "won",
46
total: "total",
@@ -9,7 +11,7 @@ i18n['en'] = {
911
rule2: "Each of the four given numerical digits <b>must appear once</b>, and <b>no other</b> digits are allowed.",
1012
rule3: "Besides digits, <b>only</b> these operators are allowed: <code>+</code> <code>-</code> <code>*</code> <code>/</code> <code>%</code> <code>~</code> <code>&amp;</code> <code>|</code> <code>^</code> <code>&lt;&lt;</code> <code>&gt;&gt;</code> <code>(</code> <code>)</code> and <code>x</code>(after a given <code>0</code>).",
1113
rule4: "In additional, to avoid <code>-~</code> from appearing continuously, <code>-</code> is <b>not allowed</b> to be used as a unary operator.",
12-
}
14+
};
1315
i18n['zh-CN'] = {
1416
won: "已获胜",
1517
total: "总局数",

js/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
function $(selector) {
23
return document.querySelector(selector);
34
}
@@ -45,6 +46,7 @@ $('#expr').addEventListener('input', function() {
4546
return;
4647
default:
4748
try {
49+
/* jshint -W061 */
4850
var result = eval($('#expr').value);
4951
if (result === null) {
5052
$('#result').innerHTML = 'null';
@@ -63,7 +65,7 @@ function check(result) {
6365
var expr = $('#expr').value;
6466
var e = expr.replace(/(\d|\))-/g, /$1/).replace(/&&|\|\|/g, '#').replace(/>>|<<|[+*\/%~^&|()]/g, '').replace(/0x/ig, '0');
6567
var digitsAppeared = 0;
66-
for (i = 0; i < 4; i++) {
68+
for (var i = 0; i < 4; i++) {
6769
if (e.match(localStorage.digits[i])) {
6870
e = e.replace(localStorage.digits[i], '');
6971
digitsAppeared += 1;
@@ -101,7 +103,7 @@ function success() {
101103
$('#solution').className = 'animate';
102104
$('#solution').innerHTML = ' = ' + $('#expr').value;
103105
$('#expr').setAttribute('disabled', '');
104-
setTimeout(function(params) {
106+
setTimeout(function() {
105107
printStats();
106108
$('#stats').className = 'hover';
107109
}, 250);

0 commit comments

Comments
 (0)