Replaced jshint with eslint & updated CS

master
Vitaly Puzrin 2015-03-24 05:28:20 +03:00
rodzic 4ace00c10b
commit cff11fc91b
28 zmienionych plików z 184 dodań i 141 usunięć

7
.eslintignore 100644
Wyświetl plik

@ -0,0 +1,7 @@
coverage/
demo/
dist/
node_modules
support/demo_template/sample.js
benchmark/implementations/
test/browser

118
.eslintrc 100644
Wyświetl plik

@ -0,0 +1,118 @@
env:
node: true
browser: false
plugins:
- nodeca
rules:
# block-scoped-var: 2
# brace-style: [ 2, '1tbs', { allowSingleLine: true } ]
# comma-spacing: 2
comma-style: 2
consistent-this: [ 2, self ]
consistent-return: 2
curly: 2
# default-case: 2
dot-notation: 2
eol-last: 2
eqeqeq: 2
# guard-for-in: 2
handle-callback-err: 2
# max-depth: [ 1, 6 ]
max-nested-callbacks: [ 1, 4 ]
# string can exceed 80 chars, but should not overflow github website :)
# max-len: [ 2, 120, 1000 ]
# new-cap: 2
new-parens: 2
no-alert: 2
no-array-constructor: 2
# no-bitwise: 2
no-caller: 2
no-catch-shadow: 2
no-comma-dangle: 2
no-cond-assign: 2
# no-console: 1
no-constant-condition: 2
no-control-regex: 2
no-debugger: 2
no-delete-var: 2
no-dupe-keys: 2
no-div-regex: 2
# no-empty: 2
no-empty-class: 2
no-empty-label: 2
no-else-return: 2
no-eq-null: 2
no-ex-assign: 2
no-extend-native: 2
no-extra-bind: 2
no-extra-boolean-cast: 2
no-extra-semi: 2
no-extra-strict: 2
no-eval: 2
no-floating-decimal: 2
no-func-assign: 2
no-implied-eval: 2
no-inner-declarations: 2
no-invalid-regexp: 2
no-irregular-whitespace: 2
no-label-var: 2
# no-labels: 2
no-lone-blocks: 2
no-lonely-if: 2
no-loop-func: 2
no-mixed-requires: 2
no-mixed-spaces-and-tabs: 2
no-multi-str: 2
no-native-reassign: 2
no-negated-in-lhs: 2
no-new: 2
no-new-func: 2
no-new-object: 2
no-new-require: 2
no-new-wrappers: 2
no-obj-calls: 2
no-octal: 2
no-octal-escape: 2
no-path-concat: 2
no-redeclare: 2
no-regex-spaces: 2
no-reserved-keys: 2
no-return-assign: 2
no-script-url: 2
no-sequences: 2
no-shadow: 2
no-shadow-restricted-names: 2
# no-space-before-semi: 2
no-sparse-arrays: 2
no-trailing-spaces: 2
no-undef: 2
no-undef-init: 2
no-undefined: 2
no-unreachable: 2
no-unused-expressions: 2
no-unused-vars: 2
no-use-before-define: 2
no-with: 2
no-wrap-func: 2
quotes: [ 2, single, avoid-escape ]
radix: 2
semi: 2
space-after-keywords: [ 2, always, , { "checkFunctionKeyword": true } ]
space-before-blocks: 2
# space-in-brackets: [ 2, always, { propertyName: false } ]
space-in-parens: [ 2, never ]
# space-infix-ops: 2
space-return-throw-case: 2
space-unary-ops: 2
# spaced-line-comment: [ 2, always, { exceptions: [ '/' ] } ]
strict: 2
use-isnan: 2
yoda: 2
valid-typeof: 2
#
# Our custom rules
#
nodeca/indent: [ 2, spaces, 2 ]

Wyświetl plik

@ -1,6 +0,0 @@
.git/
node_modules/
benchmark/implementations
coverage/
dist/
test/browser/pako.js

Wyświetl plik

@ -1,78 +0,0 @@
{
// Enforcing Options /////////////////////////////////////////////////////////
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"indent" : 2, // Specify indentation spacing
"latedef" : true, // Prohibit hariable use before definition.
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"plusplus" : false, // Prohibit use of `++` & `--`.
"quotmark" : "single", // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // Require all non-global variables be declared before they are used.
"unused" : true, // Warns when you define and never use your variables
"strict" : true, // Require `use strict` pragma in every file.
"trailing" : true, // Prohibit trailing whitespaces.
// Relaxing Options //////////////////////////////////////////////////////////
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // Tolerate use of `== null`.
//"es5" : true, // Allow ECMAScript 5 syntax.
"esnext" : false, // Allow ES.next specific features such as const and let
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
"funcscope" : false, // Tolerate declaring variables inside of control structures while accessing them later
"globalstrict" : true, // Allow global "use strict" (also enables 'strict').
"iterator" : false, // Allow usage of __iterator__ property.
"lastsemic" : false, // Tolerate semicolon omited for the last statement.
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"laxcomma" : true, // This option suppresses warnings about comma-first coding style
"loopfunc" : false, // Allow functions to be defined within loops.
"multistr" : false, // Tolerate multi-line strings.
"proto" : false, // Allow usage of __proto__ property.
"scripturl" : false, // Tolerate script-targeted URLs.
"smarttabs" : false, // Allow mixed tabs and spaces when the latter are used for alignmnent only.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"validthis" : false, // true: Tolerate using this in a non-constructor function
// Environments //////////////////////////////////////////////////////////////
"browser" : false, // Defines globals exposed by modern browsers
"couch" : false, // Defines globals exposed by CouchDB
"devel" : false, // Allow developments statements e.g. `console.log();`.
"dojo" : false, // Defines globals exposed by the Dojo Toolkit
"jquery" : false, // Defines globals exposed by the jQuery
"mootools" : false, // Defines globals exposed by the MooTools
"node" : true, // Defines globals exposed when running under Node.JS
"nonstandard" : false, // Defines non-standard but widely adopted globals such as escape and unescape
"prototypejs" : false, // Defines globals exposed by the Prototype
"rhino" : false, // Defines globals exposed when running under Rhino
"wsh" : false, // Defines globals exposed when running under WSH
"yui" : false, // Yahoo User Interface
// Legacy ////////////////////////////////////////////////////////////////////
"nomen" : false, // Prohibit use of initial or trailing underbars in names.
"onevar" : false, // Allow only one `var` statement per function.
"passfail" : false, // Stop on first error.
"white" : false, // Check against strict whitespace and indentation rules.
// Custom globals ///////////////////////////////////////////////////////////
"globals" : { }
}

Wyświetl plik

@ -1,7 +1,6 @@
language: node_js
node_js:
- "0.10"
before_script: "npm install"
script: make $COMMAND
env:
matrix:

Wyświetl plik

@ -23,7 +23,7 @@ help:
lint:
jshint . --show-non-errors
eslint --reset .
test: lint

Wyświetl plik

@ -20,8 +20,8 @@ var IMPLS = [];
fs.readdirSync(IMPLS_DIRECTORY).sort().forEach(function (name) {
var file = path.join(IMPLS_DIRECTORY, name),
code = require(file);
var file = path.join(IMPLS_DIRECTORY, name);
var code = require(file);
IMPLS_PATHS[name] = file;
IMPLS.push({
@ -85,7 +85,7 @@ fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) {
defer: !!impl.code.async,
fn: function (deferred) {
if (!!impl.code.async) {
if (impl.code.async) {
impl.code.run(content, LEVEL, function() {
deferred.resolve();
return;

Wyświetl plik

@ -1,9 +1,10 @@
'use strict';
var fs = require('fs');
var path = require('path');
var pako = require('../index.js');
var data = new Uint8Array(fs.readFileSync(__dirname +'/samples/lorem_1mb.txt'));
var data = new Uint8Array(fs.readFileSync(path.join(__dirname, '/samples/lorem_1mb.txt')));
var deflated = pako.deflate(data, { level: 6/*, to: 'string'*/ });

Wyświetl plik

@ -11,4 +11,4 @@ var pako = {};
assign(pako, deflate, inflate, constants);
module.exports = pako;
module.exports = pako;

Wyświetl plik

@ -361,4 +361,4 @@ function gzip(input, options) {
exports.Deflate = Deflate;
exports.deflate = deflate;
exports.deflateRaw = deflateRaw;
exports.gzip = gzip;
exports.gzip = gzip;

Wyświetl plik

@ -12,7 +12,7 @@ exports.assign = function (obj /*from1, from2, from3, ...*/) {
var source = sources.shift();
if (!source) { continue; }
if (typeof(source) !== 'object') {
if (typeof source !== 'object') {
throw new TypeError(source + 'must be non-object');
}
@ -43,7 +43,7 @@ var fnTyped = {
return;
}
// Fallback to ordinary array
for(var i=0; i<len; i++) {
for (var i=0; i<len; i++) {
dest[dest_offs + i] = src[src_offs + i];
}
},
@ -72,7 +72,7 @@ var fnTyped = {
var fnUntyped = {
arraySet: function (dest, src, src_offs, len, dest_offs) {
for(var i=0; i<len; i++) {
for (var i=0; i<len; i++) {
dest[dest_offs + i] = src[src_offs + i];
}
},
@ -99,4 +99,4 @@ exports.setTyped = function (on) {
}
};
exports.setTyped(TYPED_OK);
exports.setTyped(TYPED_OK);

Wyświetl plik

@ -21,8 +21,8 @@ try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch(__) { STR_APPL
// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
// because max possible codepoint is 0x10ffff
var _utf8len = new utils.Buf8(256);
for (var i=0; i<256; i++) {
_utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);
for (var q=0; q<256; q++) {
_utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
}
_utf8len[254]=_utf8len[254]=1; // Invalid sequence start
@ -91,7 +91,7 @@ function buf2binstring(buf, len) {
}
var result = '';
for(var i=0; i < len; i++) {
for (var i=0; i < len; i++) {
result += String.fromCharCode(buf[i]);
}
return result;
@ -107,7 +107,7 @@ exports.buf2binstring = function(buf) {
// Convert binary string (typed, when possible)
exports.binstring2buf = function(str) {
var buf = new utils.Buf8(str.length);
for(var i=0, len=buf.length; i < len; i++) {
for (var i=0, len=buf.length; i < len; i++) {
buf[i] = str.charCodeAt(i);
}
return buf;

Wyświetl plik

@ -5,9 +5,9 @@
// Small size is preferable.
function adler32(adler, buf, len, pos) {
var s1 = (adler & 0xffff) |0
, s2 = ((adler >>> 16) & 0xffff) |0
, n = 0;
var s1 = (adler & 0xffff) |0,
s2 = ((adler >>> 16) & 0xffff) |0,
n = 0;
while (len !== 0) {
// Set limit ~ twice less than 5552, to keep
@ -29,4 +29,4 @@ function adler32(adler, buf, len, pos) {
}
module.exports = adler32;
module.exports = adler32;

Wyświetl plik

@ -44,4 +44,4 @@ module.exports = {
/* The deflate compression method */
Z_DEFLATED: 8
//Z_NULL: null // Use -1 or null inline, depending on var type
};
};

Wyświetl plik

@ -9,9 +9,9 @@
function makeTable() {
var c, table = [];
for(var n =0; n < 256; n++){
for (var n =0; n < 256; n++) {
c = n;
for(var k =0; k < 8; k++){
for (var k =0; k < 8; k++) {
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
}
table[n] = c;
@ -25,12 +25,12 @@ var crcTable = makeTable();
function crc32(crc, buf, len, pos) {
var t = crcTable
, end = pos + len;
var t = crcTable,
end = pos + len;
crc = crc ^ (-1);
for (var i = pos; i < end; i++ ) {
for (var i = pos; i < end; i++) {
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
}
@ -38,4 +38,4 @@ function crc32(crc, buf, len, pos) {
}
module.exports = crc32;
module.exports = crc32;

Wyświetl plik

@ -1534,7 +1534,7 @@ function deflate(strm, flush) {
put_byte(s, val);
} while (val !== 0);
if (s.gzhead.hcrc && s.pending > beg){
if (s.gzhead.hcrc && s.pending > beg) {
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
}
if (val === 0) {
@ -1762,4 +1762,4 @@ exports.deflateParams = deflateParams;
exports.deflatePending = deflatePending;
exports.deflatePrime = deflatePrime;
exports.deflateTune = deflateTune;
*/
*/

Wyświetl plik

@ -17,7 +17,7 @@ function GZheader() {
// but leave for few code modifications
//
// Setup limits is not necessary because in js we should not preallocate memory
// Setup limits is not necessary because in js we should not preallocate memory
// for inflate use constant limit in 65536 bytes
//
@ -37,4 +37,4 @@ function GZheader() {
this.done = false;
}
module.exports = GZheader;
module.exports = GZheader;

Wyświetl plik

@ -1500,4 +1500,4 @@ exports.inflateSetDictionary = inflateSetDictionary;
exports.inflateSync = inflateSync;
exports.inflateSyncPoint = inflateSyncPoint;
exports.inflateUndermine = inflateUndermine;
*/
*/

Wyświetl plik

@ -194,18 +194,20 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
// poor man optimization - use if-else instead of switch,
// to avoid deopts in old v8
if (type === CODES) {
base = extra = work; /* dummy value--not used */
end = 19;
base = extra = work; /* dummy value--not used */
end = 19;
} else if (type === LENS) {
base = lbase;
base_index -= 257;
extra = lext;
extra_index -= 257;
end = 256;
base = lbase;
base_index -= 257;
extra = lext;
extra_index -= 257;
end = 256;
} else { /* DISTS */
base = dbase;
extra = dext;
end = -1;
base = dbase;
extra = dext;
end = -1;
}
/* initialize opts for loop */

Wyświetl plik

@ -10,4 +10,4 @@ module.exports = {
'-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */
'-5': 'buffer error', /* Z_BUF_ERROR (-5) */
'-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
};
};

Wyświetl plik

@ -431,7 +431,7 @@ function tr_static_init() {
}
//Assert (dist == 256, "tr_static_init: dist != 256");
dist >>= 7; /* from now on, all distances are divided by 128 */
for ( ; code < D_CODES; code++) {
for (; code < D_CODES; code++) {
base_dist[code] = dist << 7;
for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
_dist_code[256 + dist++] = code;
@ -1196,4 +1196,4 @@ exports._tr_init = _tr_init;
exports._tr_stored_block = _tr_stored_block;
exports._tr_flush_block = _tr_flush_block;
exports._tr_tally = _tr_tally;
exports._tr_align = _tr_align;
exports._tr_align = _tr_align;

Wyświetl plik

@ -26,4 +26,4 @@ function ZStream() {
this.adler = 0;
}
module.exports = ZStream;
module.exports = ZStream;

Wyświetl plik

@ -19,8 +19,9 @@
"benchmark": "*",
"ansi": "*",
"browserify":"*",
"eslint": "0.17.1",
"eslint-plugin-nodeca": "~1.0.3",
"uglify-js": "*",
"jshint": "*",
"istanbul": "*",
"ndoc": "*",
"lodash": "*",

Wyświetl plik

@ -93,4 +93,4 @@ describe('Deflate states', function() {
ret = zlib_deflate.deflateEnd(strm);
assert(ret === c.Z_STREAM_ERROR);
});
});
});

Wyświetl plik

@ -82,4 +82,4 @@ describe('Gzip special cases', function() {
assert(i === 2, 'invalid blobs count');
});
});
});

Wyświetl plik

@ -168,4 +168,4 @@ function testInflate(samples, inflateOptions, deflateOptions, callback) {
exports.cmpBuf = cmpBuf;
exports.testSamples = testSamples;
exports.testInflate = testInflate;
exports.loadSamples = loadSamples;
exports.loadSamples = loadSamples;

Wyświetl plik

@ -18,7 +18,7 @@ var pako = require('../index');
function h2b(hex) {
return hex.split(' ').map(function(hex) { return parseInt(hex, 16); });
return hex.split(' ').map(function(hx) { return parseInt(hx, 16); });
}
@ -243,4 +243,4 @@ describe('Inflate support', function() {
it('bad window size', function() {
testInflate('', -15, c.Z_OK);
});
});
});

Wyświetl plik

@ -18,13 +18,12 @@ function fixedFromCharCode(code) {
if (code > 0xffff) {
code -= 0x10000;
var surrogate1 = 0xd800 + (code >> 10)
, surrogate2 = 0xdc00 + (code & 0x3ff);
var surrogate1 = 0xd800 + (code >> 10),
surrogate2 = 0xdc00 + (code & 0x3ff);
return String.fromCharCode(surrogate1, surrogate2);
} else {
return String.fromCharCode(code);
}
return String.fromCharCode(code);
}
// Converts array of codes / chars / strings to utf16 string
@ -123,4 +122,4 @@ describe('Deflate/Inflate strings', function () {
assert.equal(data, sampleString);
});
});
});