Skip to content

Commit

Permalink
Use ESLint and JSCS instead of JSHint. Fix tests failed on Node.js 4
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed Sep 23, 2015
1 parent 14d2b9b commit f01a9aa
Show file tree
Hide file tree
Showing 276 changed files with 3,623 additions and 3,563 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
coverage/
tmp/
45 changes: 45 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"extends": "eslint:recommended",
"root": true,
"rules": {
"curly": [2, "multi-line"],
"no-console": 0,
"no-path-concat": 2,
"handle-callback-err": 2,
"no-use-before-define": [2, "nofunc"],
"no-shadow-restricted-names": 2,
"block-scoped-var": 2,
"dot-notation": 2,
"eqeqeq": [2, "allow-null"],
"no-else-return": 1,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-implied-eval": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new-wrappers": 2,
"no-redeclare": 2,
"no-return-assign": 2,
"no-throw-literal": 2,
"no-unused-expressions": [2, {
"allowShortCircuit": true,
"allowTernary": true
}],
"no-useless-call": 2,
"no-useless-concat": 2,
"no-with": 2,
"radix": 2,
"no-self-compare": 2,
"no-unused-vars": [2, {
"vars": "all",
"args": "none"
}],
"strict": [2, "global"]
},
"env": {
"node": true
}
}
85 changes: 85 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"excludeFiles": ["node_modules/**", "coverage/**", "tmp/**"],
"validateIndentation": 2,
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"requireSemicolons": true,
"disallowEmptyBlocks": true,
"disallowKeywordsOnNewLine": ["else"],
"disallowKeywords": ["with"],
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineBreaks": true,
"disallowMultipleLineStrings": true,
"disallowMultipleVarDecl": "exceptUndefined",
"disallowNewlineBeforeBlockStatements": true,
"disallowOperatorBeforeLineBreak": ["."],
"disallowSpaceBeforeBinaryOperators": [","],
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforeComma": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpaceBeforeSemicolon": true,
"disallowSpacesInCallExpression": true,
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideParentheses": true,
"disallowSpacesInsideParenthesizedExpression": {
"allExcept": [ "{", "}" ]
},
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"disallowYodaConditions": true,
"requireBlocksOnNewline": true,
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
"requireCurlyBraces": [
"for",
"while",
"do",
"try",
"catch"
],
"requireDotNotation": true,
"requireLineBreakAfterVariableAssignment": true,
"requireLineFeedAtFileEnd": true,
"requirePaddingNewLinesAfterBlocks": true,
"requirePaddingNewLinesAfterUseStrict": true,
"requireParenthesesAroundIIFE": true,
"requireSpaceAfterBinaryOperators": true,
"requireSpaceAfterKeywords": [
"do",
"for",
"if",
"else",
"switch",
"case",
"try",
"catch",
"void",
"while",
"with",
"return",
"typeof"
],
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpaceBetweenArguments": true,
"requireSpacesInFunction": {
"beforeOpeningCurlyBrace": true
},
"requireSpacesInConditionalExpression": true,
"requireSpacesInForStatement": true,
"requireSpacesInFunctionDeclaration": {
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"validateNewlineAfterArrayElements": true,
"validateParameterSeparator": ", ",
"disallowMultipleSpaces": true
}
14 changes: 0 additions & 14 deletions .jshintrc

This file was deleted.

1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ test/
tmp/
coverage/
*.log
.jshintrc
.travis.yml
gulpfile.js
.idea/
Expand Down
13 changes: 11 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
language: node_js

sudo: false

cache:
apt: true
directories:
- node_modules

node_js:
- "0.10"
- "0.12"
- iojs
- "4"

script:
- npm test
- npm run eslint
- npm run jscs
- npm run test-cov

after_script:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
17 changes: 5 additions & 12 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,13 @@ init:
# Test against these versions of Node.js.
environment:
matrix:
# node.js
- nodejs_version: "0.10"
- nodejs_version: "0.12"
# io.js
- nodejs_version: "1"

# Allow failing jobs for bleeding-edge Node.js versions.
matrix:
allow_failures:
- nodejs_version: "1"
- nodejs_version: "4"

# Install scripts. (runs after repo cloning)
install:
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
- cmd: npm install -g npm@2
- set PATH=%APPDATA%\npm;%PATH%
- ps: Install-Product node $env:nodejs_version
- npm install

# Post-install test scripts.
Expand All @@ -29,7 +20,9 @@ test_script:
- node --version
- npm --version
# Run tests
- npm test
- npm run eslint
- npm run jscs
- npm run test-cov

# Don't actually build.
build: off
Expand Down
48 changes: 0 additions & 48 deletions gulpfile.js

This file was deleted.

28 changes: 14 additions & 14 deletions lib/box/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var Promise = require('bluebird');
var escapeBOM = fs.escapeBOM;
var escapeEOL = fs.escapeEOL;

function File(data){
function File(data) {
this.source = data.source;
this.path = data.path;
this.type = data.type;
Expand All @@ -15,7 +15,7 @@ function File(data){
this.stats = data.stats;
}

function wrapReadOptions(options){
function wrapReadOptions(options) {
options = options || {};
if (typeof options === 'string') options = {encoding: options};
if (!options.hasOwnProperty('encoding')) options.encoding = 'utf8';
Expand All @@ -25,12 +25,12 @@ function wrapReadOptions(options){
return options;
}

function escapeContent(str){
function escapeContent(str) {
return escapeBOM(escapeEOL(str));
}

File.prototype.read = function(options, callback){
if (!callback && typeof options === 'function'){
File.prototype.read = function(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
Expand All @@ -40,8 +40,8 @@ File.prototype.read = function(options, callback){

options = wrapReadOptions(options);

return new Promise(function(resolve, reject){
if (!options.cache || !content){
return new Promise(function(resolve, reject) {
if (!options.cache || !content) {
return fs.readFile(self.source, options).then(resolve, reject);
}

Expand All @@ -55,12 +55,12 @@ File.prototype.read = function(options, callback){
}).nodeify(callback);
};

File.prototype.readSync = function(options){
File.prototype.readSync = function(options) {
var content = this.content;

options = wrapReadOptions(options);

if (!options.cache || !content){
if (!options.cache || !content) {
return fs.readFileSync(this.source, options);
}

Expand All @@ -73,8 +73,8 @@ File.prototype.readSync = function(options){
return result;
};

File.prototype.stat = function(options, callback){
if (!callback && typeof options === 'function'){
File.prototype.stat = function(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
Expand All @@ -85,14 +85,14 @@ File.prototype.stat = function(options, callback){
var cache = options.hasOwnProperty('cache') ? options.cache : true;
var self = this;

return new Promise(function(resolve, reject){
return new Promise(function(resolve, reject) {
if (stats && cache) return resolve(stats);

fs.stat(self.source).then(resolve, reject);
}).nodeify(callback);
};

File.prototype.statSync = function(options){
File.prototype.statSync = function(options) {
options = options || {};

var cache = options.hasOwnProperty('cache') ? options.cache : true;
Expand All @@ -103,4 +103,4 @@ File.prototype.statSync = function(options){
return fs.statSync(this.source);
};

module.exports = File;
module.exports = File;
Loading

0 comments on commit f01a9aa

Please sign in to comment.