Skip to content

Commit dc5963d

Browse files
committed
start babelification
1 parent 99d48ae commit dc5963d

20 files changed

+235
-231
lines changed

.eslintignore

-5
This file was deleted.

.eslintrc

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# vim: ft=yaml
2+
3+
parser: babel-eslint
4+
15
plugins:
26
- react
37

@@ -11,12 +15,15 @@ globals:
1115
jest: false
1216

1317
ecmaFeatures:
18+
modules: true
1419
jsx: true
1520

1621
rules:
17-
semi: true
22+
strict: [ 2, 'global' ]
1823
quotes: [ 2, 'single' ]
1924
curly: [ 2, 'multi-line' ]
25+
eqeqeq: [ 2, 'smart' ]
2026
block-scoped-var: 2
21-
no-underscore-dangle: false
27+
comma-dangle: [ 2, 'always-multiline' ]
28+
no-underscore-dangle: 0
2229
react/jsx-uses-react: 1

dist/react-data-components.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/flux/AppConstants.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
var keyMirror = require('keymirror');
2-
31
module.exports = {
42

5-
ActionTypes: keyMirror({
6-
DATA_SORT: null,
7-
DATA_CHANGE_PAGE_NUMBER: null,
8-
DATA_RECEIVE: null,
9-
DATA_FILTER: null
10-
})
3+
ActionTypes: {
4+
DATA_SORT: 'DATA_SORT',
5+
DATA_CHANGE_PAGE_NUMBER: 'DATA_CHANGE_PAGE_NUMBER',
6+
DATA_RECEIVE: 'DATA_RECEIVE',
7+
DATA_FILTER: 'DATA_FILTER',
8+
},
119

1210
};

example/flux/FluxTable.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function getStateFromStore() {
2626
class FluxTable extends React.Component {
2727

2828
constructor() {
29+
super();
2930
this.state = getStateFromStore();
3031
this.handleStoreChange = this.handleStoreChange.bind(this);
3132
}

example/flux/app.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require('../../css/table-twbs.css');
2-
31
var React = require('react');
42
var FluxTable = require('./FluxTable');
53
var WebAPIUtils = require('./WebAPIUtils');

example/table/main.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require('../../css/table-twbs.css');
2-
31
var React = require('react');
42
var { DataTable } = require('react-data-components');
53
var d3 = require('d3');
@@ -16,7 +14,7 @@ function buildTable(data) {
1614
{ title: 'City', prop: 'CITY' },
1715
{ title: 'Street address', prop: 'STREET ADDRESS' },
1816
{ title: 'Phone', prop: 'PHONE NUMBER', defaultContent: '<no phone>' },
19-
{ title: 'Map', render: renderMapUrl, className: 'text-center' }
17+
{ title: 'Map', render: renderMapUrl, className: 'text-center' },
2018
];
2119

2220
return (

example/webpack.config.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
module.exports = {
2-
devtool: 'eval',
3-
cache: true,
2+
context: __dirname,
3+
devServer: {
4+
contentBase: __dirname,
5+
},
46
entry: {
57
flux: './flux/app',
6-
table: './table/main'
8+
table: './table/main',
79
},
810
output: {
9-
filename: '[name].entry.js'
11+
filename: '[name].entry.js',
1012
},
1113
resolve: {
1214
alias: {
1315
// Use uncompiled version
14-
'react-data-components': '../../src'
15-
}
16+
'react-data-components': '../../src',
17+
},
1618
},
1719
module: {
1820
loaders: [
19-
{ test: /\.js$/, loader: 'jsx?harmony' },
20-
{ test: /\.css$/, loader: 'style!css' }
21-
]
22-
}
21+
{
22+
test: /\.js$/,
23+
exclude: /node_modules/,
24+
loader: 'babel-loader',
25+
},
26+
],
27+
},
2328
};

jest/preprocessor.js

-8
This file was deleted.

package.json

+23-20
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,53 @@
33
"version": "0.4.0",
44
"description": "React data components",
55
"keywords": [
6+
"pagination",
67
"react",
78
"react-component",
8-
"table",
9-
"pagination"
9+
"table"
1010
],
1111
"author": "Carlos Rocha",
1212
"license": "MIT",
1313
"main": "./lib/index",
1414
"files": [
15-
"css",
16-
"lib",
15+
"CHANGELOG.md",
1716
"LICENSE",
18-
"CHANGELOG.md"
17+
"css",
18+
"lib"
1919
],
2020
"repository": {
2121
"type": "git",
2222
"url": "https://github.com/carlosrocha/react-data-components"
2323
},
24+
"babel": {
25+
"stage": 0
26+
},
2427
"peerDependencies": {
2528
"react": "^0.13.0"
2629
},
2730
"devDependencies": {
28-
"css-loader": "^0.7.1",
29-
"d3": "^3.4.11",
31+
"babel": "^5.8.21",
32+
"babel-eslint": "^4.0.8",
33+
"babel-jest": "^5.3.0",
34+
"babel-loader": "^5.3.1",
35+
"d3": "^3.5.6",
36+
"eslint": "^1.1.0",
37+
"eslint-plugin-react": "^3.2.2",
3038
"flux": "^2.0.3",
31-
"jest-cli": "^0.4.0",
32-
"jsx-loader": "^0.13.1",
33-
"keymirror": "^0.1.1",
34-
"object-assign": "^2.0.0",
35-
"react-tools": "^0.13.2",
36-
"style-loader": "^0.7.1",
37-
"webpack": "^1.8.9",
38-
"webpack-dev-server": "^1.8.2"
39+
"jest-cli": "^0.5.0",
40+
"webpack": "^1.11.0",
41+
"webpack-dev-server": "^1.10.1"
3942
},
4043
"scripts": {
41-
"prepublish": "jsx --harmony --no-cache-dir src lib",
42-
"start": "cd example && webpack-dev-server -d --progress --colors --hot --inline",
44+
"lint": "eslint src",
45+
"prepublish": "webpack -p",
46+
"start": "webpack-dev-server -d --config example/webpack.config.js",
4347
"test": "jest"
4448
},
4549
"jest": {
46-
"rootDir": "src",
47-
"scriptPreprocessor": "../jest/preprocessor.js",
50+
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
4851
"unmockedModulePathPatterns": [
49-
"../node_modules/react"
52+
"<rootDir>/node_modules/react"
5053
]
5154
}
5255
}

src/DataMixin.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
var { sort, filter } = require('./utils');
42

53
var containsIgnoreCase = function(a, b) {
@@ -15,7 +13,7 @@ function buildInitialState(props) {
1513
sortBy: props.initialSortBy,
1614
filterValues: {},
1715
currentPage: 0,
18-
pageLength: props.initialPageLength
16+
pageLength: props.initialPageLength,
1917
};
2018
}
2119

@@ -31,9 +29,9 @@ module.exports = {
3129
pageLengthOptions: [ 5, 10, 20 ],
3230
filters: {
3331
globalSearch: {
34-
filter: containsIgnoreCase
35-
}
36-
}
32+
filter: containsIgnoreCase,
33+
},
34+
},
3735
};
3836
},
3937

@@ -52,7 +50,7 @@ module.exports = {
5250
onSort(sortBy) {
5351
this.setState({
5452
sortBy: sortBy,
55-
data: sort(sortBy, this.state.data)
53+
data: sort(sortBy, this.state.data),
5654
});
5755
},
5856

@@ -67,7 +65,7 @@ module.exports = {
6765
this.setState({
6866
data: newData,
6967
filterValues: filterValues,
70-
currentPage: 0
68+
currentPage: 0,
7169
});
7270
},
7371

@@ -79,7 +77,7 @@ module.exports = {
7977
return {
8078
data: data.slice(start, start + pageLength),
8179
currentPage: currentPage,
82-
totalPages: Math.ceil(data.length / pageLength)
80+
totalPages: Math.ceil(data.length / pageLength),
8381
};
8482
},
8583

@@ -94,8 +92,8 @@ module.exports = {
9492

9593
this.setState({
9694
pageLength: newPageLength,
97-
currentPage: newPage
95+
currentPage: newPage,
9896
});
99-
}
97+
},
10098

10199
};

src/DataTable.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
var React = require('react');
42
var Table = require('./Table');
53
var Pagination = require('./Pagination');
@@ -53,7 +51,7 @@ var DataTable = React.createClass({
5351
/>
5452
</div>
5553
);
56-
}
54+
},
5755
});
5856

5957
module.exports = DataTable;

0 commit comments

Comments
 (0)