Skip to content

Commit

Permalink
[packages] convert to ES6, add linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jchansen committed Jul 19, 2017
1 parent 51edaf4 commit a233009
Show file tree
Hide file tree
Showing 215 changed files with 2,073 additions and 1,661 deletions.
41 changes: 37 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
{
"presets": ["es2015", "react"],
"plugins": [
"add-module-exports"
]
"presets": [
"react"
],
"plugins": [],
"env": {
"cjs": {
"presets": [
["es2015", {
"modules": "commonjs"
}],
"react"
],
"plugins": [
"add-module-exports"
]
},
"es": {
"presets": [
["es2015", {
"modules": false
}],
"react"
],
"plugins": [
"lodash"
]
},
"test": {
"presets": [
"es2015",
"react"
],
"plugins": [
"add-module-exports"
]
}
}
}
43 changes: 42 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,47 @@
// do not require function expressions to have a name
"func-names": 0,
// only quote object literal properties when needed
"quote-props": [2, "as-needed"]
"quote-props": [2, "as-needed"],
//
"space-before-function-paren": 0,
// allow function arguments to be unused
"no-unused-vars": [
2,
{
"args": "none"
}
],
// don't require arrow syntax for callbacks
"prefer-arrow-callback": 0,
// allow console.log statements
"no-console": 0,
// allow syntax like x = { y: function() {} }
"object-shorthand": 0,
// allow dynamic requires, currently neccesary for testing
"import/no-dynamic-require": 1,
// allow use of vague PropTypes like object
"react/forbid-prop-types": 0,
// allow jsx in .js files
"react/jsx-filename-extension": 0,
// warn if imports are unresolved
"import/no-unresolved": "warn",
// do not require file extensions
"import/extensions": 0,
// allow missing PropTypes
"react/prop-types": 0,
// do not sort methods
"react/sort-comp": 0,
// allow class methods that don't use "this"
"class-methods-use-this": 0,
// do not require form labels to have an associated control
"jsx-a11y/label-has-for": 0,
// allow interactions on non-interactive elements
"jsx-a11y/no-noninteractive-element-interactions": 0,
// allow underscore dangles like _var
"no-underscore-dangle": 0,
// allow ability to specify boolean props however you want
"react/jsx-boolean-value": 0,
// allow nested ternary expressions
"no-nested-ternary": 0
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ coverage
.tracker
.tmp
lib
es
package-lock.json
npm-debug.log

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,31 @@
"lerna:publish:prerelease": "lerna publish --npm-tag=next",
"check": "npm run lint && npm run test",
"clean": "lerna exec npm run clean",
"clean:examples": "rm -rf examples/**/node_modules",
"clean:serial": "lerna exec --concurrency 1 npm run clean",
"clean:node:packages": "lerna clean --yes",
"clean:node": "npm run clean:node:packages && rm -rf node_modules",
"clean:all": "npm run clean && npm run clean:node",
"lint": "echo 'tbd: implement me.'",
"lint": "lerna exec npm run lint",
"postinstall": "npm run lerna:bootstrap",
"test:serial": "lerna exec --concurrency 1 npm test",
"test": "lerna exec npm test"
},
"dependencies": {},
"devDependencies": {
"babel-cli": "6.5.1",
"babel-core": "6.5.1",
"babel-loader": "6.2.3",
"babel-cli": "^6.0.0",
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "6.5.0",
"babel-preset-react": "6.5.0",
"babel-plugin-lodash": "^3.0.0",
"babel-plugin-transform-imports": "^1.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-react": "^6.0.0",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.2",
"eslint-plugin-import": "^2.6.1",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.1.0",
"lerna": "2.0.0"
},
"peerDependencies": {}
Expand Down
9 changes: 6 additions & 3 deletions packages/lore-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
"url": "https://github.com/lore/lore/issues"
},
"scripts": {
"build": "../../node_modules/.bin/babel src --out-dir lib",
"clean": "rimraf lib",
"build": "npm run build:cjs && npm run build:es",
"build:cjs": "BABEL_ENV=cjs ../../node_modules/.bin/babel src --out-dir lib",
"build:es": "BABEL_ENV=es ../../node_modules/.bin/babel src --out-dir es",
"clean": "rimraf lib && rimraf es",
"debug": "mocha debug --compilers js:babel-core/register --recursive",
"lint": "../../node_modules/.bin/eslint src",
"prepublish": "npm run build",
"test": "mocha --compilers js:babel-core/register --recursive"
"test": "BABEL_ENV=test mocha --compilers js:babel-core/register --recursive"
},
"dependencies": {
"lodash": "^4.0.0"
Expand Down
12 changes: 8 additions & 4 deletions packages/lore-actions/src/blueprints/create.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
const _ = require('lodash');
const { payload, defaultOptions, validatePartialPairs } = require('../utils');
/* eslint consistent-return: "off" */

import _ from 'lodash';
import utils from '../utils';

const { payload, defaultOptions, validatePartialPairs } = utils;

/*
* Blueprint for Create method
*/
module.exports = function(opts = {}) {
export default function(opts = {}) {
// clone the options so we don't unintentionally modify them
let options = _.cloneDeep(opts);

Expand Down Expand Up @@ -56,4 +60,4 @@ module.exports = function(opts = {}) {
}
};
};
};
}
14 changes: 8 additions & 6 deletions packages/lore-actions/src/blueprints/destroy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
const _ = require('lodash');
const { defaultOptions, validatePartialPairs } = require('../utils');
/* eslint consistent-return: "off" */

import _ from 'lodash';
import utils from '../utils';

const { defaultOptions, validatePartialPairs } = utils;

/*
* Blueprint for Destroy method
*/
module.exports = function(opts = {}) {
export default function(opts = {}) {
// clone the options so we don't unintentionally modify them
let options = _.cloneDeep(opts);

Expand Down Expand Up @@ -36,7 +40,6 @@ module.exports = function(opts = {}) {

if (response.status === 404) {
if (options.onNotFound) {

if (options.onNotFound.beforeDispatch) {
options.onNotFound.beforeDispatch(response, [model]);
}
Expand All @@ -50,7 +53,6 @@ module.exports = function(opts = {}) {
});
}
} else if (options.onError) {

if (options.onError.beforeDispatch) {
options.onError.beforeDispatch(response, [model]);
}
Expand All @@ -75,4 +77,4 @@ module.exports = function(opts = {}) {
}
};
};
};
}
39 changes: 29 additions & 10 deletions packages/lore-actions/src/blueprints/find.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const _ = require('lodash');
const { payloadCollection, defaultOptions, validatePartialPairs } = require('../utils');
/* eslint consistent-return: "off" */

import _ from 'lodash';
import utils from '../utils';

const { payloadCollection, defaultOptions, validatePartialPairs } = utils;

/*
* Blueprint for Find method
*/

module.exports = function(opts = {}) {
export default function(opts = {}) {
// clone the options so we don't unintentionally modify them
let options = _.cloneDeep(opts);

Expand All @@ -23,9 +27,9 @@ module.exports = function(opts = {}) {
return function(dispatch) {
const collection = new Collection();

var queryParameters = _.extend({}, query, pagination);
const queryParameters = _.extend({}, query, pagination);

var combinedQuery = {
const combinedQuery = {
where: query,
pagination: pagination
};
Expand All @@ -34,7 +38,7 @@ module.exports = function(opts = {}) {
data: queryParameters
}).then(function() {
if (options.onSuccess) {
var actions = [];
let actions = [];

if (options.normalize && options.normalize.getActions) {
// look through all models in the collection and generate actions for any attributes
Expand All @@ -44,7 +48,12 @@ module.exports = function(opts = {}) {

dispatch({
type: options.onSuccess.actionType,
payload: payloadCollection(collection, options.onSuccess.payloadState, null, combinedQuery),
payload: payloadCollection(
collection,
options.onSuccess.payloadState,
null,
combinedQuery
),
query: combinedQuery
});

Expand All @@ -63,7 +72,12 @@ module.exports = function(opts = {}) {

dispatch({
type: options.onError.actionType,
payload: payloadCollection(collection, options.onError.payloadState, error, combinedQuery),
payload: payloadCollection(
collection,
options.onError.payloadState,
error,
combinedQuery
),
query: combinedQuery
});
}
Expand All @@ -72,10 +86,15 @@ module.exports = function(opts = {}) {
if (options.optimistic) {
return dispatch({
type: options.optimistic.actionType,
payload: payloadCollection(collection, options.optimistic.payloadState, null, combinedQuery),
payload: payloadCollection(
collection,
options.optimistic.payloadState,
null,
combinedQuery
),
query: combinedQuery
});
}
};
};
};
}
16 changes: 9 additions & 7 deletions packages/lore-actions/src/blueprints/get.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
const _ = require('lodash');
const { payload, defaultOptions, validatePartialPairs } = require('../utils');
/* eslint consistent-return: "off" */

import _ from 'lodash';
import utils from '../utils';

const { payload, defaultOptions, validatePartialPairs } = utils;

/*
* Blueprint for Get method
*/
module.exports = function(opts = {}) {
export default function(opts = {}) {
// clone the options so we don't unintentionally modify them
let options = _.cloneDeep(opts);

Expand All @@ -28,7 +32,7 @@ module.exports = function(opts = {}) {
data: query
}).then(function() {
if (options.onSuccess) {
var actions = [];
let actions = [];

if (options.normalize && options.normalize.getActions) {
// look through the model and generate actions for any attributes with
Expand All @@ -51,7 +55,6 @@ module.exports = function(opts = {}) {

if (response.status === 404) {
if (options.onNotFound) {

if (options.onNotFound.beforeDispatch) {
options.onNotFound.beforeDispatch(response, [model]);
}
Expand All @@ -65,7 +68,6 @@ module.exports = function(opts = {}) {
});
}
} else if (options.onError) {

if (options.onError.beforeDispatch) {
options.onError.beforeDispatch(response, [modelId]);
}
Expand All @@ -85,4 +87,4 @@ module.exports = function(opts = {}) {
}
};
};
};
}
14 changes: 8 additions & 6 deletions packages/lore-actions/src/blueprints/update.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
const _ = require('lodash');
const { defaultOptions, validatePartialPairs } = require('../utils');
/* eslint consistent-return: "off" */

import _ from 'lodash';
import utils from '../utils';

const { defaultOptions, validatePartialPairs } = utils;

/*
* Blueprint for Update method
*/
module.exports = function(opts = {}) {
export default function(opts = {}) {
// clone the options so we don't unintentionally modify them
let options = _.cloneDeep(opts);

Expand Down Expand Up @@ -38,7 +42,6 @@ module.exports = function(opts = {}) {

if (response.status === 404) {
if (options.onNotFound) {

if (options.onNotFound.beforeDispatch) {
options.onNotFound.beforeDispatch(response, [model]);
}
Expand All @@ -52,7 +55,6 @@ module.exports = function(opts = {}) {
});
}
} else if (options.onError) {

if (options.onError.beforeDispatch) {
options.onError.beforeDispatch(response, [model, params]);
}
Expand All @@ -79,4 +81,4 @@ module.exports = function(opts = {}) {
}
};
};
};
}
Loading

0 comments on commit a233009

Please sign in to comment.