From faa53533189e44b706300dff1209cfe1ce84b0f3 Mon Sep 17 00:00:00 2001 From: Laurent Bossavit Date: Sun, 2 Jul 2017 19:12:02 +0200 Subject: [PATCH] =?UTF-8?q?:gear:=20R=C3=A9introduit=20les=20alias,=20r?= =?UTF-8?q?=C3=A9organise=20certains=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + source/.babelrc | 3 ++- source/components/Aide.js | 8 +++++--- source/components/AttachDictionary.js | 4 ++-- source/components/HomeSyso.js | 8 ++++---- source/components/Results.js | 7 ++++--- source/components/Simulateur.js | 13 +++++++------ source/components/conversation/Explicable.js | 2 +- source/components/rule/Algorithm.js | 4 ++-- source/components/rule/Examples.js | 4 ++-- source/components/rule/References.js | 4 ++-- source/components/rule/Rule.js | 10 +++++----- source/containers/Layout.js | 14 +++++++------- source/engine/generateQuestions.js | 10 ++++++---- source/reducers.js | 11 ++++------- 15 files changed, 54 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index d14e7b7bc..f7a840f15 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-do-expressions": "^6.22.0", "babel-plugin-transform-object-rest-spread": "^6.23.0", + "babel-plugin-webpack-alias": "^2.1.2", "babel-polyfill": "^6.23.0", "babel-preset-env": "^1.4.0", "babel-preset-react": "^6.24.1", diff --git a/source/.babelrc b/source/.babelrc index 8353486b5..b310a8754 100644 --- a/source/.babelrc +++ b/source/.babelrc @@ -12,6 +12,7 @@ "transform-decorators-legacy", "transform-do-expressions", "transform-object-rest-spread", - "transform-class-properties" + "transform-class-properties", + ["webpack-alias", { "config": "./source/webpack.config.js" }] ] } diff --git a/source/components/Aide.js b/source/components/Aide.js index 4137919a3..77f1bf868 100644 --- a/source/components/Aide.js +++ b/source/components/Aide.js @@ -1,10 +1,12 @@ import React, {Component} from 'react' import {connect} from 'react-redux' -import {rules, findRuleByDottedName} from '../engine/rules' -import './Aide.css' + +import marked from 'Engine/marked' +import {rules, findRuleByDottedName} from 'Engine/rules' import {EXPLAIN_VARIABLE} from '../actions' + import References from './rule/References' -import marked from '../engine/marked' +import './Aide.css' @connect( state => diff --git a/source/components/AttachDictionary.js b/source/components/AttachDictionary.js index bb18d089c..a11222b97 100644 --- a/source/components/AttachDictionary.js +++ b/source/components/AttachDictionary.js @@ -1,7 +1,7 @@ +import R from 'ramda' import React, { Component } from 'react' import ReactDOM from 'react-dom' -import R from 'ramda' -import marked from '../engine/marked' +import marked from 'Engine/marked' // On ajoute à la section la possibilité d'ouvrir un panneau d'explication des termes. // Il suffit à la section d'appeler une fonction fournie en lui donnant du JSX diff --git a/source/components/HomeSyso.js b/source/components/HomeSyso.js index 4cca32748..9b031a146 100644 --- a/source/components/HomeSyso.js +++ b/source/components/HomeSyso.js @@ -1,8 +1,8 @@ -import React, {Component} from 'react' -import './HomeSyso.css' -import {searchRules, encodeRuleName} from '../engine/rules.js' -import {Link} from 'react-router-dom' import R from 'ramda' +import React, {Component} from 'react' +import {Link} from 'react-router-dom' +import {searchRules, encodeRuleName} from 'Engine/rules.js' +import './HomeSyso.css' export default class Home extends Component { state = { diff --git a/source/components/Results.js b/source/components/Results.js index 0d85a9cb0..60e30d982 100644 --- a/source/components/Results.js +++ b/source/components/Results.js @@ -1,13 +1,14 @@ +import R from 'ramda' import React, { Component } from 'react' import classNames from 'classnames' import {Link} from 'react-router-dom' import {connect} from 'react-redux' import { withRouter } from 'react-router' -import R from 'ramda' + import './Results.css' import {capitalise0} from '../utils' -import {computeRuleValue} from '../engine/traverse' -import {encodeRuleName, getObjectives} from '../engine/rules' +import {computeRuleValue} from 'Engine/traverse' +import {encodeRuleName, getObjectives} from 'Engine/rules' let fmt = new Intl.NumberFormat('fr-FR').format let humanFigure = decimalDigits => value => fmt(value.toFixed(decimalDigits)) diff --git a/source/components/Simulateur.js b/source/components/Simulateur.js index 7ac101ef6..030570f23 100644 --- a/source/components/Simulateur.js +++ b/source/components/Simulateur.js @@ -1,18 +1,19 @@ +import R from 'ramda' import React, {Component} from 'react' +import Helmet from 'react-helmet' import {reduxForm, formValueSelector, reset} from 'redux-form' import {connect} from 'react-redux' -import {START_CONVERSATION} from '../actions' -import R from 'ramda' import {Redirect, Link, withRouter} from 'react-router-dom' +import classNames from 'classnames' + +import {START_CONVERSATION} from '../actions' import Aide from './Aide' -import {createMarkdownDiv} from '../engine/marked' -import {rules, findRuleByName, decodeRuleName} from '../engine/rules' +import {createMarkdownDiv} from 'Engine/marked' +import {rules, findRuleByName, decodeRuleName} from 'Engine/rules' import './conversation/conversation.css' import './Simulateur.css' -import classNames from 'classnames' import {capitalise0} from '../utils' import Satisfaction from './Satisfaction' -import Helmet from 'react-helmet' let situationSelector = formValueSelector('conversation') diff --git a/source/components/conversation/Explicable.js b/source/components/conversation/Explicable.js index 07d9180c8..7e595978b 100644 --- a/source/components/conversation/Explicable.js +++ b/source/components/conversation/Explicable.js @@ -4,7 +4,7 @@ import './Explicable.css' import HoverDecorator from '../HoverDecorator' import {connect} from 'react-redux' import {EXPLAIN_VARIABLE} from '../../actions' -import {rules, findRuleByDottedName} from '../../engine/rules' +import {rules, findRuleByDottedName} from 'Engine/rules' @connect(state => ({explained: state.explainedVariable}), dispatch => ({ diff --git a/source/components/rule/Algorithm.js b/source/components/rule/Algorithm.js index ab75b56b2..d14f79f8f 100644 --- a/source/components/rule/Algorithm.js +++ b/source/components/rule/Algorithm.js @@ -2,8 +2,8 @@ import React from 'react' import classNames from 'classnames' import R from 'ramda' import {AttachDictionary} from '../AttachDictionary' -import knownMecanisms from '../../engine/known-mecanisms.yaml' -import marked from '../../engine/marked' +import knownMecanisms from 'Engine/known-mecanisms.yaml' +import marked from 'Engine/marked' @AttachDictionary(knownMecanisms) export default class Algorithm extends React.Component { diff --git a/source/components/rule/Examples.js b/source/components/rule/Examples.js index 9e73e9667..02fe288bc 100644 --- a/source/components/rule/Examples.js +++ b/source/components/rule/Examples.js @@ -5,8 +5,8 @@ import { rules, decodeRuleName, disambiguateRuleReference -} from "../../engine/rules.js" -import { analyseSituation } from "../../engine/traverse" +} from "Engine/rules.js" +import { analyseSituation } from "Engine/traverse" import "./Examples.css" export default class Examples extends Component { diff --git a/source/components/rule/References.js b/source/components/rule/References.js index 797646fa2..c71b68800 100644 --- a/source/components/rule/References.js +++ b/source/components/rule/References.js @@ -1,7 +1,7 @@ import React from 'react' import R from 'ramda' -import references from '../../../règles/ressources/références/références.yaml' import './References.css' +import references from 'Règles/ressources/références/références.yaml' export default ({refs}) => (