Skip to content

Commit 8349b56

Browse files
committed
linting plugins
1 parent 950f7e1 commit 8349b56

37 files changed

+802
-812
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/main/js/lib/json2.js

.eslintrc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ module.exports = {
1212
"__dirname": true,
1313
"persist": true,
1414
"isOp": true,
15-
"echo": true
15+
"echo": true,
16+
"scload": true,
17+
"nashorn": true,
18+
"plugin": true, // not the same as __plugin!!!
19+
"command": true,
20+
"config": true,
21+
"window": false,
22+
"document": false
1623
},
1724
"extends": "eslint:recommended",
1825
"rules": {

src/main/java/bukkit/org/scriptcraftjs/bukkit/ScriptCraftPlugin.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ public class ScriptCraftPlugin extends JavaPlugin implements Listener
3030
try {
3131
ScriptEngineManager factory = new ScriptEngineManager();
3232
this.engine = factory.getEngineByName("JavaScript");
33-
if (this.engine == null) {
34-
this.getLogger().severe(NO_JAVASCRIPT_MESSAGE);
35-
} else {
36-
Invocable inv = (Invocable) this.engine;
37-
this.engine.eval(new InputStreamReader(this.getResource("boot.js")));
38-
inv.invokeFunction("__scboot", this, engine);
39-
}
40-
} catch (Exception e) {
41-
e.printStackTrace();
42-
this.getLogger().severe(e.getMessage());
43-
} finally {
44-
currentThread.setContextClassLoader(previousClassLoader);
45-
}
33+
if (this.engine == null) {
34+
this.getLogger().severe(NO_JAVASCRIPT_MESSAGE);
35+
} else {
36+
Invocable inv = (Invocable) this.engine;
37+
this.engine.eval(new InputStreamReader(this.getResource("boot.js")));
38+
inv.invokeFunction("__scboot", this, engine);
39+
}
40+
} catch (Exception e) {
41+
e.printStackTrace();
42+
this.getLogger().severe(e.getMessage());
43+
} finally {
44+
currentThread.setContextClassLoader(previousClassLoader);
45+
}
4646
}
4747

4848
public List<String> onTabComplete(CommandSender sender, Command cmd,

src/main/js/lib/events-bukkit.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*global Java, exports, org, __plugin */
22
var bkEventPriority = org.bukkit.event.EventPriority,
33
bkEventExecutor = org.bukkit.plugin.EventExecutor,
4-
bkRegisteredListener = org.bukkit.plugin.RegisteredListener,
5-
bkEventPackage = 'org.bukkit.event.';
4+
bkRegisteredListener = org.bukkit.plugin.RegisteredListener;
65

76
var nashorn = (typeof Java != 'undefined');
87

@@ -15,7 +14,7 @@ function getHandlerListForEventType( eventType ){
1514
//so to avoid this problem, call getHandlerList using java.lang.reflect
1615
//methods
1716
clazz = eventType['class'];
18-
result = clazz.getMethod("getHandlerList").invoke(null);
17+
result = clazz.getMethod('getHandlerList').invoke(null);
1918

2019
} else {
2120
result = eventType.getHandlerList();

src/main/js/lib/events-canary.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*global nashorn, exports, require, Packages, __plugin*/
22
var cmPriority = Packages.net.canarymod.plugin.Priority,
33
cmCanary = Packages.net.canarymod.Canary,
4-
cmDispatcher = Packages.net.canarymod.hook.Dispatcher,
5-
cmRegisteredPluginListener = Packages.net.canarymod.plugin.RegisteredPluginListener,
64
cmPluginListener = Packages.net.canarymod.plugin.PluginListener;
75
var cmHookExecutor = cmCanary.hooks();
86

@@ -13,8 +11,7 @@ exports.on = function(
1311
handler,
1412
/* (optional) String (CRITICAL, HIGH, NORMAL, LOW, PASSIVE), */
1513
priority ) {
16-
var handlerList,
17-
regd,
14+
var regd,
1815
eventExecutor;
1916

2017
if ( typeof priority == 'undefined' ) {

src/main/js/lib/events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ if (__plugin.canary){
109109
}
110110
for ( var func in helper ) {
111111
module.exports[func] = helper[func];
112-
};
112+
}

src/main/js/lib/find.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ module.exports = function find(dir, filter) {
44
var result = [];
55
function recurse( dir, store ) {
66
var files,
7-
len,
8-
i,
9-
file,
10-
dirfile = new File( dir );
7+
len,
8+
i,
9+
file,
10+
dirfile = new File( dir );
1111

1212
if ( typeof filter == 'undefined' ) {
1313
files = dirfile.list();

src/main/js/lib/js-patch.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ module.exports = function( $ ) {
1313
Function.prototype.bind = (function (slice){
1414
// (C) WebReflection - Mit Style License
1515
function bind(context) {
16-
var self = this; // "trapped" function reference
17-
// only if there is more than an argument
16+
var self = this; // "trapped" function reference
17+
// only if there is more than an argument
1818
// we are interested into more complex operations
1919
// this will speed up common bind creation
2020
// avoiding useless slices over arguments
21-
if (1 < arguments.length) {
22-
// extra arguments to send by default
21+
if (1 < arguments.length) {
22+
// extra arguments to send by default
2323
var $arguments = slice.call(arguments, 1);
2424
return function () {
2525
return self.apply(
2626
context,
2727
// thanks @kangax for this suggestion
2828
arguments.length ?
29-
// concat arguments with those received
30-
$arguments.concat(slice.call(arguments)) :
31-
// send just arguments, no concat, no slice
32-
$arguments
29+
// concat arguments with those received
30+
$arguments.concat(slice.call(arguments)) :
31+
// send just arguments, no concat, no slice
32+
$arguments
3333
);
3434
};
3535
}
36-
// optimized callback
37-
return function () {
36+
// optimized callback
37+
return function () {
3838
// speed up when function is called without arguments
3939
return arguments.length ? self.apply(context, arguments) : self.call(context);
4040
};
@@ -52,8 +52,8 @@ module.exports = function( $ ) {
5252

5353
return function unitTest( console ) {
5454
/*
55-
sanity tests
56-
*/
55+
sanity tests
56+
*/
5757
$.setTimeout(function(){
5858
console.log('js-patch setTimeout() test complete');
5959
},100);
@@ -66,10 +66,10 @@ module.exports = function( $ ) {
6666
var clearAfterRuns = $.setInterval(function(){
6767
runs --;
6868
if (runs == 0){
69-
$.clearInterval(clearAfterRuns);
69+
$.clearInterval(clearAfterRuns);
7070
}
7171
if (runs < 0){
72-
console.error('js-patch clearInterval test failed.');
72+
console.error('js-patch clearInterval test failed.');
7373
}
7474
},100);
7575
};

0 commit comments

Comments
 (0)