Skip to content

Commit

Permalink
Merge pull request #371 from votingworks/foundation-fixes
Browse files Browse the repository at this point in the history
Foundation fixes
  • Loading branch information
beausmith authored May 18, 2019
2 parents ea9cb2d + f4e5611 commit 8aad636
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 41 deletions.
14 changes: 7 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,17 @@ module.exports = {
},
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off', // Want to use it, but it requires return types for all built-in React lifecycle methods.
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-null-keyword': 'on',
'no-unused-vars': 'off', // base rule must be disabled as it can report incorrect errors: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md#options
'@typescript-eslint/no-unused-vars': ['error', {
'vars': 'all'
}],
camelcase: 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
'no-unused-vars': 'off', // base rule must be disabled as it can report incorrect errors: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md#options
'@typescript-eslint/no-unused-vars': ['error', {
'vars': 'all'
}],
'no-null/no-null': 2, // TypeScript with strictNullChecks
'react/destructuring-assignment': 'off',
'react/jsx-boolean-value': [2, 'never'],
Expand All @@ -86,5 +83,8 @@ module.exports = {
},
],
strict: 0,
'@typescript-eslint/explicit-function-return-type': 'off', // Want to use it, but it requires return types for all built-in React lifecycle methods.
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-null-keyword': 'on',
},
}
9 changes: 7 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* Reset */
/* Allow selectors to be used multiple times in this file for grouping of concerns. */
/* stylelint-disable no-duplicate-selectors */

/* Reset */
html {
box-sizing: border-box;
line-height: 1;
Expand All @@ -11,6 +13,10 @@ html {
box-sizing: inherit;
}

body {
margin: 0;
}

table {
border-collapse: collapse;
}
Expand Down Expand Up @@ -51,7 +57,6 @@ body,
}

/* Typography */
/* stylelint-disable-next-line no-duplicate-selectors */
html {
background: #edeff0;
color: #263238;
Expand Down
2 changes: 1 addition & 1 deletion src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('loads election', () => {
})
window.localStorage.setItem(electionKey, JSON.stringify(electionSample))
const { getByText } = render(<App />)
getByText('Configure Ballot Marking Device')
getByText('Load Election Configuration File')
})
it(`App uses data from localStorage when set`, () => {
const ballotStyleId = electionSample.ballotStyles[0].id
Expand Down
2 changes: 1 addition & 1 deletion src/__snapshots__/AppSetElection.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ exports[`Sets election config file 1`] = `
class="c4"
>
<h1>
Configure Ballot Marking Device
Load Election Configuration File
</h1>
<p>
Drag and drop
Expand Down
5 changes: 2 additions & 3 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ interface Attrs extends HTMLButtonElement {
readonly type: string
}

// @ts-ignore: 'T' triggers noUnusedParameters, but must exist for this interface to be 'generic'.
export interface ButtonInterface<T> {
export interface ButtonInterface {
readonly danger?: boolean
readonly primary?: boolean
readonly fullWidth?: boolean
}

interface Props
extends ButtonInterface<{}>,
extends ButtonInterface,
React.PropsWithoutRef<JSX.IntrinsicElements['button']> {}

const buttonStyles = css<Props>`
Expand Down
2 changes: 1 addition & 1 deletion src/components/LinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Button, { ButtonInterface } from './Button'
import { ButtonEvent } from '../config/types'

interface Props
extends ButtonInterface<{}>,
extends ButtonInterface,
RouteComponentProps<{}>,
React.PropsWithoutRef<JSX.IntrinsicElements['button']> {}

Expand Down
2 changes: 1 addition & 1 deletion src/components/UploadConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class UploadConfig extends React.Component<Props, State> {
<p>Drop files here…</p>
) : (
<React.Fragment>
<h1>Configure Ballot Marking Device</h1>
<h1>Load Election Configuration File</h1>
<p>
Drag and drop <code>election.json</code> file here,
or click to browse for file.
Expand Down
50 changes: 25 additions & 25 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,7 @@ export interface Dictionary<T> {
export type InputEvent = React.FormEvent<EventTarget>
export type ButtonEvent = React.MouseEvent<HTMLButtonElement>

// UI
export type ScrollDirections = 'up' | 'down'
export interface ScrollShadows {
showBottomShadow: boolean
showTopShadow: boolean
}
export interface Scrollable {
isScrollable: boolean
}

// Election
// Candidates
export interface Candidate {
readonly id: string
readonly name: string
Expand All @@ -26,14 +16,6 @@ export interface Candidate {
}
export type OptionalCandidate = Candidate | undefined

// Votes
export type CandidateVote = Candidate[]
export type YesNoVote = 'yes' | 'no'
export type OptionalYesNoVote = YesNoVote | undefined
export type Vote = CandidateVote | YesNoVote
export type OptionalVote = Vote | undefined
export type VotesDict = Dictionary<Vote>

// Contests
export type ContestTypes = 'candidate' | 'yesno'
export interface Contest {
Expand Down Expand Up @@ -106,12 +88,13 @@ export interface ActivationData {
precinct: Precinct
}

export type TextSizeSetting = 0 | 1 | 2 | 3

export interface UserSettings {
textSize: TextSizeSetting
}
export type PartialUserSettings = Partial<UserSettings>
// Votes
export type CandidateVote = Candidate[]
export type YesNoVote = 'yes' | 'no'
export type OptionalYesNoVote = YesNoVote | undefined
export type Vote = CandidateVote | YesNoVote
export type OptionalVote = Vote | undefined
export type VotesDict = Dictionary<Vote>

// Ballot
export type UpdateVoteFunction = (contestId: string, vote: OptionalVote) => void
Expand Down Expand Up @@ -143,4 +126,21 @@ export interface AdminCardData extends CardData {
readonly h: string
}

// User Interface
export type ScrollDirections = 'up' | 'down'
export interface ScrollShadows {
showBottomShadow: boolean
showTopShadow: boolean
}
export interface Scrollable {
isScrollable: boolean
}

export type TextSizeSetting = 0 | 1 | 2 | 3

export interface UserSettings {
textSize: TextSizeSetting
}
export type PartialUserSettings = Partial<UserSettings>

export default {}

0 comments on commit 8aad636

Please sign in to comment.