Commit 6471a8c3 authored by Yamagishi Kazutoshi's avatar Yamagishi Kazutoshi

Introduce ESLint

parent a0782c2d
/app/javascript/locales/default.js
/app/javascript/locales/translations.js
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
},
extends: 'airbnb',
env: {
browser: true,
},
rules: {
'jsx-quotes': ['error', 'prefer-single'],
'no-multi-spaces': [
'error',
{
ignoreEOLComments: false,
exceptions: {
VariableDeclarator: true,
},
},
],
},
};
import { FINDER_PROGRESS, FINDER_RESULTS, FINDER_DOMAINS } from '../constants/finderConstants';
import axios from 'axios';
import {
FINDER_PROGRESS,
FINDER_RESULTS,
FINDER_DOMAINS,
} from '../constants/finderConstants';
export const fetchProgress = () => dispatch => axios.get('/friends/status.json').then(({ data }) => {
export const fetchResults = () => dispatch => axios.get('/friends/results.json').then(({ data }) => {
dispatch({
type: FINDER_PROGRESS,
type: FINDER_RESULTS,
data,
});
if (data.status === 'complete') {
dispatch(fetchResults());
dispatch(fetchDomains());
} else if (data.status === 'failed') {
console.error('failed');
} else {
setTimeout(() => dispatch(fetchProgress()), 1000);
}
});
export const fetchResults = () => dispatch => axios.get('/friends/results.json').then(({ data }) => {
export const fetchDomains = () => dispatch => axios.get('/friends/domains.json').then(({ data }) => {
dispatch({
type: FINDER_RESULTS,
type: FINDER_DOMAINS,
data,
});
});
export const fetchDomains = () => dispatch => axios.get('/friends/domains.json').then(({ data }) => {
export const fetchProgress = () => dispatch => axios.get('/friends/status.json').then(({ data }) => {
dispatch({
type: FINDER_DOMAINS,
type: FINDER_PROGRESS,
data,
});
if (data.status === 'complete') {
dispatch(fetchResults());
dispatch(fetchDomains());
} else if (data.status === 'failed') {
console.error('failed'); // eslint-disable-line no-console
} else {
setTimeout(() => dispatch(fetchProgress()), 1000);
}
});
import PropTypes from 'prop-types';
import React from 'react';
import React, { Fragment } from 'react';
import { FormattedMessage } from 'react-intl';
const ConnectPrompt = ({ isPioneer, domains }) => isPioneer ? (
const ConnectPrompt = ({ isPioneer, domains }) => (
<div className='connect-prompt'>
<h3><i className='fa fa-binoculars' /> <FormattedMessage id='connect_prompt.pioneer.title' defaultMessage='You are a pioneer!' /></h3>
<p><FormattedMessage id='connect_prompt.pioneer.body' defaultMessage='You might be the first among your Twitter friends to explore Mastodon. Be sure to connect your Mastodon account so they see you when they join.' /></p>
{isPioneer ? (
<Fragment>
<h3><i className='fa fa-binoculars' /> <FormattedMessage id='connect_prompt.pioneer.title' defaultMessage='You are a pioneer!' /></h3>
<p><FormattedMessage id='connect_prompt.pioneer.body' defaultMessage='You might be the first among your Twitter friends to explore Mastodon. Be sure to connect your Mastodon account so they see you when they join.' /></p>
</Fragment>
) : (
<Fragment>
<h3><i className='fa fa-check' /> <FormattedMessage id='connect_prompt.tutorial.title' defaultMessage='Almost there!' /></h3>
<p><FormattedMessage id='connect_prompt.tutorial.body' defaultMessage='For your friends to find you as well, you still need to login with your Mastodon account. If you need help choosing a server to create a new account on, {link} or click the button below.' values={{ link: <a href='#domain'><FormattedMessage id='connect_prompt.tutorial.link' defaultMessage='see where your friends have signed up' /></a> }} /></p>
</Fragment>
)}
<a target='_blank' href='/users/auth/mastodon'><FormattedMessage id='connect_prompt.login_via_mastodon' defaultMessage='Login via Mastodon' /></a>
{domains.length > 0 && <a target='_blank' className='secondary' href={`https://${domains[0].uri}/auth/sign_up`}><FormattedMessage id='connect_prompt.create_mastodon_account' defaultMessage='Create Mastodon account' /></a>}
</div>
) : (
<div className='connect-prompt'>
<h3><i className='fa fa-check' /> <FormattedMessage id='connect_prompt.tutorial.title' defaultMessage='Almost there!' /></h3>
<p><FormattedMessage id='connect_prompt.tutorial.body' defaultMessage='For your friends to find you as well, you still need to login with your Mastodon account. If you need help choosing a server to create a new account on, {link} or click the button below.' values={{ link: <a href='#domain'><FormattedMessage id='connect_prompt.tutorial.link' defaultMessage='see where your friends have signed up' /></a> }} /></p>
<a target='_blank' href='/users/auth/mastodon'><FormattedMessage id='connect_prompt.login_via_mastodon' defaultMessage='Login via Mastodon' /></a>
{domains.length > 0 && <a target='_blank' className='secondary' href={`https://${domains[0].uri}/auth/sign_up`}><FormattedMessage id='connect_prompt.create_mastodon_account' defaultMessage='Create Mastodon account' /></a>}
{domains.length > 0 && <a rel='noopener noreferrer' target='_blank' className='secondary' href={`https://${domains[0].uri}/auth/sign_up`}><FormattedMessage id='connect_prompt.create_mastodon_account' defaultMessage='Create Mastodon account' /></a>}
</div>
);
ConnectPrompt.defaultProps = {
isPioneer: false,
};
ConnectPrompt.propTypes = {
isPioneer: PropTypes.bool,
domains: PropTypes.array.isRequired,
domains: PropTypes.arrayOf(PropTypes.shape({
uri: PropTypes.string,
})).isRequired,
};
export default ConnectPrompt;
......@@ -5,7 +5,7 @@ import HelloWorld from '../components/HelloWorld';
import * as actions from '../actions/finderActionCreators';
// Which part of the Redux global state does our component want to receive as props?
const mapStateToProps = (state) => ({
const mapStateToProps = state => ({
...state.finder,
...state.user,
});
......
import { combineReducers } from 'redux';
import { FINDER_PROGRESS, FINDER_RESULTS, FINDER_DOMAINS } from '../constants/finderConstants';
import {
FINDER_PROGRESS,
FINDER_RESULTS,
FINDER_DOMAINS,
} from '../constants/finderConstants';
const initialState = {
total: 0,
......@@ -13,7 +17,12 @@ const initialState = {
const finder = (state = initialState, action) => {
switch (action.type) {
case FINDER_PROGRESS:
return { ...state, status: action.data.status, total: action.data.total, at: action.data.at };
return {
...state,
status: action.data.status,
total: action.data.total,
at: action.data.at,
};
case FINDER_RESULTS:
return { ...state, inProgress: false, results: action.data };
case FINDER_DOMAINS:
......@@ -23,9 +32,7 @@ const finder = (state = initialState, action) => {
}
};
const user = (state = '', action) => {
return state;
};
const user = (state = '') => state;
const finderReducer = combineReducers({ finder, user });
......
......@@ -21,7 +21,7 @@ const messages = translations[locale] || translations[defaultLocale];
// See documentation for https://github.com/reactjs/react-redux.
// This is how you get props from the Rails view into the redux store.
// This code here binds your smart component to the redux store.
const HelloWorldApp = (props) => (
const HelloWorldApp = props => (
<IntlProvider locale={locale} messages={messages}>
<Provider store={configureStore(props)}>
<HelloWorldContainer />
......
import { createStore, applyMiddleware, compose } from 'redux';
import finderReducer from '../reducers/finderReducer';
import thunk from 'redux-thunk';
import finderReducer from '../reducers/finderReducer';
// eslint-disable-next-line no-underscore-dangle
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const configureStore = (railsProps) => (
const configureStore = railsProps => (
createStore(finderReducer, railsProps, composeEnhancers(applyMiddleware(thunk)))
);
......
......@@ -2,4 +2,4 @@ import './logo_full.svg';
import './logo.svg';
import './preview.jpg';
import './toot-friend.png';
import './twitter-square.png';
\ No newline at end of file
import './twitter-square.png';
import '../styles/application.scss';
import '../images';
import Rails from 'rails-ujs';
import ReactOnRails from 'react-on-rails';
import '../styles/application.scss';
import '../images';
import HelloWorldApp from '../bundles/HelloWorld/startup/HelloWorldApp';
Rails.start();
......
......@@ -21,6 +21,8 @@ default: &default
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: postgres
development:
<<: *default
database: mastodon-bridge_development
......
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const environment = require('./environment')
const environment = require('./environment');
module.exports = environment.toWebpackConfig()
module.exports = environment.toWebpackConfig();
const { environment } = require('@rails/webpacker')
const { environment } = require('@rails/webpacker');
module.exports = environment
module.exports = environment;
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
const environment = require('./environment')
const environment = require('./environment');
module.exports = environment.toWebpackConfig()
module.exports = environment.toWebpackConfig();
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const environment = require('./environment')
const environment = require('./environment');
module.exports = environment.toWebpackConfig()
module.exports = environment.toWebpackConfig();
{
"name": "@mastodon/bridge-build",
"private": true,
"scripts": {
"test:lint": "eslint --ext js --ext jsx ./app/javascript/ ./config/webpack/"
},
"dependencies": {
"@rails/webpacker": "3.5",
"axios": "^0.18.0",
......@@ -18,6 +21,12 @@
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"babel-eslint": "^8.2.3",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.9.1",
"webpack-dev-server": "2.11.2"
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment