chore: lint

This commit is contained in:
cha0s 2020-06-21 20:50:39 -05:00
parent 597de89826
commit 7d15057699
10 changed files with 61 additions and 12 deletions

View File

@ -30,6 +30,8 @@
"ansi-html": "0.0.7", "ansi-html": "0.0.7",
"classnames": "2.2.6", "classnames": "2.2.6",
"contempo": "1.x", "contempo": "1.x",
"debug": "^4.1.1",
"deepmerge": "^4.2.2",
"express": "^4.17.1", "express": "^4.17.1",
"express-session": "^1.17.1", "express-session": "^1.17.1",
"express-socket.io-session": "^1.3.5", "express-socket.io-session": "^1.3.5",
@ -44,6 +46,7 @@
"react-markdown": "^4.3.1", "react-markdown": "^4.3.1",
"react-redux": "^7.2.0", "react-redux": "^7.2.0",
"react-tabs": "^3.1.1", "react-tabs": "^3.1.1",
"redux": "^4.0.5",
"scwp": "1.x", "scwp": "1.x",
"socket.io-redis": "^5.3.0", "socket.io-redis": "^5.3.0",
"source-map-support": "^0.5.11" "source-map-support": "^0.5.11"

View File

@ -1,5 +1,6 @@
import './app.scss'; import './app.scss';
import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import {all} from './resources.scwp'; import {all} from './resources.scwp';
@ -10,11 +11,21 @@ const Resource = (props) => {
const { const {
uri, uri,
} = props; } = props;
const resource = resources.find((resource) => uri.match(resource.matcher)); const resource = resources.find((r) => uri.match(r.matcher));
const {Component} = resource const {
? resource Component = () => (
: {Component: () => <div className="unloadable">No loader for `<code>{uri}</code>`.</div>}; <div className="unloadable">
No loader for `
<code>{uri}</code>
`.
</div>
),
} = resource || {};
return <div className="resource"><Component uri={uri} /></div>; return <div className="resource"><Component uri={uri} /></div>;
}; };
Resource.propTypes = {
uri: PropTypes.string.isRequired,
};
export default Resource; export default Resource;

View File

@ -1,6 +1,7 @@
import {compose} from '@avocado/core'; import {compose} from '@avocado/core';
import {Entity} from '@avocado/entity'; import {Entity} from '@avocado/entity';
import contempo from 'contempo'; import contempo from 'contempo';
import PropTypes from 'prop-types';
import React, {useEffect} from 'react'; import React, {useEffect} from 'react';
import {useDispatch, useSelector} from 'react-redux'; import {useDispatch, useSelector} from 'react-redux';
@ -35,4 +36,8 @@ const EntityComponent = (props) => {
); );
}; };
EntityComponent.propTypes = {
uri: PropTypes.string.isRequired,
};
export default decorate(EntityComponent); export default decorate(EntityComponent);

View File

@ -4,5 +4,6 @@ export default {
keys: ['entity', 'entities'], keys: ['entity', 'entities'],
matcher: /\.entity\.json$/, matcher: /\.entity\.json$/,
Component: EntityComponent, Component: EntityComponent,
// eslint-disable-next-line global-require
state: require('./state'), state: require('./state'),
}; };

View File

@ -1,3 +1,4 @@
/* eslint-disable no-param-reassign */
import {normalize, schema} from 'normalizr'; import {normalize, schema} from 'normalizr';
import { import {
createAsyncThunk, createAsyncThunk,
@ -15,7 +16,7 @@ export const fetchEntity = createAsyncThunk(
const json = await data.json(); const json = await data.json();
const {entities} = normalize(json, entitySchema); const {entities} = normalize(json, entitySchema);
return entities; return entities;
} },
); );
const adapter = createEntityAdapter({ const adapter = createEntityAdapter({
@ -28,8 +29,8 @@ export const {
selectIds: selectEntityIds, selectIds: selectEntityIds,
selectEntities: selectEntityEntities, selectEntities: selectEntityEntities,
selectAll: selectAllEntities, selectAll: selectAllEntities,
selectTotal: selectTotalEntities selectTotal: selectTotalEntities,
} = adapter.getSelectors((state) => state.entities) } = adapter.getSelectors((state) => state.entities);
export const selectEntityUris = createSelector( export const selectEntityUris = createSelector(
(state) => state.entities, (state) => state.entities,
@ -41,13 +42,21 @@ export const selectEntityByUri = createSelector(
selectEntityUris, selectEntityUris,
(_, uri) => uri, (_, uri) => uri,
({entities}, uris, uri) => entities[uris[uri]], ({entities}, uris, uri) => entities[uris[uri]],
) );
const slice = createSlice({ const slice = createSlice({
name: 'entities', name: 'entities',
initialState: adapter.getInitialState({uris: {}}), initialState: adapter.getInitialState({uris: {}}),
reducers: { reducers: {
setTraitProperty: (state, {payload: {target, trait, type, key, value}}) => { setTraitProperty: (state, {
payload: {
target,
trait,
type,
key,
value,
},
}) => {
const {traits} = state.entities[target]; const {traits} = state.entities[target];
traits[trait] = traits[trait] || {}; traits[trait] = traits[trait] || {};
traits[trait][type] = traits[trait][type] || {}; traits[trait][type] = traits[trait][type] || {};
@ -59,6 +68,7 @@ const slice = createSlice({
[fetchEntity.fulfilled]: (state, action) => { [fetchEntity.fulfilled]: (state, action) => {
adapter.upsertMany(state, action.payload.entities); adapter.upsertMany(state, action.payload.entities);
Object.entries(action.payload.entities) Object.entries(action.payload.entities)
// eslint-disable-next-line no-return-assign
.forEach(([id, entity]) => state.uris[entity.uri] = id); .forEach(([id, entity]) => state.uris[entity.uri] = id);
}, },
}, },

View File

@ -1,6 +1,7 @@
import {mapObject} from '@avocado/core'; import {mapObject} from '@avocado/core';
import {lookupTrait} from '@avocado/entity'; import {lookupTrait} from '@avocado/entity';
import {all as allTraitComponents} from '@avocado/entity/trait/trait-components.scwp'; import {all as allTraitComponents} from '@avocado/entity/trait/trait-components.scwp';
import PropTypes from 'prop-types';
import React, {useMemo} from 'react'; import React, {useMemo} from 'react';
import {useDispatch} from 'react-redux'; import {useDispatch} from 'react-redux';
@ -84,4 +85,11 @@ const TraitPane = (props) => {
); );
}; };
TraitPane.propTypes = {
context: PropTypes.shape({}).isRequired,
target: PropTypes.string.isRequired,
trait: PropTypes.shape({}).isRequired,
type: PropTypes.string.isRequired,
};
export default TraitPane; export default TraitPane;

View File

@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
const TraitTab = (props) => { const TraitTab = (props) => {
@ -11,4 +12,8 @@ const TraitTab = (props) => {
); );
}; };
TraitTab.propTypes = {
type: PropTypes.string.isRequired,
};
export default TraitTab; export default TraitTab;

View File

@ -76,6 +76,7 @@ const Traits = (props) => {
Traits.propTypes = { Traits.propTypes = {
context: PropTypes.shape({}).isRequired, context: PropTypes.shape({}).isRequired,
target: PropTypes.string.isRequired,
traits: PropTypes.shape({}).isRequired, traits: PropTypes.shape({}).isRequired,
}; };

View File

@ -8,8 +8,8 @@ import {all} from './resources.scwp';
const resources = Object.values(all()).map((M) => M.default); const resources = Object.values(all()).map((M) => M.default);
const reducerMap = resources.reduce( const reducerMap = resources.reduce(
(r, {keys, state: {'default': reducer}}) => ({...r, [keys[1]]: reducer}), (r, {keys, state: {default: reducer}}) => ({...r, [keys[1]]: reducer}),
{} {},
); );
export default function createStore(options = {}) { export default function createStore(options = {}) {

View File

@ -3346,6 +3346,11 @@ deepmerge@^2.2.1:
resolved "https://npm.i12e.cha0s.io/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170" resolved "https://npm.i12e.cha0s.io/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170"
integrity sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA== integrity sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA==
deepmerge@^4.2.2:
version "4.2.2"
resolved "https://npm.i12e.cha0s.io/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955"
integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==
default-gateway@^4.2.0: default-gateway@^4.2.0:
version "4.2.0" version "4.2.0"
resolved "https://npm.i12e.cha0s.io/default-gateway/-/default-gateway-4.2.0.tgz#167104c7500c2115f6dd69b0a536bb8ed720552b" resolved "https://npm.i12e.cha0s.io/default-gateway/-/default-gateway-4.2.0.tgz#167104c7500c2115f6dd69b0a536bb8ed720552b"
@ -7796,7 +7801,7 @@ redux-thunk@^2.3.0:
resolved "https://npm.i12e.cha0s.io/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622" resolved "https://npm.i12e.cha0s.io/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"
integrity sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw== integrity sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw==
redux@^4.0.0: redux@^4.0.0, redux@^4.0.5:
version "4.0.5" version "4.0.5"
resolved "https://npm.i12e.cha0s.io/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f" resolved "https://npm.i12e.cha0s.io/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f"
integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w== integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w==