Skip to content

Commit

Permalink
Merge pull request #185 from KleeGroup/eslint-fix
Browse files Browse the repository at this point in the history
Eslint fix [part-1]
  • Loading branch information
pierr committed Aug 24, 2015
2 parents fc76840 + 585f89f commit de68de1
Show file tree
Hide file tree
Showing 40 changed files with 609 additions and 580 deletions.
4 changes: 2 additions & 2 deletions src/application/clear.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let React = require('react');
var mountedComponents = require('./mounted-components');
const React = require('react');
let mountedComponents = require('./mounted-components');

/**
* Clear a react component.
Expand Down
75 changes: 46 additions & 29 deletions src/application/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
let React = require('react');
var dispatcher = require('../dispatcher');
var Empty = React.createClass({
render: function() {
return <div></div>;
}
const React = require('react');
const dispatcher = require('../dispatcher');
//Empty compoennt.
const Empty = React.createClass({
/** @inheritdoc */
displayName: 'Empty',
/** @inheritdoc */
render() {
return <div></div>;
}
});

module.exports = {
render: require('./render'),
builtInStore: require('./built-in-store'),
actionBuilder: require('./action-builder'),
clear: require('./clear'),
mountedComponents: require('./mounted-components'),
changeMode(newMode, previousMode){
var mode = {newMode: newMode, previousMode: previousMode};
dispatcher.handleViewAction({data: {mode: mode}, type: 'update'});
},
changeRoute(newRoute){
dispatcher.handleViewAction({data: {route: newRoute}, type: 'update'});
},
clearCartridge(){
dispatcher.handleViewAction({
data: {
cartridgeComponent: {component: Empty},
barContentLeftComponent: {component: Empty},
summaryComponent: {component: Empty},
actions: {primary: [], secondary: []}
},
type: 'update'
});
}
render: require('./render'),
builtInStore: require('./built-in-store'),
actionBuilder: require('./action-builder'),
clear: require('./clear'),
mountedComponents: require('./mounted-components'),
/**
* Change application mode.
* @param {string} newMode - New application mode.
* @param {string} previousMode - Previous mode.
*/
changeMode(newMode, previousMode){
const mode = {newMode: newMode, previousMode: previousMode};
dispatcher.handleViewAction({data: {mode: mode}, type: 'update'});
},
/**
* Change application route (maybe not the wole route but a route's group.)
* @param {string} newRoute - new route name.
*/
changeRoute(newRoute){
dispatcher.handleViewAction({data: {route: newRoute}, type: 'update'});
},
/**
* Clear the application's header.
* @return {[type]} [description]
*/
clearHeader(){
dispatcher.handleViewAction({
data: {
cartridgeComponent: {component: Empty},
barContentLeftComponent: {component: Empty},
summaryComponent: {component: Empty},
actions: {primary: [], secondary: []}
},
type: 'update'
});
}
};
65 changes: 31 additions & 34 deletions src/application/render.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
'use strict';
/*global document*/
var React = require('react');
var keys = require('lodash/object/keys');
/**
* Map containing all the mounted components.
* @type {Object}
*/
var mountedComponents = require('./mounted-components');

var clearComponent = require('./clear');
//dependencies
const React = require('react');
const keys = require('lodash/object/keys');
const mountedComponents = require('./mounted-components');
const clearComponent = require('./clear');

/**
* Render a react component in a DOM selector.
* @param {object} component - A react component.
* @param {string} selector - A selector on a DOM node.
* @param {object} options - Options for the component rendering.
*/
* Render a react component in a DOM selector.
* @param {object} component - A react component.
* @param {string} selector - A selector on a DOM node.
* @param {object} options - Options for the component rendering.
*/
module.exports = function renderComponent(component, selector, options){
options = options || {};
// Clear a potential previously mounted component
clearComponent(selector);
let targetDOMContainer = document.querySelector(selector);
if(!targetDOMContainer){throw new Error(`You are trying to render a component in a DOM element which is not existing, your selector is ${selector}`); }
// Render the component
var mountedComponent = React.render(
React.createElement(component, options.props, options.data),
targetDOMContainer
);
//Save the fact that a component is mounted.
mountedComponents[selector] = mountedComponent;
console.info('Mounted components : ', keys(mountedComponents));
return mountedComponent;
options = options || {};
// Clear a potential previously mounted component
clearComponent(selector);
const targetDOMContainer = document.querySelector(selector);
if(!targetDOMContainer){
throw new Error(`You are trying to render a component in a DOM element which is not existing, your selector is ${selector}`);
}
// Render the component
const mountedComponent = React.render(
React.createElement(component, options.props, options.data),
targetDOMContainer
);
//Save the fact that a component is mounted.
mountedComponents[selector] = mountedComponent;
console.info('Mounted components : ', keys(mountedComponents));
return mountedComponent;
};
/*
Exemple
var render = Focus.application.render;
var MyComponent = require('./my-component');
render(MyComponent, 'div.component-container', {props: {id: '12'}});
*/
Exemple
var render = Focus.application.render;
var MyComponent = require('./my-component');
render(MyComponent, 'div.component-container', {props: {id: '12'}});
*/
46 changes: 18 additions & 28 deletions src/component/builder.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
"use strict";
var React = require('react');
var assign = require('object-assign');
const React = require('react');
const assign = require('object-assign');
//var isObject = require('lodash/lang/isObject');
//var isFunction = require('lodash/lang/isFunction');

/**
* Create a component with a mixin except id the component is mixin only.
* @param {object} mixin - The component mixin.
* @param {Boolean} isMixinOnly - define if the component is a mixin only.
* @return {object} - {component} the built react component.
*/
* Create a component with a mixin except id the component is mixin only.
* @param {object} mixin - The component mixin.
* @param {Boolean} isMixinOnly - define if the component is a mixin only.
* @return {object} - {component} the built react component.
*/
function createComponent(mixin, isMixinOnly){
if (isMixinOnly){
return undefined;//Error('Your class publish a mixin only...');
return null;
}
return {component: React.createClass(mixin)};
}

/**
* Build a module with a mixin and a React component.
* @param {object} componentMixin - Mixin of the component.
* @param {boolean} isMixinOnly - Bolean to set .
* @return {object} {mixin: 'the component mixin', component: 'the react instanciated component'}
*/
module.exports = function(componentMixin, isMixinOnly){

return assign( {
mixin: componentMixin
/*extend: function extendMixin(properties){
if(isFunction(componentMixin)){
throw new Error('You cannot extend a mixin function');
}
if(!isObject(properties)){
throw new Error('properties should be an object');
}
return assign({}, componentMixin, properties);
},*/
}, createComponent(componentMixin, isMixinOnly));
* Build a module with a mixin and a React component.
* @param {object} componentMixin - Mixin of the component.
* @param {boolean} isMixinOnly - Bolean to set .
* @return {object} {mixin: 'the component mixin', component: 'the react instanciated component'}
*/
module.exports = function builder(componentMixin, isMixinOnly){
return assign(
{mixin: componentMixin},
createComponent(componentMixin, isMixinOnly)
);
};
1 change: 0 additions & 1 deletion src/component/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"use strict";
module.exports = {
builder: require('./builder'),
types: require('./types')
Expand Down
6 changes: 0 additions & 6 deletions src/component/override.js

This file was deleted.

63 changes: 31 additions & 32 deletions src/component/types.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
"use strict";
//Dependencies.
var React = require('react');
var isString = require('lodash/lang/isString');
var isArray = require('lodash/lang/isArray');
const React = require('react');
const isString = require('lodash/lang/isString');
const isArray = require('lodash/lang/isArray');

/**
* Expose a React type validation for the component properties validation.
* @see http://facebook.github.io/react/docs/reusable-components.html
* @param {string} type - String or array of the types to use.
* @param {boolean} isRequired - Defines if the props is mandatory.
* @returns {object} The corresponding react type.
*/
module.exports = function(type, isRequired){
var isStringType = isString(type);
if(!isStringType && !isArray(type)){
throw new Error('The type should be a string or an array');
}
//Container for the propTypes.
var propTypeToReturn;
//Array case.
if(isStringType){
propTypeToReturn = React.PropTypes[type];
}else {
propTypeToReturn = React.PropTypes.oneOfType(
type.map(
(type)=>{
return React.PropTypes[type];
}));
}
//Mandatory case
if(isRequired){
propTypeToReturn = propTypeToReturn.isRequired;
}
return propTypeToReturn;
* Expose a React type validation for the component properties validation.
* @see http://facebook.github.io/react/docs/reusable-components.html
* @param {string} type - String or array of the types to use.
* @param {boolean} isRequired - Defines if the props is mandatory.
* @return {object} The corresponding react type.
*/
module.exports = function types(type, isRequired){
const isStringType = isString(type);
if(!isStringType && !isArray(type)){
throw new Error('The type should be a string or an array');
}
//Container for the propTypes.
let propTypeToReturn;
//Array case.
if(isStringType){
propTypeToReturn = React.PropTypes[type];
}else {
propTypeToReturn = React.PropTypes.oneOfType(
type.map(
(t)=>{
return React.PropTypes[t];
}));
}
//Mandatory case
if(isRequired){
propTypeToReturn = propTypeToReturn.isRequired;
}
return propTypeToReturn;
};
45 changes: 22 additions & 23 deletions src/definition/check-domains.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
let keys = require('lodash/object/keys');
const keys = require('lodash/object/keys');
let {intersection, uniq, difference} = require('lodash/array');

module.exports = (entityDef, domains)=>{
domains = Object.keys(domains);
let arr = [];
for (let node in entityDef) {
for (let sub in entityDef[node]) {
arr.push(entityDef[node][sub].domain);
module.exports = function checkDomain(entityDef, domains){
domains = keys(domains);
let arr = [];
for (let node in entityDef) {
for (let sub in entityDef[node]) {
arr.push(entityDef[node][sub].domain);
}
}
}
let appDomains = uniq(arr);
console.info('########################## DOMAINS ##############################');
console.info('Entity definitions domains: ', appDomains);
console.info('Domains with a definition',domains);
let missingDomains = difference(appDomains, intersection(appDomains,domains));
if(missingDomains.length > 0){
console.warn('Missing domain\'s definition', missingDomains);
}
let useLessDomains =difference(domains, _.intersection(appDomains,domains));
if(useLessDomains > 0){
console.warn('Useless domain\'s definition',useLessDomains);
}

console.info('####################################################################');
}
const appDomains = uniq(arr);
console.info('########################## DOMAINS ##############################');
console.info('Entity definitions domains: ', appDomains);
console.info('Domains with a definition', domains);
const missingDomains = difference(appDomains, intersection(appDomains, domains));
if(0 < missingDomains.length){
console.warn('Missing domain\'s definition', missingDomains);
}
const useLessDomains = difference(domains, intersection(appDomains, domains));
if(0 < useLessDomains){
console.warn('Useless domain definition', useLessDomains);
}
console.info('####################################################################');
};
2 changes: 1 addition & 1 deletion src/definition/domain/__tests__/container-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __tests__/container-test.js
jest.dontMock('../container');
require('../../../test/dontMock');
var ArgumentInvalidException = require('../../../exception/ArgumentInvalidException');
var ArgumentInvalidException = require('../../../exception/argument-invalid-exception');


describe('### container', function() {
Expand Down
Loading

0 comments on commit de68de1

Please sign in to comment.