From f0576f9bc22ec383555d9a2de6abbc1260ae5369 Mon Sep 17 00:00:00 2001 From: Ivan Voischev Date: Tue, 22 Sep 2015 21:17:46 +0300 Subject: [PATCH] feat(lint): own jscs config --- .jscsrc | 22 ++++++++++++++++++++-- gulpfile.babel.js | 1 - lib/api.js | 9 ++++----- lib/parser.js | 16 ++++++++-------- lib/posthtml.js | 2 +- package.json | 1 - test/options.js | 2 +- test/plugins.js | 6 +++--- 8 files changed, 37 insertions(+), 22 deletions(-) diff --git a/.jscsrc b/.jscsrc index e7094a1..53dce5c 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,5 +1,4 @@ { - "plugins": ["jscs-protein"], "excludeFiles": [ ".git/**", "node_modules/**", @@ -10,5 +9,24 @@ "esnext": true, "requireArrowFunctions": true, "requireShorthandArrowFunctions": true, - "requireTemplateStrings": true + "requireTemplateStrings": true, + "disallowSpacesInCallExpression": true, + "disallowSpaceAfterObjectKeys": true, + "disallowNewlineBeforeBlockStatements": true, + "disallowMultipleLineBreaks": true, + "requireSemicolons": true, + "requireFunctionDeclarations": true, + "requireCommaBeforeLineBreak": true, + "disallowTrailingComma": true, + "disallowTrailingWhitespace": true, + "disallowSpacesInFunction": { + "beforeOpeningRoundBrace": true + }, + "requireSpacesInFunction": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInConditionalExpression": { + "afterTest": true, + "afterConsequent": true + } } diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 260b465..2763f03 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -34,7 +34,6 @@ gulp.task('build:package', () => { gulp.task('build', ['build:lib', 'build:docs', 'build:package']); - // Changelog gulp.task('changelog', done => { diff --git a/lib/api.js b/lib/api.js index 3014c4b..d144514 100644 --- a/lib/api.js +++ b/lib/api.js @@ -17,7 +17,7 @@ export default { * return tree; * } */ - walk: function (cb) { + walk: function walk(cb) { return traverse(this, node => cb(node)); }, /** @@ -36,7 +36,7 @@ export default { * return tree; * } */ - match: function (precondition, cb) { + match: function match(precondition, cb) { return this.walk(node => { if(compare(precondition, node)) { return cb(node); @@ -59,7 +59,7 @@ export default { * return tree; * } */ - eachClass: function(className, cb) { + eachClass: function eachClass(className, cb) { return this.walk(node => { let classes = node.attrs && node.attrs.class.split(' ') || []; if(classes.includes(className)) { @@ -70,8 +70,7 @@ export default { } }; - -function traverse (tree, cb) { +function traverse(tree, cb) { if (Array.isArray(tree)) { for (let i = 0, l = tree.length; i < l; i++) { let item = tree[i]; diff --git a/lib/parser.js b/lib/parser.js index 3b69da0..6b5d0cb 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -8,7 +8,7 @@ export default { * @param {String} html * @return {Object} */ - toTree: function (html) { + toTree: function toTree(html) { let bufArray = [], results = []; @@ -81,7 +81,7 @@ export default { * @param {Object} options Parse options * @return {String} html string */ - toHtml: function (tree, options = {}) { + toHtml: function toHtml(tree, options = {}) { /** * options parse @@ -112,7 +112,7 @@ export default { return html(tree); - function html (tree) { + function html(tree) { if(typeof(tree) === 'string') { return tree; @@ -141,12 +141,12 @@ export default { } } else { buf += `<${ tag }${ - node.attrs ? - attrs(node.attrs) : + node.attrs? + attrs(node.attrs): '' }>${ - node.content ? - html(node.content) : + node.content? + html(node.content): '' }`; } @@ -154,7 +154,7 @@ export default { return buf; - function attrs (obj) { + function attrs(obj) { let attr = ''; for (let key in obj) { attr += ` ${key}="${obj[key]}"`; diff --git a/lib/posthtml.js b/lib/posthtml.js index dd7eb33..c103103 100644 --- a/lib/posthtml.js +++ b/lib/posthtml.js @@ -33,7 +33,7 @@ class Posthtml { process(tree, options = {}) { return new Promise(resolve => { - tree = options.skipParse ? tree : this.parse(tree); + tree = options.skipParse? tree: this.parse(tree); tree.options = options; for(let key in api) { diff --git a/package.json b/package.json index 1768fd2..2e2a655 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "gulp-json-editor": "^2.2.1", "isparta": "^3.0.3", "jscs": "^2.0.0", - "jscs-protein": "git://github.com/theprotein/jscs-protein.git#1d22e08ca767958a95b79f3bad6449fb2fa9f496", "jshint": "^2.8.0", "mocha": "^2.2.5", "mversion": "^1.10.0" diff --git a/test/options.js b/test/options.js index 91a6349..e315a46 100644 --- a/test/options.js +++ b/test/options.js @@ -3,7 +3,7 @@ import posthtml from '../index.js'; import { expect } from 'chai'; const beforeHTML = '
Text
'; -const options = { singleTags : ['rect'], closingSingleTag: 'slash' }; +const options = { singleTags: ['rect'], closingSingleTag: 'slash' }; function test(html, done) { posthtml().process(html, options).then(result => { diff --git a/test/plugins.js b/test/plugins.js index fab6f1d..f23f855 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -50,7 +50,7 @@ describe('Plugins', () => { }); it('set options skipParse', done => { - testPluginsArray(tree, { skipParse : true }, done); + testPluginsArray(tree, { skipParse: true }, done); }); }); @@ -62,7 +62,7 @@ describe('Plugins', () => { }); it('set options skipParse', done => { - testPluginUse(tree, { skipParse : true }, done); + testPluginUse(tree, { skipParse: true }, done); }); }); @@ -71,7 +71,7 @@ describe('Plugins', () => { let html = '

'; let ref = '

'; - function plugin (tree) { + function plugin(tree) { tree.options.singleTags = ['rect']; tree.options.closingSingleTag = 'slash'; return tree;