Fix eslint issues
This commit is contained in:
parent
2a38901fae
commit
17f28004df
11 changed files with 973 additions and 955 deletions
1
.babelrc
1
.babelrc
|
@ -13,6 +13,7 @@
|
|||
"components": "./components"
|
||||
}
|
||||
}],
|
||||
"transform-class-properties",
|
||||
"transform-runtime"
|
||||
]
|
||||
}
|
|
@ -37,6 +37,7 @@
|
|||
],
|
||||
"rules": {
|
||||
"no-unneeded-ternary" : "off",
|
||||
"no-console": "off",
|
||||
"object-curly-spacing": ["error", "always", {
|
||||
"objectsInObjects": false,
|
||||
"arraysInObjects": false
|
||||
|
|
1757
dist/WebpackAutoInjectVersion.js
vendored
1757
dist/WebpackAutoInjectVersion.js
vendored
File diff suppressed because it is too large
Load diff
13
package.json
13
package.json
|
@ -10,10 +10,8 @@
|
|||
"author": "Radoslaw Swiat",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"bluebird": "^3.4.6",
|
||||
"chalk": "^1.1.3",
|
||||
"lodash": "^4.17.4",
|
||||
"minimist": "^1.2.0",
|
||||
"optimist": "^0.6.1",
|
||||
"semver": "^5.3.0",
|
||||
"babel-cli": "^6.10.1",
|
||||
|
@ -26,15 +24,14 @@
|
|||
"babel-preset-node5": "^11.0.1",
|
||||
"babel-preset-react": "^6.5.0",
|
||||
"babel-preset-stage-2": "^6.22.0",
|
||||
"gutil": "^1.6.4",
|
||||
"webpack": "^2.3.3",
|
||||
"webpack-node-externals": "^1.5.4",
|
||||
"eslint": "^2.7.0",
|
||||
"eslint-config-airbnb": "^6.2.0",
|
||||
"eslint-loader": "^1.5.0",
|
||||
"eslint-plugin-babel": "^3.2.0",
|
||||
"gutil": "^1.6.4",
|
||||
"webpack": "^2.3.3",
|
||||
"webpack-node-externals": "^1.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
"eslint-plugin-jsx-control-statements": "^2.1.1",
|
||||
"eslint-plugin-react": "^4.2.3"
|
||||
}
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
import semver from 'semver';
|
||||
import config from 'config';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { isArgv } from 'core/utils';
|
||||
import chalk from 'chalk';
|
||||
import log from 'core/log';
|
||||
|
||||
export default class AutoIncreaseVersion {
|
||||
|
@ -14,6 +12,11 @@ export default class AutoIncreaseVersion{
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply will be called from main class
|
||||
* @protected
|
||||
* @returns {Promise}
|
||||
*/
|
||||
apply() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.resolve = resolve;
|
||||
|
@ -30,8 +33,7 @@ export default class AutoIncreaseVersion{
|
|||
this.packageFile = this.openPackageFile();
|
||||
if (isArgv('major')) {
|
||||
this.major();
|
||||
}
|
||||
else if( isArgv('minor') ) {
|
||||
} else if (isArgv('minor')) {
|
||||
this.minor();
|
||||
} else if (isArgv('patch')) {
|
||||
this.patch();
|
||||
|
@ -56,13 +58,17 @@ export default class AutoIncreaseVersion{
|
|||
this.packageFile.version = newVersion;
|
||||
fs.writeFile(
|
||||
path.resolve(this.context.config.PACKAGE_JSON_PATH),
|
||||
JSON.stringify(this.packageFile, null, 4
|
||||
), (err) => {
|
||||
if(err) {this.reject(err); return console.log(err);}
|
||||
JSON.stringify(this.packageFile, null, 4), (err) => {
|
||||
if (err) {
|
||||
this.reject(err);
|
||||
console.log(err);
|
||||
return false;
|
||||
}
|
||||
log.info(`autoIncVersion : new version : ${newVersion}`);
|
||||
log.info('package.json updated!');
|
||||
this.context.version = newVersion;
|
||||
this.resolve();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import chalk from 'chalk';
|
||||
import path from 'path';
|
||||
import config from 'config';
|
||||
import log from 'core/log';
|
||||
|
@ -18,9 +17,14 @@ export default class InjectAsComment{
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply will be called from main class
|
||||
* @protected
|
||||
* @returns {Promise}
|
||||
*/
|
||||
apply() {
|
||||
this.context.compiler.plugin('emit', (compilation, cb) => {
|
||||
for ( var basename in compilation.assets ) {
|
||||
for (let basename in compilation.assets) {
|
||||
let ext = path.extname(basename);
|
||||
let asset = compilation.assets[basename];
|
||||
switch (ext) {
|
||||
|
@ -33,27 +37,31 @@ export default class InjectAsComment{
|
|||
case '.css' :
|
||||
this.injectIntoCss(asset);
|
||||
break;
|
||||
case 'default': break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
log.info(`InjectAsComment : match : ${basename} : injected : ${this.context.version}`);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
return new Promise((resolve, reject) => { resolve(); })
|
||||
return new Promise((resolve) => { resolve(); });
|
||||
}
|
||||
|
||||
injectIntoCss(asset) {
|
||||
let modAsset = `/** [${config.SHORT}] Build version: ${this.context.version} **/ ${endOfLine} ${asset.source()} `;
|
||||
let modAsset = `/** [${config.SHORT}] Build version: ${this.context.version} **/ `;
|
||||
modAsset += `${endOfLine} ${asset.source()} `;
|
||||
asset.source = () => modAsset;
|
||||
}
|
||||
|
||||
injectIntoHtml(asset) {
|
||||
let modAsset = `<!-- [${config.SHORT}] Build version: ${this.context.version} --> ${endOfLine} ${asset.source()} `;
|
||||
let modAsset = `<!-- [${config.SHORT}] Build version: ${this.context.version} --> `;
|
||||
modAsset += `${endOfLine} ${asset.source()} `;
|
||||
asset.source = () => modAsset;
|
||||
}
|
||||
|
||||
injectIntoJs(asset) {
|
||||
let modAsset = `// [${config.SHORT}] Build version: ${this.context.version} ${endOfLine} ${asset.source()} `;
|
||||
let modAsset = `// [${config.SHORT}] Build version: ${this.context.version} `;
|
||||
modAsset = `${endOfLine} ${asset.source()} `;
|
||||
asset.source = () => modAsset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import log from 'core/log';
|
||||
import chalk from 'chalk';
|
||||
|
||||
/**
|
||||
* Inject version number into HTML
|
||||
* - done by parsing html file,
|
||||
|
@ -13,6 +13,11 @@ export default class InjectByTag{
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply will be called from main class
|
||||
* @protected
|
||||
* @returns {Promise}
|
||||
*/
|
||||
apply() {
|
||||
this.context.compiler.plugin('emit', (compilation, cb) => {
|
||||
// for every output file
|
||||
|
@ -38,7 +43,6 @@ export default class InjectByTag{
|
|||
}
|
||||
cb();
|
||||
});
|
||||
|
||||
return new Promise((resolve, reject) => { resolve(); })
|
||||
return new Promise((resolve) => { resolve(); });
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ class Log{
|
|||
* @returns {string}
|
||||
*/
|
||||
getHead() {
|
||||
return endOfLine + chalk.bgYellow.black('[AIV] : ')
|
||||
return endOfLine + chalk.bgYellow.black('[AIV] : ');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,6 @@ class Log{
|
|||
console.log(`${this.getHead()} ${chalk.red('error')} : ${msg}`);
|
||||
}
|
||||
|
||||
|
||||
info(msg) {
|
||||
if (!this.logLevel) return;
|
||||
console.log(`${this.getHead()} ${chalk.blue('info')} : ${msg}`);
|
||||
|
@ -60,7 +59,6 @@ class Log{
|
|||
if (!this.logLevel) return;
|
||||
console.log(`${this.getHead()} ${chalk.yellow('warn')} : ${msg}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new Log();
|
|
@ -18,17 +18,3 @@ export function isArgv(arg) {
|
|||
return Boolean(argv.env[arg]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
|
||||
* @param obj1
|
||||
* @param obj2
|
||||
* @returns obj3 a new object based on obj1 and obj2
|
||||
*/
|
||||
export function merge(obj1,obj2){
|
||||
var obj3 = {};
|
||||
for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
|
||||
for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
|
||||
return obj3;
|
||||
}
|
||||
|
||||
|
||||
|
|
18
src/main.js
18
src/main.js
|
@ -1,4 +1,4 @@
|
|||
import chalk from 'chalk';
|
||||
/* global define */
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import config from 'config';
|
||||
|
@ -12,9 +12,13 @@ import InjectByTag from 'components/inject-by-tag';
|
|||
|
||||
export default class WebpackAutoInject {
|
||||
|
||||
/**
|
||||
* Protected config
|
||||
* @type {{NAME: string, SHORT: string}}
|
||||
*/
|
||||
static protectedConfig = {
|
||||
NAME: 'Auto Inject Version',
|
||||
SHORT: 'AIV',
|
||||
SHORT: 'AIV'
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -32,11 +36,17 @@ export default class WebpackAutoInject{
|
|||
this.executeNoneWebpackComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set config
|
||||
* - merge userConfig with default config
|
||||
* - merge above with a protected config
|
||||
* @param userConfig
|
||||
*/
|
||||
setConfig(userConfig) {
|
||||
this.config = merge(config, userConfig);
|
||||
|
||||
// lets convert all components names to lowercase - to prevent issues
|
||||
this.config.components = transform(this.config.components, function (result, val, key) {
|
||||
this.config.components = transform(this.config.components, (result, val, key) => {
|
||||
result[key.toLowerCase()] = val;
|
||||
});
|
||||
|
||||
|
@ -48,6 +58,7 @@ export default class WebpackAutoInject{
|
|||
* when webpack is initialized and
|
||||
* plugin has been called by webpack
|
||||
* @param compiler
|
||||
* @protected
|
||||
*/
|
||||
async apply(compiler) {
|
||||
this.compiler = compiler;
|
||||
|
@ -78,7 +89,6 @@ export default class WebpackAutoInject{
|
|||
* - used for both, webpack and non webpack comp
|
||||
*/
|
||||
async executeComponent(components) {
|
||||
|
||||
// no more components,
|
||||
// finish
|
||||
if (!components.length) {
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import path from 'path';
|
||||
const webpack = require('webpack');
|
||||
// import nodeExternals from 'webpack-node-externals';
|
||||
|
||||
export default {
|
||||
target: 'node',
|
||||
// externals: [nodeExternals()],
|
||||
entry: ['babel-polyfill', './src/main.js'],
|
||||
resolve: {
|
||||
extensions: ['.js']
|
||||
|
@ -26,7 +23,10 @@ export default {
|
|||
loaders: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
use: [
|
||||
'babel-loader',
|
||||
'eslint-loader'
|
||||
],
|
||||
include: [
|
||||
path.resolve('src')
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue