Skip to content

Commit

Permalink
Replace JSHint with ESLint and JSCS
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed Nov 1, 2015
1 parent 62373ef commit 85240da
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 101 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
@@ -0,0 +1,3 @@
node_modules/
coverage/
tmp/
45 changes: 45 additions & 0 deletions .eslintrc
@@ -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
@@ -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
Expand Up @@ -2,7 +2,6 @@ test/
tmp/
coverage/
*.log
.jshintrc
.travis.yml
gulpfile.js
.idea/
Expand Down
14 changes: 12 additions & 2 deletions .travis.yml
@@ -1,12 +1,22 @@
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:
- npm install coveralls
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
39 changes: 0 additions & 39 deletions gulpfile.js

This file was deleted.

6 changes: 4 additions & 2 deletions index.js
@@ -1,10 +1,12 @@
/* global hexo */

'use strict';

var assign = require('object-assign');

hexo.config.index_generator = assign({
per_page: typeof hexo.config.per_page === "undefined" ? 10 : hexo.config.per_page,
per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page,
order_by: '-date'
}, hexo.config.index_generator);

hexo.extend.generator.register('index', require('./lib/generator'));
hexo.extend.generator.register('index', require('./lib/generator'));
4 changes: 2 additions & 2 deletions lib/generator.js
Expand Up @@ -2,7 +2,7 @@

var pagination = require('hexo-pagination');

module.exports = function(locals){
module.exports = function(locals) {
var config = this.config;
var posts = locals.posts.sort(config.index_generator.order_by);
var paginationDir = config.pagination_dir || 'page';
Expand All @@ -15,4 +15,4 @@ module.exports = function(locals){
__index: true
}
});
};
};
24 changes: 11 additions & 13 deletions package.json
Expand Up @@ -4,7 +4,10 @@
"description": "Index generator for Hexo.",
"main": "index",
"scripts": {
"test": "gulp test"
"eslint": "eslint .",
"jscs": "jscs .",
"test": "mocha test/index.js",
"test-cov": "istanbul cover --print both _mocha -- test/index.js"
},
"directories": {
"lib": "./lib"
Expand All @@ -23,20 +26,15 @@
"author": "Tommy Chen <tommy351@gmail.com> (http://zespia.tw)",
"license": "MIT",
"devDependencies": {
"chai": "^1.9.1",
"coveralls": "^2.11.2",
"gulp": "^3.8.9",
"gulp-istanbul": "^0.5.0",
"gulp-jshint": "^1.8.6",
"gulp-load-plugins": "^0.8.0",
"gulp-mocha": "^2.0.0",
"chai": "^3.4.0",
"eslint": "^1.8.0",
"hexo": "^3.0.0",
"jshint-stylish": "^1.0.0",
"mocha": "^2.0.1",
"rimraf": "^2.2.8"
"istanbul": "^0.4.0",
"jscs": "^2.5.0",
"mocha": "^2.0.1"
},
"dependencies": {
"hexo-pagination": "0.0.2",
"object-assign": "^2.0.0"
"object-assign": "^4.0.1"
}
}
}
9 changes: 9 additions & 0 deletions test/.eslintrc
@@ -0,0 +1,9 @@
{
"extend": "../.eslintrc",
"rules": {
"no-unused-expressions": 0
},
"env": {
"mocha": true
}
}
15 changes: 0 additions & 15 deletions test/.jshintrc

This file was deleted.

0 comments on commit 85240da

Please sign in to comment.