Skip to content

Commit 9b6dab3

Browse files
author
Antonella Sgarlatta
authored
Merge pull request #110 from standardnotes/feature/add-eslint
Add eslint and pre-commit hook
2 parents 1d46940 + 37d72e5 commit 9b6dab3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2518
-981
lines changed

.eslintrc.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": "airbnb",
7+
"globals": {
8+
"Atomics": "readonly",
9+
"SharedArrayBuffer": "readonly",
10+
"Turbolinks": "readonly"
11+
},
12+
"parserOptions": {
13+
"ecmaFeatures": {
14+
"jsx": true
15+
},
16+
"ecmaVersion": 2018,
17+
"sourceType": "module"
18+
},
19+
"plugins": [
20+
"react"
21+
],
22+
"rules": {
23+
"indent": ["error", 4],
24+
"jsx-a11y/label-has-associated-control": ["error", {
25+
"labelAttributes": ["htmlFor"]
26+
}],
27+
"quotes": ["error", "double"],
28+
"react/jsx-indent": [2, 4],
29+
"react/jsx-indent-props": [2, 4],
30+
"react/jsx-props-no-spreading": [0],
31+
"react/prop-types": [0]
32+
}
33+
}

babel.config.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
module.exports = function (api) {
2-
var validEnv = ["development", "production"];
3-
var currentEnv = api.env();
4-
var isDevelopmentEnv = api.env("development");
1+
module.exports = (api) => {
2+
const validEnv = ["development", "production"];
3+
const currentEnv = api.env();
4+
const isDevelopmentEnv = api.env("development");
55

66
if (!validEnv.includes(currentEnv)) {
77
throw new Error(
8-
"Please specify a valid `NODE_ENV` or " +
9-
'`BABEL_ENV` environment variables. Valid values are "development", ' +
10-
'"test", and "production". Instead, received: ' +
11-
JSON.stringify(currentEnv) +
12-
"."
8+
`${"Please specify a valid `NODE_ENV` or "
9+
+ "`BABEL_ENV` environment variables. Valid values are \"development\", "
10+
+ "\"test\", and \"production\". Instead, received: "}${
11+
JSON.stringify(currentEnv)
12+
}.`,
1313
);
1414
}
1515

client/app/assets/gifs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import SettingsGif from "./listed-settings.gif";
55
export {
66
GettingStartedGif,
77
PublishGif,
8-
SettingsGif
8+
SettingsGif,
99
};

client/app/assets/icons/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import IcArrowLong from "./ic-arrow-long.svg";
22
import IcBook from "./ic-book.svg";
3-
import IcCheckboxChecked from "./ic-checkbox-checked";
4-
import IcCheckboxEmpty from "./ic-checkbox-empty";
3+
import IcCheckboxChecked from "./ic-checkbox-checked.svg";
4+
import IcCheckboxEmpty from "./ic-checkbox-empty.svg";
55
import IcChevronDown from "./ic-chevron-down.svg";
66
import IcChevronUp from "./ic-chevron-up.svg";
77
import IcClose from "./ic-close.svg";
@@ -47,5 +47,5 @@ export {
4747
IcStarCircleFilled,
4848
IcTextRich,
4949
IcTrash,
50-
IcWalletFilled
50+
IcWalletFilled,
5151
};

client/app/assets/styles/application.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,3 @@ textarea {
412412
.text-field--error {
413413
outline: $color-error auto 1px;
414414
}
415-
416-
.author-page {
417-
.button--primary {
418-
419-
}
420-
}
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
import React from "react";
22

3-
export default ({ username, id, domain, email }) => {
4-
return (
5-
<div>
6-
<p>A new domain request is ready for review.</p>
7-
<p>Author: {username}</p>
8-
<p>Author ID: {id}</p>
9-
<p>Request domain: {domain}</p>
10-
<p>Author email: {email}</p>
11-
</div>
12-
);
13-
};
3+
export default ({
4+
username, id, domain, email,
5+
}) => (
6+
<div>
7+
<p>A new domain request is ready for review.</p>
8+
<p>
9+
Author:
10+
{username}
11+
</p>
12+
<p>
13+
Author ID:
14+
{id}
15+
</p>
16+
<p>
17+
Request domain:
18+
{domain}
19+
</p>
20+
<p>
21+
Author email:
22+
{email}
23+
</p>
24+
</div>
25+
);

client/app/components/authors/HeaderContainer.jsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ const HeaderContainer = ({
1212
pages,
1313
authorGuestbookEntriesUrl,
1414
currentUrl,
15-
blogPage
15+
blogPage,
1616
}) => {
1717
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
1818

19-
const renderMenu = isDesktopMenu => (
19+
const renderMenu = (isDesktopMenu) => (
2020
<MenuContainer
2121
isMobileMenuOpen={isMobileMenuOpen}
2222
isDesktopMenu={isDesktopMenu}
@@ -29,7 +29,7 @@ const HeaderContainer = ({
2929

3030
return (
3131
<div className={`page-header__container ${post ? "page-header__container--post" : ""}`}>
32-
<div id="page-header" >
32+
<div id="page-header">
3333
<div className="left">
3434
<div className="website-name">
3535
<a href={homeUrl} className="listed-logo-link">
@@ -45,11 +45,15 @@ const HeaderContainer = ({
4545
)}
4646
</div>
4747
<div className="right">
48-
<button className="button button--menu-icon" aria-label="Menu" aria-controls="navigation">
49-
{isMobileMenuOpen
48+
<button
49+
className="button button--menu-icon"
50+
aria-label="Menu"
51+
aria-controls="navigation"
52+
type="button"
53+
>
54+
{isMobileMenuOpen
5055
? <SVG src={IcClose} onClick={() => setIsMobileMenuOpen(false)} />
51-
: <SVG src={IcMenu} onClick={() => setIsMobileMenuOpen(true)} />
52-
}
56+
: <SVG src={IcMenu} onClick={() => setIsMobileMenuOpen(true)} />}
5357
</button>
5458
{renderMenu(true)}
5559
</div>
@@ -62,4 +66,4 @@ const HeaderContainer = ({
6266
);
6367
};
6468

65-
export default props => <HeaderContainer {...props} />;
69+
export default (props) => <HeaderContainer {...props} />;

client/app/components/authors/SettingsPage.jsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
GuestbookEntries,
77
CustomDomain,
88
PaymentDetails,
9-
DeleteBlog
9+
DeleteBlog,
1010
} from "./settings";
1111
import Resources from "../shared/Resources";
1212
import {
@@ -16,82 +16,86 @@ import {
1616
IcEarth,
1717
IcCreditCard,
1818
IcLifebuoy,
19-
IcTrash
19+
IcTrash,
2020
} from "../../assets/icons";
2121
import "./SettingsPage.scss";
2222

23-
const SettingsPage = ({ author, authorCredentialsUrl, customDomainIP, guestbookEntries, posts, deleteAllDataError }) => {
23+
const SettingsPage = ({
24+
author, authorCredentialsUrl, customDomainIP, guestbookEntries, posts,
25+
}) => {
2426
const sections = [
2527
{
2628
id: "general",
2729
title: "General",
2830
icon: IcSettingsFilled,
2931
collapsed: false,
30-
renderContent: () => <General author={author} />
32+
renderContent: () => <General author={author} />,
3133
},
3234
{
3335
id: "my-posts",
3436
title: "My posts",
3537
icon: IcTextRich,
3638
collapsed: true,
37-
renderContent: () => <MyPosts posts={posts} author={author} />
39+
renderContent: () => <MyPosts posts={posts} author={author} />,
3840
},
3941
{
4042
id: "guestbook-entries",
4143
title: "Guestbook entries",
4244
icon: IcBook,
4345
collapsed: true,
44-
renderContent: () => <GuestbookEntries guestbookEntries={guestbookEntries} />
46+
renderContent: () => <GuestbookEntries guestbookEntries={guestbookEntries} />,
4547
},
4648
{
4749
id: "custom-domain",
4850
title: "Custom domain",
4951
icon: IcEarth,
5052
collapsed: true,
51-
renderContent: () => <CustomDomain author={author} customDomainIP={customDomainIP} />
53+
renderContent: () => <CustomDomain author={author} customDomainIP={customDomainIP} />,
5254
},
5355
{
5456
id: "payment-details",
5557
title: "Payment details",
5658
icon: IcCreditCard,
5759
collapsed: true,
58-
renderContent: () => <PaymentDetails author={author} authorCredentialsUrl={authorCredentialsUrl} />
60+
renderContent: () => (
61+
<PaymentDetails author={author} authorCredentialsUrl={authorCredentialsUrl} />
62+
),
5963
},
6064
{
6165
id: "resources",
6266
title: "Resources",
6367
icon: IcLifebuoy,
6468
collapsed: true,
65-
renderContent: () => <Resources />
69+
renderContent: () => <Resources />,
6670
},
6771
{
6872
id: "delete-blog",
6973
title: "Delete blog",
7074
icon: IcTrash,
7175
collapsed: true,
72-
renderContent: () => <DeleteBlog author={author} />
73-
}
76+
renderContent: () => <DeleteBlog author={author} />,
77+
},
7478
];
7579

7680
return (
7781
<LeftNavBarPage
7882
heading="Settings"
79-
subheading={
83+
subheading={(
8084
<div>
8185
<p className="p1">
8286
Your public blog is accessible via:
8387
</p>
8488
<ul className="accessible-via">
85-
{author.accessible_via.map(url => (
89+
{author.accessible_via.map((url) => (
8690
<li key={url} className="p1">
8791
<a href={url} target="_blank" rel="noopener noreferrer">
8892
{url}
8993
</a>
90-
</li>
94+
</li>
9195
))}
9296
</ul>
9397
</div>
94-
}
98+
)}
9599
sections={sections}
96100
/>
97101
);

client/app/components/authors/Show.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,32 @@ const Show = ({ posts, olderThan, displayAuthor }) => {
1515
axios
1616
.get(`/authors/${displayAuthor.id}/more_posts?older_than=${loadMorePostsDate}`, null, {
1717
headers: {
18-
"X-CSRF-Token": getAuthToken()
18+
"X-CSRF-Token": getAuthToken(),
1919
},
2020
})
21-
.then(response => {
22-
const { older_than, posts } = response.data;
21+
.then((response) => {
22+
const { older_than: newOlderThan, posts: newPosts } = response.data;
2323

24-
setVisiblePosts([...visiblePosts, ...posts]);
25-
setLoadMorePostsDate(older_than);
24+
setVisiblePosts([...visiblePosts, ...newPosts]);
25+
setLoadMorePostsDate(newOlderThan);
2626
})
27-
.catch(error => {
27+
.catch(() => {
2828
setLoadMorePostsDate(null);
29-
})
29+
});
3030
};
3131

3232
return (
3333
<div id="author-profile">
3434
<div id="author-posts">
35-
{visiblePosts.map(post => (
35+
{visiblePosts.map((post) => (
3636
<div key={post.id} className="author-post">
37-
<Post post={post}></Post>
37+
<Post post={post} />
3838
</div>
3939
))}
4040
{loadMorePostsDate && (
4141
<div className="navigation">
4242
<div className="older">
43-
<button className="button" onClick={loadMorePosts}>
43+
<button className="button" type="button" onClick={loadMorePosts}>
4444
Load more posts
4545
<SVG
4646
src={IcChevronDown}
@@ -56,4 +56,4 @@ const Show = ({ posts, olderThan, displayAuthor }) => {
5656
);
5757
};
5858

59-
export default props => <Show {...props} />;
59+
export default (props) => <Show {...props} />;

client/app/components/authors/Subscribe.jsx

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,33 @@ import React from "react";
22
import SubscriptionForm from "./SubscriptionForm";
33
import "./Subscribe.scss";
44

5-
const Subscribe = ({ displayAuthor, subscribedToAuthor, subscriptionForAuthor, subscriptionSuccess }) => {
6-
return (
7-
<div id="subscribe-page" className="page-container">
8-
<h1 className="h1">Subscribe</h1>
9-
{(!subscribedToAuthor ||!subscriptionForAuthor.verification_sent_at) && (
10-
<p className="p1">
11-
You'll only receive an email when the author publishes something new.
12-
</p>
13-
)}
14-
<div id="subscription-form">
15-
<SubscriptionForm
16-
subscribedToAuthor={subscribedToAuthor}
17-
subscriptionForAuthor={subscriptionForAuthor}
18-
subscriptionSuccess={subscriptionSuccess}
19-
author={displayAuthor}
20-
>
21-
</SubscriptionForm>
22-
</div>
23-
{(!subscribedToAuthor ||!subscriptionForAuthor.verification_sent_at) && (
24-
<p className="p1 subscribe-page__rss-feed">
25-
Or view their{" "}
26-
<a href={displayAuthor.rss_url} data-turbolinks="false">RSS feed</a>.
27-
</p>
28-
)}
5+
const Subscribe = ({
6+
displayAuthor, subscribedToAuthor, subscriptionForAuthor, subscriptionSuccess,
7+
}) => (
8+
<div id="subscribe-page" className="page-container">
9+
<h1 className="h1">Subscribe</h1>
10+
{(!subscribedToAuthor || !subscriptionForAuthor.verification_sent_at) && (
11+
<p className="p1">
12+
You&apos;ll only receive an email when the author publishes something new.
13+
</p>
14+
)}
15+
<div id="subscription-form">
16+
<SubscriptionForm
17+
subscribedToAuthor={subscribedToAuthor}
18+
subscriptionForAuthor={subscriptionForAuthor}
19+
subscriptionSuccess={subscriptionSuccess}
20+
author={displayAuthor}
21+
/>
2922
</div>
30-
);
31-
};
23+
{(!subscribedToAuthor || !subscriptionForAuthor.verification_sent_at) && (
24+
<p className="p1 subscribe-page__rss-feed">
25+
Or view their
26+
{" "}
27+
<a href={displayAuthor.rss_url} data-turbolinks="false">RSS feed</a>
28+
.
29+
</p>
30+
)}
31+
</div>
32+
);
3233

3334
export default Subscribe;

0 commit comments

Comments
 (0)