Skip to content
Snippets Groups Projects
Commit dcfa56a2 authored by Yannis Barlas's avatar Yannis Barlas
Browse files

Merge branch 'lint' into 'main'

fix(*): add linter config and fix some files

See merge request kotahi/kotahi!153
parents 17f5d71a c8db0f00
No related branches found
No related tags found
No related merge requests found
Showing
with 136 additions and 93 deletions
module.exports = {
extends: ['@commitlint/config-conventional'],
}
const { commitizen } = require('@coko/lint')
commitizen.scopes = ['api', 'models', 'client', 'ui', '*']
module.exports = commitizen
# docker
Dockerfile*
docker-compose*
# git
.git
.gitignore
# npm & yarn
node_modules node_modules
npm-debug.log
package-lock.json
yarn-error.log
# misc
.devcontainer
.DS_Store
.vscode
app.pid
# environment files
.env
.env-ci
.env.example
.envrc
*.env
# app
_build/
config/local*
cypress/
data/
coverage/
logs/
stories/
tmp/
uploads/*
CONTRIBUTING.md
# development config files
.eslintrc.js
.commitlintrc.js
.cz-config.js
.gitlab-ci.yml
.linstagedrc.js
.prettierrc.js
.stylelintrc.js
cypress.json
_build
node_modules
{
"env": {
"es6": true,
"browser": true
},
"globals": {
"fixture": true,
"test": true,
"cy": true,
},
"extends": [
"pubsweet"
],
"parser": "babel-eslint",
"rules": {
"camelcase": 0,
"consistent-return": 0,
"global-require": 0,
"jsx-a11y/anchor-is-valid": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/label-has-for": 0,
"jsx-a11y/no-static-element-interactions": 0,
"import/extensions": 0,
"import/no-dynamic-require": 0,
"import/no-extraneous-dependencies": 0,
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0,
"import/prefer-default-export": 0,
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-param-reassign": 0,
"no-shadow": 0,
"no-underscore-dangle": 0,
"react/no-did-mount-set-state": 0,
"react/prop-types": 0,
"sort-keys": 0
}
}
const { eslint } = require('@coko/lint')
eslint.rules['react/jsx-props-no-spreading'] = 0
module.exports = eslint
const { lintstaged } = require('@coko/lint')
module.exports = lintstaged
{
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}
const { prettier } = require('@coko/lint')
module.exports = prettier
**/_build
**/node_modules
{
"extends": "stylelint-config-pubsweet"
}
const { stylelint } = require('@coko/lint')
module.exports = stylelint
/* eslint-disable react/prop-types */
import * as React from 'react' import * as React from 'react'
import { useQuery } from '@apollo/client' import { gql, useQuery } from '@apollo/client'
import styled from 'styled-components' import styled from 'styled-components'
import gql from 'graphql-tag'
import AvatarImage from './image' import AvatarImage from './image'
import { Container, AvatarLink, OnlineIndicator } from './style' import { Container, AvatarLink, OnlineIndicator } from './style'
import ConditionalWrap from '../../ConditionalWrap' import ConditionalWrap from '../../ConditionalWrap'
...@@ -90,10 +91,9 @@ const Avatar = props => { ...@@ -90,10 +91,9 @@ const Avatar = props => {
} }
const AvatarHandler = props => { const AvatarHandler = props => {
const { showHoverProfile = true, isClickable } = props const { showHoverProfile = true, isClickable, user, username } = props
if (props.user) { if (user) {
const { user } = props
return ( return (
<ConditionalWrap <ConditionalWrap
condition={showHoverProfile} condition={showHoverProfile}
...@@ -108,10 +108,8 @@ const AvatarHandler = props => { ...@@ -108,10 +108,8 @@ const AvatarHandler = props => {
) )
} }
if (!props.user && props.username) { if (!user && username) {
return ( return <GetUserByUsername isClickable={isClickable} username={username} />
<GetUserByUsername isClickable={isClickable} username={props.username} />
)
} }
return null return null
......
/* eslint-disable react/prop-types */
import * as React from 'react' import * as React from 'react'
import VisibilitySensor from 'react-visibility-sensor' import VisibilitySensor from 'react-visibility-sensor'
...@@ -14,6 +16,7 @@ import { Img, FallbackImg, LoadingImg } from './style' ...@@ -14,6 +16,7 @@ import { Img, FallbackImg, LoadingImg } from './style'
export default function Image(props) { export default function Image(props) {
const { type, size, mobilesize } = props const { type, size, mobilesize } = props
const { ...rest } = props const { ...rest } = props
const fallbackSrc = const fallbackSrc =
type === 'user' type === 'user'
? '/static/profiles/default_avatar.svg' ? '/static/profiles/default_avatar.svg'
......
import UserAvatar from './UserAvatar' import UserAvatar from './UserAvatar'
// eslint-disable-next-line import/prefer-default-export
export { UserAvatar } export { UserAvatar }
/* eslint-disable no-shadow */
// @flow // @flow
// import theme from 'shared/theme' // import theme from 'shared/theme'
import styled, { css } from 'styled-components' import styled, { css } from 'styled-components'
import { Img as ReactImage } from 'react-image' import { Img as ReactImage } from 'react-image'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
// import { ProfileHeaderAction } from '../profile/style' // import { ProfileHeaderAction } from '../profile/style'
import { MEDIA_BREAK } from '../../layout' import { MEDIA_BREAK } from '../../layout'
// import { zIndex } from '../../globals' // import { zIndex } from '../../globals'
export const Container = styled.div` export const Container = styled.div`
position: relative; background-color: ${th('colorBackground')};
display: block; border: none;
width: ${props => (props.size ? `${props.size}px` : '32px')};
height: ${props => (props.size ? `${props.size}px` : '32px')};
border-radius: ${props => border-radius: ${props =>
props.type === 'community' ? `${props.size / 8}px` : '100%'}; props.type === 'community' ? `${props.size / 8}px` : '100%'};
border: none; display: block;
background-color: ${th('colorBackground')}; height: ${props => (props.size ? `${props.size}px` : '32px')};
position: relative;
width: ${props => (props.size ? `${props.size}px` : '32px')};
/* stylelint-disable-next-line order/properties-alphabetical-order */
${props => ${props =>
props.mobilesize && props.mobilesize &&
css` css`
...@@ -29,16 +33,16 @@ export const Container = styled.div` ...@@ -29,16 +33,16 @@ export const Container = styled.div`
` `
export const AvatarLink = styled(Link)` export const AvatarLink = styled(Link)`
align-items: center;
border-radius: ${props =>
props.type === 'community' ? `${props.size / 8}px` : '100%'};
display: flex; display: flex;
flex: none; flex: none;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
width: 100%;
justify-content: center; justify-content: center;
align-items: center;
pointer-events: auto; pointer-events: auto;
border-radius: ${props => width: 100%;
props.type === 'community' ? `${props.size / 8}px` : '100%'};
` `
// export const CoverAction = styled(ProfileHeaderAction)` // export const CoverAction = styled(ProfileHeaderAction)`
...@@ -49,14 +53,15 @@ export const AvatarLink = styled(Link)` ...@@ -49,14 +53,15 @@ export const AvatarLink = styled(Link)`
// ` // `
export const Img = styled(ReactImage)` export const Img = styled(ReactImage)`
display: inline-block; background-color: ${th('colorBackground')};
width: ${props => (props.size ? `${props.size}px` : '32px')};
height: ${props => (props.size ? `${props.size}px` : '32px')};
border-radius: ${props => border-radius: ${props =>
props.type === 'community' ? `${props.size / 8}px` : '100%'}; props.type === 'community' ? `${props.size / 8}px` : '100%'};
display: inline-block;
height: ${props => (props.size ? `${props.size}px` : '32px')};
object-fit: cover; object-fit: cover;
background-color: ${th('colorBackground')}; width: ${props => (props.size ? `${props.size}px` : '32px')};
/* stylelint-disable-next-line order/properties-alphabetical-order */
${props => ${props =>
props.mobilesize && props.mobilesize &&
css` css`
...@@ -68,14 +73,15 @@ export const Img = styled(ReactImage)` ...@@ -68,14 +73,15 @@ export const Img = styled(ReactImage)`
` `
export const FallbackImg = styled.img` export const FallbackImg = styled.img`
display: inline-block; background-color: ${th('colorSecondary')};
width: ${props => (props.size ? `${props.size}px` : '32px')};
height: ${props => (props.size ? `${props.size}px` : '32px')};
border-radius: ${props => border-radius: ${props =>
props.type === 'community' ? `${props.size / 8}px` : '100%'}; props.type === 'community' ? `${props.size / 8}px` : '100%'};
display: inline-block;
height: ${props => (props.size ? `${props.size}px` : '32px')};
object-fit: cover; object-fit: cover;
background-color: ${th('colorSecondary')}; width: ${props => (props.size ? `${props.size}px` : '32px')};
/* stylelint-disable-next-line order/properties-alphabetical-order */
${props => ${props =>
props.mobilesize && props.mobilesize &&
css` css`
...@@ -87,13 +93,14 @@ export const FallbackImg = styled.img` ...@@ -87,13 +93,14 @@ export const FallbackImg = styled.img`
` `
export const LoadingImg = styled.div` export const LoadingImg = styled.div`
display: inline-block; background: ${th('colorSecondary')};
width: ${props => (props.size ? `${props.size}px` : '32px')};
height: ${props => (props.size ? `${props.size}px` : '32px')};
border-radius: ${props => border-radius: ${props =>
props.type === 'community' ? `${props.size / 8}px` : '100%'}; props.type === 'community' ? `${props.size / 8}px` : '100%'};
background: ${th('colorSecondary')}; display: inline-block;
height: ${props => (props.size ? `${props.size}px` : '32px')};
width: ${props => (props.size ? `${props.size}px` : '32px')};
/* stylelint-disable-next-line order/properties-alphabetical-order */
${props => ${props =>
props.mobilesize && props.mobilesize &&
css` css`
...@@ -105,17 +112,17 @@ export const LoadingImg = styled.div` ...@@ -105,17 +112,17 @@ export const LoadingImg = styled.div`
` `
export const OnlineIndicator = styled.span` export const OnlineIndicator = styled.span`
position: absolute; background: ${th('colorSuccess')};
width: 10px;
height: 10px;
border: 2px solid border: 2px solid
${props => ${props =>
props.onlineBorderColor props.onlineBorderColor
? props.onlineBorderColor(props.theme) ? props.onlineBorderColor(props.theme)
: th('colorTextReverse')}; : th('colorTextReverse')};
background: ${th('colorSuccess')};
border-radius: 5px; border-radius: 5px;
bottom: 0; bottom: 0;
height: 10px;
position: absolute;
right: 0; right: 0;
width: 10px;
z-index: 1; z-index: 1;
` `
/* eslint-disable react/destructuring-assignment */
/* /*
Actions arose from current designs (like the Appbar) where we had to blend Actions arose from current designs (like the Appbar) where we had to blend
links and buttons, but make them appear the same. links and buttons, but make them appear the same.
...@@ -37,6 +39,7 @@ const ActionButton = styled.button` ...@@ -37,6 +39,7 @@ const ActionButton = styled.button`
min-width: 0; min-width: 0;
padding: 0; padding: 0;
/* stylelint-disable-next-line order/properties-alphabetical-order */
${common}; ${common};
` `
......
/* eslint-disable react/prop-types */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable consistent-return */
// @flow // @flow
import React from 'react' import React from 'react'
import { MentionsInput, Mention } from 'react-mentions' import { MentionsInput, Mention } from 'react-mentions'
...@@ -48,6 +52,7 @@ const sortSuggestions = (a, b, queryString) => { ...@@ -48,6 +52,7 @@ const sortSuggestions = (a, b, queryString) => {
const CustomMentionsInput = props => { const CustomMentionsInput = props => {
const client = useApolloClient() const client = useApolloClient()
const searchUsers = async (queryString, callback) => { const searchUsers = async (queryString, callback) => {
const staticSuggestions = !props.staticSuggestions const staticSuggestions = !props.staticSuggestions
? [] ? []
......
/* eslint-disable react/prop-types */
import React from 'react' import React from 'react'
import { UserAvatar } from '../../../component-avatar/src' import { UserAvatar } from '../../../component-avatar/src'
......
...@@ -21,14 +21,14 @@ export const MentionsInputStyle = { ...@@ -21,14 +21,14 @@ export const MentionsInputStyle = {
} }
export const StyledMentionSuggestion = styled.div` export const StyledMentionSuggestion = styled.div`
display: flex;
padding: 8px 12px;
align-items: center; align-items: center;
background: ${props => background: ${props =>
props.focused ? th('colorBackgroundHue') : th('colorBackground')}; props.focused ? th('colorBackgroundHue') : th('colorBackground')};
min-width: 156px;
line-height: 1.3;
border-bottom: 1px solid ${th('colorBorder')}; border-bottom: 1px solid ${th('colorBorder')};
display: flex;
line-height: 1.3;
min-width: 156px;
padding: 8px 12px;
` `
export const MentionContent = styled.div` export const MentionContent = styled.div`
...@@ -37,19 +37,23 @@ export const MentionContent = styled.div` ...@@ -37,19 +37,23 @@ export const MentionContent = styled.div`
` `
export const MentionName = styled.span` export const MentionName = styled.span`
color: ${props => (props.focused ? th('colorPrimary') : th('colorText'))};
font-size: 14px;
font-weight: 500;
margin-left: 12px; margin-left: 12px;
width: calc(184px - 62px); width: calc(184px - 62px);
/* stylelint-disable-next-line order/properties-alphabetical-order */
${Truncate}; ${Truncate};
font-size: 14px;
font-weight: 500;
color: ${props => (props.focused ? th('colorPrimary') : th('colorText'))};
` `
export const MentionUsername = styled.span` export const MentionUsername = styled.span`
margin-left: 12px; color: ${props => (props.focused ? th('colorPrimary') : th('colorWarning'))};
font-size: 13px; font-size: 13px;
font-weight: 400; font-weight: 400;
margin-left: 12px;
width: calc(184px - 62px); width: calc(184px - 62px);
/* stylelint-disable-next-line order/properties-alphabetical-order */
${Truncate}; ${Truncate};
color: ${props => (props.focused ? th('colorPrimary') : th('colorWarning'))};
` `
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