Skip to content

Commit

Permalink
Fix ESLint warnings and errors from updating
Browse files Browse the repository at this point in the history
  • Loading branch information
amazon-meaisiah committed Mar 13, 2021
1 parent b4a3943 commit 3540428
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 61 deletions.
14 changes: 4 additions & 10 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
# because ESLint configs frequently need to be JS.

# top-level and lambda function specific
/node_modules
**/node_modules
/coverage
/lambdas/static-asset-uploader/build/
/lambdas/coverage/
/lambdas/backend/node_modules/
/lambdas/catalog-updater/node_modules/
/lambdas/cfn-cognito-user-pools-client-settings/node_modules/
/lambdas/cfn-cognito-user-pools-domain/node_modules/
/lambdas/cognito-user-pools-confirmation-strategy/node_modules/
/lambdas/dump-v3-account-data/node_modules/
/lambdas/listener/node_modules/
/lambdas/shared/node_modules/
/lambdas/static-asset-uploader/node_modules/
!/lambdas/common-layer/nodejs/node_modules

# devportal specific

Expand Down
13 changes: 12 additions & 1 deletion dev-portal/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@

module.exports = {
extends: ['react-app', '../.eslintrc.js'],
}
overrides: [
{
files: ['.eslintrc.js', './*.js'],
parserOptions: {
sourceType: 'script'
},
rules: {
strict: ['warn', 'global']
}
}
]
}
12 changes: 6 additions & 6 deletions dev-portal/example-deployer.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Here's how you set this up:
//
//
// 1. Replace YOUR_LAMBDA_ARTIFACTS_BUCKET_NAME with the name of the bucket you created in step 3
// of the dev setup.
// 2. Replace 'CUSTOM_PREFIX' in the properties that have it with your name, your org name, or some
Expand All @@ -9,11 +9,11 @@
// 3. Set any other optional parameters as desired. For the DynamoDB tables, their names must be
// unique to all DynamoDB tables within your account.
// 4. Save the file.
//
//
// Note: these configuration parameters are *not* the same as the SAM template parameters - the names differ and the behavior in many areas also differ. Furthermore, some SAM template parameters like `StaticAssetsRebuildToken` are handled automatically internally and cannot be configured.
//
//
// See the "Deployer configuration" section of `BUILDING.md` for documentation on each of the parameters.
"use strict"
'use strict'

module.exports = {
// Optional, but recommended if you have multiple active AWS CLI profiles.
Expand All @@ -24,7 +24,7 @@ module.exports = {
stackName: 'CUSTOM_PREFIX-dev-portal',
siteAssetsBucket: 'CUSTOM_PREFIX-dev-portal-static-assets',
apiAssetsBucket: 'CUSTOM_PREFIX-dev-portal-artifacts',
cognitoDomainName: 'CUSTOM_PREFIX-auth',
cognitoDomainName: 'CUSTOM_PREFIX-auth'

// Optional, but highly encouraged if you have such a domain ready. Not all of these may apply.
// customDomainName: 'developer.domain.example',
Expand All @@ -36,4 +36,4 @@ module.exports = {
// Toggle this any time the edge lambda or its replicator lambda need updated. You will be told in
// the migration instructions to do so if you need to.
// edgeLambdaResetToken: 'reset',
}
}
8 changes: 4 additions & 4 deletions dev-portal/example-dev-deployer.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// See `example-deployer.config.js` in this directory for setup instructions and the "Deployer
// configuration" section of `BUILDING.md` for documentation on each of the parameters.
//
//
// It's recommended you track your live deployments here. You can change this any time you want to
// do a fresh deployment.
// Live: 0
"use strict"
'use strict'

const n = 0

Expand All @@ -30,10 +30,10 @@ module.exports = {
staticAssetRebuildMode: 'overwrite-content',

// Set development mode for local use.
developmentMode: true,
developmentMode: true

// Toggle this any time the edge lambda or its replicator lambda are updated. In general, unless
// either you're modifying them yourself or they were changed upstream and you just pulled those
// changes, you shouldn't need to do anything about this value.
// edgeLambdaResetToken: 'reset',
}
}
2 changes: 2 additions & 0 deletions dev-portal/src/components/Admin/Accounts/AccountsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const AccountsTable = ({
directionIndex: 0
})

/* eslint-disable brace-style */
useEffect(() => {
const filterableColumns = columns.filter(column => column.filtering)
setFilterableColumns(filterableColumns)
Expand All @@ -109,6 +110,7 @@ export const AccountsTable = ({
setFilter(filter => ({ ...filter, column: NO_FILTER_COLUMN }))
}
}, [columns, filter])
/* eslint-enable brace-style */

/**
* Sets `accountsView` to the filtered and sorted subset of `props.accounts`.
Expand Down
8 changes: 4 additions & 4 deletions dev-portal/src/components/MessageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ export const MessageList = ({ messages }) =>
export const useMessages = () => {
const [state, setState] = useState({
messages: [],
nextId: 0,
nextId: 0
})

const sendMessage = renderWithDismiss => {
const id = state.nextId
const dismiss = () => {
setState(state => ({
...state,
messages: state.messages.filter(message => message.id !== id),
messages: state.messages.filter(message => message.id !== id)
}))
}
const newMessage = {
render: () => renderWithDismiss(dismiss),
id: state.nextId,
id: state.nextId
}
setState(state => ({
messages: [...state.messages, newMessage],
nextId: state.nextId + 1,
nextId: state.nextId + 1
}))
}

Expand Down
6 changes: 3 additions & 3 deletions dev-portal/src/pages/Admin/Accounts/AdminAccounts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const AdminAccounts = () => {

const refreshAccounts = () =>
AccountService.fetchAdminAccounts().then(accounts =>
setAccounts(accounts),
setAccounts(accounts)
)

// Initial load
Expand All @@ -21,7 +21,7 @@ const AdminAccounts = () => {
}, [])

const onSelectAccount = useCallback(account => setSelectedAccount(account), [
setSelectedAccount,
setSelectedAccount
])

return (
Expand All @@ -32,7 +32,7 @@ const AdminAccounts = () => {
columns={[
AccountsTableColumns.EmailAddress,
AccountsTableColumns.DatePromoted,
AccountsTableColumns.Promoter,
AccountsTableColumns.Promoter
]}
loading={loading}
selectedAccount={selectedAccount}
Expand Down
26 changes: 13 additions & 13 deletions dev-portal/src/pages/Admin/Accounts/PendingInvites.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Header,
Input,
Message,
Modal,
Modal
} from 'semantic-ui-react'

import * as MessageList from 'components/MessageList'
Expand All @@ -20,21 +20,21 @@ const PendingInvites = () => {
const [loading, setLoading] = useState(true)
const [selectedAccount, setSelectedAccount] = useState(undefined)
const [isCreateModalOpen, openCreateModal, closeCreateModal] = useBoolean(
false,
false
)
const [isDeleteModalOpen, openDeleteModal, closeDeleteModal] = useBoolean(
false,
false
)
const [messages, sendMessage] = MessageList.useMessages()
const [
createModalMessages,
sendCreateModalMessage,
clearCreateModalMessages,
clearCreateModalMessages
] = MessageList.useMessages()

const refreshAccounts = () =>
AccountService.fetchPendingInviteAccounts().then(accounts =>
setAccounts(accounts),
setAccounts(accounts)
)

// Initial load
Expand All @@ -44,7 +44,7 @@ const PendingInvites = () => {

const onSelectAccount = useCallback(
account => setSelectedAccount(account),
[],
[]
)

const onConfirmCreate = useCallback(
Expand Down Expand Up @@ -77,8 +77,8 @@ const PendingInvites = () => {
sendMessage,
sendCreateModalMessage,
clearCreateModalMessages,
closeCreateModal,
],
closeCreateModal
]
)

const onConfirmResend = useCallback(async () => {
Expand Down Expand Up @@ -128,7 +128,7 @@ const PendingInvites = () => {
columns={[
AccountsTableColumns.EmailAddress,
AccountsTableColumns.DateInvited,
AccountsTableColumns.Inviter,
AccountsTableColumns.Inviter
]}
loading={loading}
selectedAccount={selectedAccount}
Expand Down Expand Up @@ -166,7 +166,7 @@ const TableActions = ({
canResend,
onClickResend,
canDelete,
onClickDelete,
onClickDelete
}) => (
<Button.Group>
<Button
Expand All @@ -186,7 +186,7 @@ const TableActions = ({
// - The whole regexp was made case-insensitive to avoid the need for `A-Za-z` in classes.
// - As we're only testing, I replaced all the non-capturing groups with capturing ones.
const validEmailRegex =
/^[\w.!#$%&'*+\/=?^`{|}~-]+@[^_\W]([a-z\d-]{0,61}[^_\W])?(\.[^_\W]([a-z\d-]{0,61}[^_\W])?)*$/i
/^[\w.!#$%&'*+/=?^`{|}~-]+@[^_\W]([a-z\d-]{0,61}[^_\W])?(\.[^_\W]([a-z\d-]{0,61}[^_\W])?)*$/i

/*
* Note: `onConfirm` should return a boolean indicating whether the creation
Expand All @@ -198,7 +198,7 @@ const CreateInviteModal = ({ onConfirm, open, onClose, messages }) => {
const isEmailValid = useMemo(() => validEmailRegex.test(email), [email])
const onChangeEmailAddress = useCallback(
(_event, { value }) => setEmail(value),
[],
[]
)
const onClickCreate = useCallback(async () => {
setLoading(true)
Expand All @@ -210,7 +210,7 @@ const CreateInviteModal = ({ onConfirm, open, onClose, messages }) => {
setLoading(false)
}
}, [onConfirm, email])

// If the user stops typing, but the email is invalid, show the invalid email message as a hint
// for why they can't proceed. Don't make the timeout so short that it'd annoy a slow typer,
// though.
Expand Down
1 change: 0 additions & 1 deletion dev-portal/src/pages/Admin/SideNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { isAdmin } from 'services/self'

import { observer } from 'mobx-react'

import { Link } from 'react-router-dom'
import { Menu } from 'semantic-ui-react'
import Sidebar from 'components/Sidebar/Sidebar'
import SidebarHeader from 'components/Sidebar/SidebarHeader'
Expand Down
Loading

0 comments on commit 3540428

Please sign in to comment.