Skip to content

Commit

Permalink
chore(lint): use eslint-config-valorsoft
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin committed Mar 9, 2016
1 parent a814223 commit e2a18df
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 275 deletions.
199 changes: 3 additions & 196 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,200 +1,7 @@
{
"parser": "babel-eslint",
"extends": "./node_modules/eslint-config-valorsoft/.eslintrc",
"env": {
"browser": 2,
"node": 2,
"mocha": 2,
"es6": 2
},
"ecmaFeatures": {
"modules": true
},
"globals": {
"_": 2,
"$": 2,
"angular": 2,
"jQuery": 2
},
"rules": {
// Possible Errors
"comma-dangle": 2,
// no-comma-dangle - (deprecated)
"no-cond-assign": [2, "always"],
"no-console": 2,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-dupe-keys": 2,
"no-dupe-args": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
// no-empty-class - (deprecated)
"no-empty": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 2,
"no-extra-semi": 2,
"no-func-assign": 2,
"no-inner-declarations": 2,
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-regex-spaces": 2,
"no-sparse-arrays": 2,
"no-unreachable": 2,
"use-isnan": 2,
"valid-jsdoc": 2,
"valid-typeof": 2,
"no-unexpected-multiline": 2,

// Best Practices
// not sure
"accessor-pairs": [2, {"getWithoutSet": false, "setWithoutGet": true}],
"block-scoped-var": 2,
"complexity": [2, 6],
"consistent-return": 2,
"curly": 2,
"default-case": 2,
"dot-notation": 2,
// not good for chain calls, but not for properties
"dot-location": [2, "property"],
"eqeqeq": 2,
"guard-for-in": 2,
"no-alert": 2,
"no-caller": 2,
"no-div-regex": 2,
"no-else-return": 2,
"no-empty-label": 2,
"no-eq-null": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-implied-eval": 2,
"no-iterator": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-param-reassign": 2,
"no-process-env": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-throw-literal": 2,
"no-unused-expressions": 2,
"no-void": 2,
"no-warning-comments": [1, { "terms": ["todo", "fixme"], "location": "anywhere" }],
"no-with": 2,
"radix": 2,
"vars-on-top": 0,
"wrap-iife": [2, "inside"],
"yoda": [2, "never"],

// Strict Mode
"strict": [0],

// Variables
"no-catch-shadow": 2,
"no-delete-var": 2,
"no-label-var": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-undefined": 2,
"no-unused-vars": 2,
"no-use-before-define": [2, "nofunc"],

// Node.js
"handle-callback-err": [2, "^.*(e|E)rr" ],
"no-mixed-requires": [2, true],
"no-new-require": 2,
"no-path-concat": 2,
"no-process-exit": 2,
"no-sync": 2,

// Stylistic Issues
"array-bracket-spacing": [2, "never"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"camelcase": 2,
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [2, "last"],
"computed-property-spacing": [2, "never"],
"consistent-this": [2, "self"],
// not sure
"eol-last": 0,
"func-names": 0,
"func-style": [2, "declaration"],
"indent": [2, 2],
"key-spacing": [2, { "beforeColon": false, "afterColon": true}],
"max-nested-callbacks": [2, 3],
"new-cap": [2, {"newIsCap": true, "capIsNew": true, "capIsNewExceptions":[
"ObjectId",
"Object",
"Function",
"Number",
"String",
"Boolean",
"Date",
"Array",
"Symbol",
"RegExp"
]}],
"new-parens": 2,
"newline-after-var": 0,
"no-array-constructor": 2,
"no-inline-comments": 2,
"no-lonely-if": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multiple-empty-lines": [2, {"max": 1}],
"no-nested-ternary": 2,
"no-new-object": 2,
"no-spaced-func": 2,
"no-ternary": 0,
"no-trailing-spaces": 2,
"no-underscore-dangle": 2,
"no-unneeded-ternary": 2,
"object-curly-spacing": [2, "never"],
"one-var": [2, {
"var": "never", // Exactly one var declaration per function
"let": "never", // Exactly one let declaration per block
"const": "never" // Exactly one declarator per const declaration per block
}],
"operator-assignment": [1, "always"],
"operator-linebreak": [2, "after"],
"padded-blocks": [2, "never"],
"quote-props": [2, "as-needed"],
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "always"],
"semi-spacing": 2,
// "sort-vars": [1, { "ignoreCase": true }],
"space-after-keywords": [2, "always" ],
"space-before-blocks": [2, "always"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": 0,
"wrap-regexp": 0,

// Legacy
"max-len": [1, 120, 4],
// todo: apply max-params
"max-params": [0, 3],
// todo: apply max-statements
"max-statements": [2, 30],
"no-bitwise": 2
"node": true
}
}
3 changes: 2 additions & 1 deletion clean.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

/*eslint no-console: 0, no-sync: 0*/
'use strict';
const del = require('del');

console.log(del.sync(['components/**/*.+(js|d.ts|js.map)']));
7 changes: 4 additions & 3 deletions gh-pages-publish.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env node

/*eslint no-console: 0, no-sync: 0*/
'use strict';

var ghpages = require('gh-pages');
var path = require('path');
const ghpages = require('gh-pages');
const path = require('path');

ghpages.publish(path.join(__dirname, 'demo-build'), function (err) {
ghpages.publish(path.join(__dirname, 'demo-build'), err => {
if (err) {
console.log('Error while publish gh-pages');
throw err;
Expand Down
26 changes: 10 additions & 16 deletions gulp-tasks/lint.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
var gulp = require('gulp');
var esLint = require('gulp-eslint');
var tslint = require('gulp-tslint');
'use strict';

var paths = gulp.paths;
const gulp = require('gulp');
const tslint = require('gulp-tslint');
const paths = gulp.paths;

gulp.task('eslint', function() {
return gulp.src(paths.jssrc)
.pipe(esLint({useEslintrc: true}))
.pipe(esLint.format())
.pipe(esLint.failOnError());
});

gulp.task('tslint', function() {
return gulp.src(paths.tssrc)
gulp.task('tslint', () =>
gulp
.src(paths.tssrc)
.pipe(tslint())
.pipe(tslint.report('verbose', {
emitError: true,
reportLimit: 0
}));
});
}))
);

gulp.task('lint', ['tslint', 'eslint']);
gulp.task('lint', ['tslint']);
6 changes: 4 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var gulp = require('gulp');
'use strict';

const gulp = require('gulp');

gulp.paths = {
tssrc: [
Expand All @@ -18,6 +20,6 @@ gulp.paths = {

require('require-dir')('./gulp-tasks');

gulp.task('default', function () {
gulp.task('default', () => {
gulp.start('lint');
});
15 changes: 9 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var path = require('path');
var cwd = process.cwd();
'use strict';

module.exports = function (config) {
const path = require('path');
const cwd = process.cwd();

module.exports = config => {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
Expand Down Expand Up @@ -77,7 +79,8 @@ module.exports = function (config) {
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
// possible values: config.LOG_DISABLE || config.LOG_ERROR ||
// config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
Expand All @@ -93,6 +96,6 @@ module.exports = function (config) {
});
};

function root(p) {
return path.join(__dirname, p);
function root(partialPath) {
return path.join(__dirname, partialPath);
}
38 changes: 22 additions & 16 deletions make.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node
/*eslint no-console: 0, no-sync: 0*/
'use strict';

/*eslint no-console: 0, no-sync: 0*/

// System.js bundler
// simple and yet reusable system.js bundler
// bundles, minifies and gzips
Expand All @@ -24,14 +25,14 @@ async.waterfall([
getSystemJsBundleConfig,
buildSystemJs({minify: true, sourceMaps: true, mangle: false}),
gzipSystemJsBundle
], function (err) {
], err => {
if (err) {
throw err;
}
});

function getSystemJsBundleConfig(cb) {
let config = {
const config = {
baseURL: '..',
transpiler: 'typescript',
typescriptOptions: {
Expand All @@ -57,38 +58,43 @@ function getSystemJsBundleConfig(cb) {

function cleanBundlesFolder(cb) {
return del(targetFolder)
.then((paths) => {
.then(paths => {
console.log('Deleted files and folders:\n', paths.join('\n'));
cb();
});
}

function buildSystemJs(options) {
return function (config, cb) {
let fileName = name + (options && options.minify ? '.min' : '') + '.js';
let dest = path.resolve(__dirname, targetFolder, fileName);
console.log('Bundling system.js file:', fileName, options);
return (config, cb) => {
const minPostFix = options && options.minify ? '.min' : '';
const fileName = `${name}${minPostFix}.js`;
const dest = path.resolve(__dirname, targetFolder, fileName);
const builder = new Builder();

let builder = new Builder();
console.log('Bundling system.js file:', fileName, options);
builder.config(config);
return builder
.bundle([name, name].join('/'), dest, options)
.then(()=>cb()).catch(cb);
.then(() => cb())
.catch(cb);
};
}

function gzipSystemJsBundle(cb) {
var files = fs.readdirSync(path.resolve(targetFolder))
const files = fs
.readdirSync(path.resolve(targetFolder))
.map(file => path.resolve(targetFolder, file))
.filter(file => fs.statSync(file).isFile())
.filter(file => path.extname(file) !== 'gz');
return async.eachLimit(files, 1, (file, gzipcb)=> {
process.nextTick(()=> {

return async.eachSeries(files, (file, gzipcb) => {
process.nextTick(() => {
console.log('Gzipping ', file);
const gzip = zlib.createGzip({level: 9});
let inp = fs.createReadStream(file);
let out = fs.createWriteStream(file + '.gz');
inp.on('end', ()=>gzipcb());
const inp = fs.createReadStream(file);
const out = fs.createWriteStream(`${file}.gz`);

inp.on('end', () => gzipcb());
inp.on('error', err => gzipcb(err));
return inp.pipe(gzip).pipe(out);
});
Expand Down
Loading

0 comments on commit e2a18df

Please sign in to comment.