Skip to content

Commit 0913325

Browse files
committed
Adding linting and fixing linter warnings. Reducing timeouts to 7 seconds.
1 parent b11415d commit 0913325

File tree

5 files changed

+256
-136
lines changed

5 files changed

+256
-136
lines changed

.gitignore

+1-9
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,4 @@ Thumbs.db
1212
*.swp
1313
*.user
1414

15-
16-
17-
18-
19-
20-
21-
22-
23-
15+
node_modules

.jscsrc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"disallowMixedSpacesAndTabs": true,
3+
"disallowTrailingWhitespace": true,
4+
"validateLineBreaks": "CRLF",
5+
"validateIndentation": 4,
6+
"requireLineFeedAtFileEnd": true,
7+
8+
"disallowSpaceAfterPrefixUnaryOperators": true,
9+
"disallowSpaceBeforePostfixUnaryOperators": true,
10+
"requireSpaceAfterLineComment": true,
11+
"requireCapitalizedConstructors": true,
12+
13+
"disallowSpacesInNamedFunctionExpression": {
14+
"beforeOpeningRoundBrace": true
15+
},
16+
17+
"requireSpaceAfterKeywords": [
18+
"if",
19+
"else",
20+
"for",
21+
"while",
22+
"do"
23+
]
24+
}

.jshintrc

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
// Copied from http://jshint.com/docs/
3+
4+
"maxerr" : 50, // {int} Maximum error before stopping
5+
6+
// Enforcing
7+
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
8+
"camelcase" : false, // true: Identifiers must be in camelCase
9+
"curly" : true, // true: Require {} for every new block or scope
10+
"eqeqeq" : true, // true: Require triple equals (===) for comparison
11+
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
12+
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
13+
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
14+
"latedef" : true, // true: Require variables/functions to be defined before being used
15+
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
16+
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
17+
"noempty" : true, // true: Prohibit use of empty blocks
18+
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
19+
"nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment)
20+
"plusplus" : true, // true: Prohibit use of `++` and `--`
21+
"quotmark" : false, // Quotation mark consistency:
22+
// false : do nothing (default)
23+
// true : ensure whatever is used is consistent
24+
// "single" : require single quotes
25+
// "double" : require double quotes
26+
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
27+
"unused" : "strict", // Unused variables:
28+
// true : all variables, last function parameter
29+
// "vars" : all variables only
30+
// "strict" : all variables, all function parameters
31+
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
32+
"maxparams" : false, // {int} Max number of formal params allowed per function
33+
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
34+
"maxstatements" : false, // {int} Max number statements per function
35+
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
36+
"maxlen" : false, // {int} Max number of characters per line
37+
"varstmt" : false, // true: Disallow any var statements. Only `let` and `const` are allowed.
38+
39+
// Relaxing
40+
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
41+
"boss" : false, // true: Tolerate assignments where comparisons would be expected
42+
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
43+
"eqnull" : false, // true: Tolerate use of `== null`
44+
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
45+
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
46+
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
47+
// (ex: `for each`, multiple try/catch, function expression…)
48+
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
49+
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
50+
"funcscope" : false, // true: Tolerate defining variables inside control statements
51+
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
52+
"iterator" : false, // true: Tolerate using the `__iterator__` property
53+
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
54+
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
55+
"laxcomma" : false, // true: Tolerate comma-first style coding
56+
"loopfunc" : false, // true: Tolerate functions being defined in loops
57+
"multistr" : false, // true: Tolerate multi-line strings
58+
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
59+
"notypeof" : false, // true: Tolerate invalid typeof operator values
60+
"proto" : false, // true: Tolerate using the `__proto__` property
61+
"scripturl" : false, // true: Tolerate script-targeted URLs
62+
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
63+
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
64+
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
65+
"validthis" : false, // true: Tolerate using this in a non-constructor function
66+
67+
// Environments
68+
"browser" : true, // Web Browser (window, document, etc)
69+
"browserify" : false, // Browserify (node.js code in the browser)
70+
"couch" : false, // CouchDB
71+
"devel" : true, // Development/debugging (alert, confirm, etc)
72+
"dojo" : false, // Dojo Toolkit
73+
"jasmine" : true, // Jasmine
74+
"jquery" : false, // jQuery
75+
"mocha" : false, // Mocha
76+
"mootools" : false, // MooTools
77+
"node" : false, // Node.js
78+
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
79+
"phantom" : false, // PhantomJS
80+
"prototypejs" : false, // Prototype and Scriptaculous
81+
"qunit" : false, // QUnit
82+
"rhino" : false, // Rhino
83+
"shelljs" : false, // ShellJS
84+
"typed" : false, // Globals for typed array constructions
85+
"worker" : false, // Web Workers
86+
"wsh" : false, // Windows Scripting Host
87+
"yui" : false, // Yahoo User Interface
88+
89+
// Custom Globals
90+
"globals" : {} // additional predefined global variables
91+
}

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"browser"
1919
]
2020
},
21+
"scripts": {
22+
"test": "npm run lint && npm run style",
23+
"style": "node_modules/.bin/jscs tests/tests.js",
24+
"lint": "node_modules/.bin/jshint tests/tests.js"
25+
},
2126
"repository": {
2227
"type": "git",
2328
"url": "https://github.com/apache/cordova-plugin-file-transfer"
@@ -43,5 +48,9 @@
4348
"cordova-plugin-file": "^3.0.0"
4449
},
4550
"author": "Apache Software Foundation",
46-
"license": "Apache 2.0"
51+
"license": "Apache 2.0",
52+
"devDependencies": {
53+
"jscs": "^2.6.0",
54+
"jshint": "^2.8.0"
55+
}
4756
}

0 commit comments

Comments
 (0)