Skip to content

Commit 2500f5b

Browse files
committed
Enforce styling rules
1 parent 0f89ec1 commit 2500f5b

File tree

21 files changed

+210
-138
lines changed

21 files changed

+210
-138
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ indent_size = 2
1010
charset = utf-8
1111
trim_trailing_whitespace = true
1212
max_line_length = 80
13+
quote_type = single
1314

1415
[*.{js,ts}]
1516
quote_type = single

.eslintrc.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,44 @@ module.exports = {
33
browser: true,
44
commonjs: true,
55
es2020: true,
6-
node: true
6+
node: true,
77
},
88
globals: {
9-
strapi: true
9+
strapi: true,
1010
},
1111
extends: [
12+
'eslint:recommended',
1213
'plugin:react/recommended',
13-
'standard',
14-
'plugin:cypress/recommended'
14+
'plugin:cypress/recommended',
15+
'plugin:prettier/recommended',
1516
],
1617
parserOptions: {
1718
ecmaFeatures: {
18-
jsx: true
19+
jsx: true,
1920
},
20-
ecmaVersion: 11
21+
ecmaVersion: 11,
2122
},
22-
ignorePatterns: ['playground/plugins'],
23-
plugins: [
24-
'react'
25-
],
23+
ignorePatterns: ['playground'],
24+
plugins: ['react', 'prettier'],
2625
settings: {
2726
react: {
28-
version: 'detect'
29-
}
27+
version: 'detect',
28+
},
3029
},
3130
rules: {
32-
'react/jsx-indent': 'error',
33-
'react/jsx-indent-props': [2, 2],
3431
'cypress/no-unnecessary-waiting': 'off',
3532
'react/prop-types': 'off',
3633
'react/jsx-closing-bracket-location': [2, 'tag-aligned'],
3734
'no-unused-vars': ['error', { varsIgnorePattern: '^omit.*$' }],
38-
'array-callback-return': 'off'
39-
}
35+
'array-callback-return': 'off',
36+
'arrow-parens': ['error', 'as-needed'],
37+
'prettier/prettier': [
38+
'error',
39+
{
40+
quoteProps: 'consistent',
41+
semi: false,
42+
arrowParens: 'avoid',
43+
},
44+
],
45+
},
4046
}

admin/src/components/Collections.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const ReloadButton = styled(Button)`
2525
const headers = [
2626
{
2727
name: 'Name',
28-
value: 'name'
28+
value: 'name',
2929
},
3030
{
3131
name: 'In MeiliSearch',
@@ -41,8 +41,8 @@ const headers = [
4141
},
4242
{
4343
name: 'Hooks',
44-
value: 'hooked'
45-
}
44+
value: 'hooked',
45+
},
4646
]
4747

4848
const Collections = ({ updateCredentials }) => {
@@ -113,7 +113,7 @@ const Collections = ({ updateCredentials }) => {
113113
// Remove a collection from MeiliSearch
114114
const removeCollection = async ({ name: collection }) => {
115115
const res = await request(`/${pluginId}/indexes/${collection}/`, {
116-
method: 'DELETE'
116+
method: 'DELETE',
117117
})
118118
if (res.error) errorNotifications(res)
119119
else successNotification({ message: `${collection} collection is removed from MeiliSearch!`, duration: 4000 })

admin/src/components/Credentials.js

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const Credentials = ({ setUpdatedCredentials }) => {
1515

1616
useEffect(() => {
1717
strapi.lockApp()
18-
async function fillMeilisearchCredentials () {
18+
async function fillMeilisearchCredentials() {
1919
const { apiKey, host } = await request(`/${pluginId}/credentials/`, {
20-
method: 'GET'
20+
method: 'GET',
2121
})
2222
setApiKey(apiKey)
2323
setHost(host)
@@ -31,47 +31,51 @@ const Credentials = ({ setUpdatedCredentials }) => {
3131
method: 'POST',
3232
body: {
3333
host: msHost,
34-
apiKey: msApiKey
35-
}
34+
apiKey: msApiKey,
35+
},
3636
})
3737
strapi.notification.toggle({
3838
type: 'success',
3939
message: 'MeiliSearch Credentials Updated!',
40-
timeout: 4000
40+
timeout: 4000,
4141
})
4242
setApiKey(apiKey)
4343
setHost(host)
4444
setUpdatedCredentials(prev => !prev)
4545
}
4646

4747
return (
48-
<div className="col-md-12">
49-
<Wrapper>
50-
<Label htmlFor="MSHost" message="MeiliSearch Host" />
51-
<InputText
52-
name="MSHost"
53-
onChange={({ target: { value } }) => {
54-
setHost(value)
55-
}}
56-
placeholder="Host"
57-
type="text"
58-
value={msHost}
59-
/>
60-
<Label htmlFor="MSApiKey" message="MeiliSearch Api Key" />
61-
<InputText
62-
name="MSApiKey"
63-
onChange={({ target: { value } }) => {
64-
setApiKey(value)
65-
}}
66-
placeholder="apiKey"
67-
type="text"
68-
value={msApiKey}
69-
/>
70-
<Button className="credentials_button" onClick={addMeilisearchCredentials} style={{ marginTop: '20px' }}>
71-
Add
72-
</Button>
73-
</Wrapper>
74-
</div>
48+
<div className="col-md-12">
49+
<Wrapper>
50+
<Label htmlFor="MSHost" message="MeiliSearch Host" />
51+
<InputText
52+
name="MSHost"
53+
onChange={({ target: { value } }) => {
54+
setHost(value)
55+
}}
56+
placeholder="Host"
57+
type="text"
58+
value={msHost}
59+
/>
60+
<Label htmlFor="MSApiKey" message="MeiliSearch Api Key" />
61+
<InputText
62+
name="MSApiKey"
63+
onChange={({ target: { value } }) => {
64+
setApiKey(value)
65+
}}
66+
placeholder="apiKey"
67+
type="text"
68+
value={msApiKey}
69+
/>
70+
<Button
71+
className="credentials_button"
72+
onClick={addMeilisearchCredentials}
73+
style={{ marginTop: '20px' }}
74+
>
75+
Add
76+
</Button>
77+
</Wrapper>
78+
</div>
7579
)
7680
}
7781

admin/src/containers/App/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ import HomePage from '../HomePage'
1717
const theme = {
1818
colors: {
1919
backgroundColor: '#ffffff',
20-
shadows: '#e3e9f3'
21-
}
20+
shadows: '#e3e9f3',
21+
},
2222
}
2323

2424
const App = () => {
2525
return (
26-
<ThemeProvider theme={theme} >
27-
<Switch>
28-
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
29-
<Route component={NotFound} />
30-
</Switch>
31-
</ThemeProvider>
26+
<ThemeProvider theme={theme}>
27+
<Switch>
28+
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
29+
<Route component={NotFound} />
30+
</Switch>
31+
</ThemeProvider>
3232
)
3333
}
3434

admin/src/containers/HomePage/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ const HomePage = () => {
1616
const { formatMessage } = useGlobalContext()
1717

1818
return (
19-
<div className="container-fluid" style={{ padding: '18px 30px 66px 30px' }}>
20-
<Header
21-
title={{
22-
label: formatMessage({ id: getTrad('plugin.name') })
23-
}}
24-
content={formatMessage({ id: getTrad('header.description') })}
25-
/>
26-
<Credentials setUpdatedCredentials={setUpdatedCredentials} />
27-
<Collections updateCredentials={updateCredentials} />
28-
</div>
19+
<div className="container-fluid" style={{ padding: '18px 30px 66px 30px' }}>
20+
<Header
21+
title={{
22+
label: formatMessage({ id: getTrad('plugin.name') }),
23+
}}
24+
content={formatMessage({ id: getTrad('header.description') })}
25+
/>
26+
<Credentials setUpdatedCredentials={setUpdatedCredentials} />
27+
<Collections updateCredentials={updateCredentials} />
28+
</div>
2929
)
3030
}
3131

admin/src/containers/Initializer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Initializer = ({ updatePlugin }) => {
2020
}
2121

2222
Initializer.propTypes = {
23-
updatePlugin: PropTypes.func.isRequired
23+
updatePlugin: PropTypes.func.isRequired,
2424
}
2525

2626
export default Initializer

admin/src/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import lifecycles from './lifecycles'
66
import trads from './translations'
77

88
export default strapi => {
9-
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description
9+
const pluginDescription =
10+
pluginPkg.strapi.description || pluginPkg.description
1011
const icon = pluginPkg.strapi.icon
1112
const name = pluginPkg.strapi.name
1213

@@ -33,7 +34,7 @@ export default strapi => {
3334
icon,
3435
label: {
3536
id: `${pluginId}.plugin.name`,
36-
defaultMessage: name
37+
defaultMessage: name,
3738
},
3839
name,
3940
permissions: [
@@ -42,10 +43,10 @@ export default strapi => {
4243
// action: '', // the action name should be plugins::plugin-name.actionType
4344
// subject: null,
4445
// },
45-
]
46-
}
47-
]
48-
}
46+
],
47+
},
48+
],
49+
},
4950
}
5051

5152
return strapi.registerPlugin(plugin)

admin/src/lifecycles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
function lifecycles () {}
1+
function lifecycles() {}
22

33
export default lifecycles

admin/src/pluginId.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
const pluginPkg = require('../../package.json')
2-
const pluginId = pluginPkg.name.replace(
3-
/^strapi-plugin-/i,
4-
''
5-
)
2+
const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '')
63

74
module.exports = pluginId

0 commit comments

Comments
 (0)