Skip to content

Commit e0bab33

Browse files
Add prettier / Update eslint / Fix lint errors
1 parent 234cd55 commit e0bab33

13 files changed

+258
-114
lines changed

.editorconfig

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
# EditorConfig helps developers define and maintain consistent
2-
# coding styles between different editors and IDEs
3-
# editorconfig.org
4-
51
root = true
62

7-
83
[*]
9-
10-
# Change these settings to your own preference
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
117
indent_style = space
128
indent_size = 2
13-
14-
# We recommend you to keep these unchanged
15-
end_of_line = lf
16-
charset = utf-8
179
trim_trailing_whitespace = true
18-
insert_final_newline = true
1910

2011
[*.md]
21-
trim_trailing_whitespace = false
12+
trim_trailing_whitespace = false

.eslintrc.js

-26
This file was deleted.

.eslintrc.json

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": [
4+
"airbnb",
5+
"prettier"
6+
],
7+
"env": {
8+
"browser": true,
9+
"node": true,
10+
"jest": true,
11+
"es6": true
12+
},
13+
"plugins": [
14+
"react",
15+
"jsx-a11y",
16+
"prettier"
17+
],
18+
"parserOptions": {
19+
"ecmaVersion": 6,
20+
"sourceType": "module",
21+
"ecmaFeatures": {
22+
"jsx": true
23+
}
24+
},
25+
"rules": {
26+
"arrow-parens": [
27+
"error",
28+
"as-needed"
29+
],
30+
"arrow-body-style": [
31+
2,
32+
"as-needed"
33+
],
34+
"class-methods-use-this": 0,
35+
"comma-dangle": [
36+
2,
37+
"always-multiline"
38+
],
39+
"import/imports-first": 0,
40+
"import/newline-after-import": 0,
41+
"import/no-dynamic-require": 0,
42+
"import/no-extraneous-dependencies": 0,
43+
"import/no-named-as-default": 0,
44+
"import/no-unresolved": 2,
45+
"import/no-webpack-loader-syntax": 0,
46+
"import/prefer-default-export": 0,
47+
"indent": [
48+
2,
49+
2,
50+
{
51+
"SwitchCase": 1
52+
}
53+
],
54+
"jsx-a11y/anchor-is-valid": [
55+
"error",
56+
{
57+
"components": [
58+
"Link"
59+
],
60+
"specialLink": [
61+
"to",
62+
"hrefLeft",
63+
"hrefRight"
64+
],
65+
"aspects": [
66+
"noHref",
67+
"invalidHref",
68+
"preferButton"
69+
]
70+
}
71+
],
72+
"jsx-a11y/aria-props": 2,
73+
"jsx-a11y/heading-has-content": 0,
74+
"jsx-a11y/click-events-have-key-events": 0,
75+
"jsx-a11y/no-static-element-interactions": 0,
76+
"jsx-a11y/label-has-for": 2,
77+
"jsx-a11y/mouse-events-have-key-events": 2,
78+
"jsx-a11y/role-has-required-aria-props": 2,
79+
"jsx-a11y/role-supports-aria-props": 2,
80+
"max-len": 0,
81+
"newline-per-chained-call": 0,
82+
"no-confusing-arrow": 0,
83+
"no-console": 1,
84+
"no-use-before-define": 0,
85+
"prefer-template": 2,
86+
"prettier/prettier": "error",
87+
"react/forbid-prop-types": 0,
88+
"react/jsx-first-prop-new-line": [
89+
2,
90+
"multiline"
91+
],
92+
"react/jsx-filename-extension": 0,
93+
"react/jsx-no-target-blank": 0,
94+
"react/require-default-props": 0,
95+
"react/require-extension": 0,
96+
"react/self-closing-comp": 0,
97+
"require-yield": 0,
98+
"linebreak-style": 0
99+
},
100+
"settings": {
101+
"import/resolver": {
102+
"webpack": {
103+
"config": "./internals/webpack/webpack.prod.babel.js"
104+
}
105+
}
106+
}
107+
}

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

__tests__/VerticalTimelineElement_test.js

+33-15
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,57 @@ import React from 'react';
22
import {
33
renderIntoDocument,
44
findRenderedDOMComponentWithClass,
5-
scryRenderedDOMComponentsWithClass
5+
scryRenderedDOMComponentsWithClass,
66
} from 'react-dom/test-utils';
77
import VerticalTimelineElement from '../src/VerticalTimelineElement';
88

9-
describe('VerticalTimeline', function () {
10-
it('should have the vertical-timeline-element classname', function () {
9+
describe('VerticalTimeline', () => {
10+
it('should have the vertical-timeline-element classname', () => {
1111
const component = renderIntoDocument(<VerticalTimelineElement />);
1212
findRenderedDOMComponentWithClass(component, 'vertical-timeline-element');
1313
});
1414

15-
it('should have the vertical-timeline-element--right classname', function () {
16-
const component = renderIntoDocument(<VerticalTimelineElement position="right" />);
17-
findRenderedDOMComponentWithClass(component, 'vertical-timeline-element--right');
15+
it('should have the vertical-timeline-element--right classname', () => {
16+
const component = renderIntoDocument(
17+
<VerticalTimelineElement position="right" />,
18+
);
19+
findRenderedDOMComponentWithClass(
20+
component,
21+
'vertical-timeline-element--right',
22+
);
1823
});
1924

20-
describe('when children is empty', function () {
21-
it('should have the vertical-timeline-element--no-children classname', function () {
25+
describe('when children is empty', () => {
26+
it('should have the vertical-timeline-element--no-children classname', () => {
2227
const component = renderIntoDocument(<VerticalTimelineElement />);
23-
findRenderedDOMComponentWithClass(component, 'vertical-timeline-element--no-children');
28+
findRenderedDOMComponentWithClass(
29+
component,
30+
'vertical-timeline-element--no-children',
31+
);
2432
});
2533

26-
it('should have the vertical-timeline-element--no-children classname', function () {
27-
const componentWithDate = renderIntoDocument(<VerticalTimelineElement date="2018" />);
28-
findRenderedDOMComponentWithClass(componentWithDate, 'vertical-timeline-element--no-children');
34+
it('should have the vertical-timeline-element--no-children classname', () => {
35+
const componentWithDate = renderIntoDocument(
36+
<VerticalTimelineElement date="2018" />,
37+
);
38+
findRenderedDOMComponentWithClass(
39+
componentWithDate,
40+
'vertical-timeline-element--no-children',
41+
);
2942
});
3043

31-
it('should not have the vertical-timeline-element--no-children classname', function () {
44+
it('should not have the vertical-timeline-element--no-children classname', () => {
3245
const component = renderIntoDocument(
3346
<VerticalTimelineElement>
3447
<div>My Child</div>
35-
</VerticalTimelineElement>
48+
</VerticalTimelineElement>,
3649
);
37-
expect(scryRenderedDOMComponentsWithClass(component, 'vertical-timeline-element--no-children').length).toBe(0);
50+
expect(
51+
scryRenderedDOMComponentsWithClass(
52+
component,
53+
'vertical-timeline-element--no-children',
54+
).length,
55+
).toBe(0);
3856
});
3957
});
4058
});

__tests__/VerticalTimeline_test.js

+19-10
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,34 @@ import { expect } from 'chai';
44

55
import VerticalTimeline from '../src/VerticalTimeline';
66

7-
describe('VerticalTimeline', function () {
8-
it('should have the vertical-timeline classname', function () {
7+
describe('VerticalTimeline', () => {
8+
it('should have the vertical-timeline classname', () => {
99
const component = shallow(
10-
<VerticalTimeline><div>test1</div><div>test2</div></VerticalTimeline>
10+
<VerticalTimeline>
11+
<div>test1</div>
12+
<div>test2</div>
13+
</VerticalTimeline>,
1114
);
12-
expect(component.hasClass('vertical-timeline')).to.be.true;
15+
expect(component.hasClass('vertical-timeline')).to.equal(true);
1316
});
1417

15-
it('should have the vertical-timeline--animate classname', function () {
18+
it('should have the vertical-timeline--animate classname', () => {
1619
const component = shallow(
17-
<VerticalTimeline><div>test1</div><div>test2</div></VerticalTimeline>
20+
<VerticalTimeline>
21+
<div>test1</div>
22+
<div>test2</div>
23+
</VerticalTimeline>,
1824
);
19-
expect(component.hasClass('vertical-timeline--animate')).to.be.true;
25+
expect(component.hasClass('vertical-timeline--animate')).to.equal(true);
2026
});
2127

22-
it('should not have the vertical-timeline--animate classname', function () {
28+
it('should not have the vertical-timeline--animate classname', () => {
2329
const component = shallow(
24-
<VerticalTimeline animate={false}><div>test1</div><div>test2</div></VerticalTimeline>
30+
<VerticalTimeline animate={false}>
31+
<div>test1</div>
32+
<div>test2</div>
33+
</VerticalTimeline>,
2534
);
26-
expect(component.hasClass('vertical-timeline--animate')).to.be.false;
35+
expect(component.hasClass('vertical-timeline--animate')).to.equal(false);
2736
});
2837
});

catalog.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint no-param-reassign: 0 */
22
module.exports = {
3-
webpack: (catalogWebpackConfig) => {
3+
webpack: catalogWebpackConfig => {
44
catalogWebpackConfig.output.publicPath = '';
55
return catalogWebpackConfig;
6-
}
6+
},
77
};

0 commit comments

Comments
 (0)