-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from KleeGroup/eslint-fix
Eslint fix [part-1]
- Loading branch information
Showing
40 changed files
with
609 additions
and
580 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'}}); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
"use strict"; | ||
module.exports = { | ||
builder: require('./builder'), | ||
types: require('./types') | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('####################################################################'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.