Skip to content

Commit 9c08083

Browse files
committed
fix lint errors
1 parent 8d78af2 commit 9c08083

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

demo/app.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export default class App extends Component {
5353
});
5454
let content = null;
5555
if (_.isArray(this.state.content)) {
56-
content = this.state.content.map(file =>
57-
<DiffView key={file.filename} source={file.patch} />
56+
content = this.state.content.map(
57+
file => <DiffView key={file.filename} source={file.patch} />,
5858
);
5959
} else {
6060
content = <DiffView source={this.state.content} />;

lib/chunk.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
88

99
exports.default = Chunk;
1010

11+
var _lodash = require('lodash');
12+
1113
var _react = require('react');
1214

1315
var _react2 = _interopRequireDefault(_react);
@@ -23,9 +25,10 @@ var _style2 = _interopRequireDefault(_style);
2325
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2426

2527
function Chunk(props) {
26-
var changes = props.changes.map(function (change, i) {
28+
var renderChange = function renderChange(change, i) {
2729
return _react2.default.createElement(_change2.default, _extends({ key: i }, change, { lang: props.lang }));
28-
});
30+
};
31+
var changes = (0, _lodash.map)(props.changes, renderChange);
2932
return _react2.default.createElement(
3033
'tbody',
3134
null,

lib/diffview.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
88

99
exports.DiffView = DiffView;
1010

11+
var _lodash = require('lodash');
12+
1113
var _react = require('react');
1214

1315
var _react2 = _interopRequireDefault(_react);
@@ -31,18 +33,18 @@ var _style2 = _interopRequireDefault(_style);
3133
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3234

3335
function Part(props) {
34-
var from = props.from;
35-
var to = props.to;
36-
var additions = props.additions;
37-
var deletions = props.deletions;
38-
var chunks = props.chunks;
36+
var from = props.from,
37+
to = props.to,
38+
additions = props.additions,
39+
deletions = props.deletions,
40+
chunks = props.chunks;
3941

4042
var fileName = to === '/dev/null' ? from : to;
4143

4244
var ext = (0, _path.extname)(fileName);
4345
var langs = (0, _langMap.languages)(ext);
4446

45-
var items = chunks.map(function (chunk, i) {
47+
var items = (0, _lodash.map)(chunks, function (chunk, i) {
4648
return _react2.default.createElement(_chunk2.default, _extends({ key: i }, chunk, { lang: langs[0] }));
4749
});
4850

@@ -87,7 +89,7 @@ function DiffView(props) {
8789
return _react2.default.createElement('div', null);
8890
}
8991
var diff = props.diff || (0, _parseDiff2.default)(props.source);
90-
var content = diff.map(function (p, i) {
92+
var content = (0, _lodash.map)(diff, function (p, i) {
9193
return _react2.default.createElement(Part, _extends({ key: i }, p));
9294
});
9395
return _react2.default.createElement(

src/chunk.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { map } from 'lodash';
12
import React from 'react';
23
import Change from './change';
34
import style from './style.scss';
45

56
export default function Chunk(props) {
6-
const changes = props.changes.map((change, i) =>
7-
<Change key={i} {...change} lang={props.lang} />
8-
);
7+
const renderChange = (change, i) => <Change key={i} {...change} lang={props.lang} />;
8+
const changes = map(props.changes, renderChange);
99
return (
1010
<tbody>
1111
<tr className={style.chunk}>

src/diffview.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { map } from 'lodash';
12
import React from 'react';
23
import parse from 'parse-diff';
34
import { extname } from 'path';
@@ -12,9 +13,7 @@ function Part(props) {
1213
const ext = extname(fileName);
1314
const langs = languages(ext);
1415

15-
const items = chunks.map((chunk, i) =>
16-
<Chunk key={i} {...chunk} lang={langs[0]} />
17-
);
16+
const items = map(chunks, (chunk, i) => <Chunk key={i} {...chunk} lang={langs[0]} />);
1817

1918
return (
2019
<article className={style.diff}>
@@ -35,7 +34,7 @@ export function DiffView(props) {
3534
return <div />;
3635
}
3736
const diff = props.diff || parse(props.source);
38-
const content = diff.map((p, i) => <Part key={i} {...p} />);
37+
const content = map(diff, (p, i) => <Part key={i} {...p} />);
3938
return (
4039
<div>
4140
{content}

0 commit comments

Comments
 (0)