Skip to content

Commit

Permalink
Update to eslint 6.8.0 [appveyor githubissuedetail packagist] (badges…
Browse files Browse the repository at this point in the history
…#4489)

* update to eslint 6.8.0 and related packages

* Fixes for no-prototype-builtins

* Updates for explicit-function-return-type

* Add ignores for no-explicit-any

* update to eslint 6.8.0 and related packages

* Fixes for no-prototype-builtins

* Updates for explicit-function-return-type

* Add ignores for no-explicit-any

* package: activate eslint-config-standard

* apply updated eslint configuration

* lint: apply eslint feedback after rebase

* Update lockfile

* Update lockfile

* Restore missing deps

* Update lockfile

* Re-add eslint-plugin-node

* Add eslint-plugin-standard and eslint-plugin-react-hooks

* Clean lint

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
  • Loading branch information
znarf and paulmelnikow authored Feb 29, 2020
1 parent fe70e75 commit 0d8a2d5
Show file tree
Hide file tree
Showing 57 changed files with 679 additions and 505 deletions.
17 changes: 12 additions & 5 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
extends:
- standard-jsx
- standard
- standard-react
- plugin:@typescript-eslint/recommended
- prettier
- prettier/@typescript-eslint
- prettier/standard
- prettier/react
Expand Down Expand Up @@ -39,7 +40,6 @@ overrides:
es6: true
rules:
no-console: 'off'
'@typescript-eslint/no-var-requires': off

- files:
- '**/*.@(ts|tsx)'
Expand All @@ -48,8 +48,13 @@ overrides:
parser: '@typescript-eslint/parser'
rules:
# Argh.
'@typescript-eslint/explicit-function-return-type': 'off'
'@typescript-eslint/explicit-function-return-type':
['error', { 'allowExpressions': true }]
'@typescript-eslint/no-empty-function': 'error'
'@typescript-eslint/no-var-requires': 'error'
'@typescript-eslint/no-object-literal-type-assertion': 'off'
'@typescript-eslint/no-explicit-any': 'error'
'@typescript-eslint/ban-ts-ignore': 'off'

- files:
- core/**/*.ts
Expand Down Expand Up @@ -113,9 +118,9 @@ rules:
# Allow unused parameters. In callbacks, removing them seems to obscure
# what the functions are doing.
'@typescript-eslint/no-unused-vars': ['error', { 'args': 'none' }]
no-unused-vars: off
no-unused-vars: 'off'

'@typescript-eslint/no-var-requires': error
'@typescript-eslint/no-var-requires': 'off'

# These should be disabled by eslint-config-prettier, but are not.
no-extra-semi: 'off'
Expand Down Expand Up @@ -163,6 +168,8 @@ rules:

# Disable some from TypeScript.
'@typescript-eslint/camelcase': off
'@typescript-eslint/explicit-function-return-type': 'off'
'@typescript-eslint/no-empty-function': 'off'

react/jsx-sort-props: 'error'
react-hooks/rules-of-hooks: 'error'
Expand Down
6 changes: 3 additions & 3 deletions core/base-service/coalesce.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ describe('coalesce', function() {
given(null, [], {}).expect([])
given(null, undefined, 0, {}).expect(0)

const a = null,
c = 0,
d = 1
const a = null
const c = 0
const d = 1
let b
given(a, b, c, d).expect(0)
})
Expand Down
6 changes: 6 additions & 0 deletions core/base-service/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class NotFound extends ShieldsRuntimeError {
get name() {
return 'NotFound'
}

get defaultPrettyMessage() {
return defaultNotFoundError
}
Expand All @@ -82,6 +83,7 @@ class InvalidResponse extends ShieldsRuntimeError {
get name() {
return 'InvalidResponse'
}

get defaultPrettyMessage() {
return 'invalid'
}
Expand All @@ -107,6 +109,7 @@ class Inaccessible extends ShieldsRuntimeError {
get name() {
return 'Inaccessible'
}

get defaultPrettyMessage() {
return 'inaccessible'
}
Expand All @@ -131,6 +134,7 @@ class ImproperlyConfigured extends ShieldsRuntimeError {
get name() {
return 'ImproperlyConfigured'
}

get defaultPrettyMessage() {
return 'improperly configured'
}
Expand All @@ -156,6 +160,7 @@ class InvalidParameter extends ShieldsRuntimeError {
get name() {
return 'InvalidParameter'
}

get defaultPrettyMessage() {
return 'invalid parameter'
}
Expand All @@ -180,6 +185,7 @@ class Deprecated extends ShieldsRuntimeError {
get name() {
return 'Deprecated'
}

get defaultPrettyMessage() {
return 'no longer available'
}
Expand Down
4 changes: 2 additions & 2 deletions core/base-service/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function validate(
}
const options = { abortEarly: false }
if (allowAndStripUnknownKeys) {
options['allowUnknown'] = true
options['stripUnknown'] = true
options.allowUnknown = true
options.stripUnknown = true
}
const { error, value } = schema.validate(data, options)
if (error) {
Expand Down
2 changes: 1 addition & 1 deletion core/server/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function setRoutes({ rateLimit }, { server, metricInstance }) {
.split(/[/-]/)
.slice(0, 3)
.join('')
const referer = req.headers['referer']
const referer = req.headers.referer

if (ipRateLimit.isBanned(ip, req, res)) {
metricInstance.noteRateLimitExceeded('ip')
Expand Down
2 changes: 1 addition & 1 deletion core/server/server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('The server', function() {
})

it('should allow strings for port', async function() {
//fixes #4391 - This allows the app to be run using iisnode, which uses a named pipe for the port.
// fixes #4391 - This allows the app to be run using iisnode, which uses a named pipe for the port.
const pipeServer = createTestServer({
port: '\\\\.\\pipe\\9c137306-7c4d-461e-b7cf-5213a3939ad6',
})
Expand Down
5 changes: 5 additions & 0 deletions core/token-pooling/token-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,23 @@ class Token {
get id() {
return this._id
}

get data() {
return this._data
}

get usesRemaining() {
return this._usesRemaining
}

get nextReset() {
return this._nextReset
}

get isValid() {
return this._isValid
}

get isFrozen() {
return this._isFrozen
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/badge-examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function Example({
onClick: (example: RenderableExample, isSuggestion: boolean) => void
exampleData: RenderableExample
isBadgeSuggestion: boolean
}) {
function handleClick() {
}): JSX.Element {
function handleClick(): void {
onClick(exampleData, isBadgeSuggestion)
}

Expand Down Expand Up @@ -106,7 +106,7 @@ export function BadgeExamples({
areBadgeSuggestions: boolean
baseUrl?: string
onClick: (exampleData: RenderableExample, isSuggestion: boolean) => void
}) {
}): JSX.Element {
return (
<ExampleTable>
<tbody>
Expand Down
14 changes: 11 additions & 3 deletions frontend/components/category-headings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ export function CategoryHeading({
category: { id, name },
}: {
category: Category
}) {
}): JSX.Element {
return (
<Link to={`/category/${id}`}>
<H3 id={id}>{name}</H3>
</Link>
)
}

export function CategoryHeadings({ categories }: { categories: Category[] }) {
export function CategoryHeadings({
categories,
}: {
categories: Category[]
}): JSX.Element {
return (
<div>
{categories.map(category => (
Expand Down Expand Up @@ -61,7 +65,11 @@ const StyledNav = styled.nav`
}
`

export function CategoryNav({ categories }: { categories: Category[] }) {
export function CategoryNav({
categories,
}: {
categories: Category[]
}): JSX.Element {
return (
<StyledNav>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function Badge({
height = '20px',
clickable = false,
...rest
}: BadgeProps) {
}: BadgeProps): JSX.Element {
return (
<BadgeWrapper clickable={clickable} display={display} height={height}>
{src ? <img alt={alt} src={src} {...rest} /> : nonBreakingSpace}
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/customizer/builder-common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function BuilderContainer({
children,
}: {
children: JSX.Element[] | JSX.Element
}) {
}): JSX.Element {
return (
<BuilderOuterContainer>
<BuilderInnerContainer>{children}</BuilderInnerContainer>
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/customizer/copied-content-indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function _CopiedContentIndicator(
children: JSX.Element | JSX.Element[]
},
ref: React.Ref<CopiedContentIndicatorHandle>
) {
): JSX.Element {
const [pose, setPose] = useState('hidden')

useImperativeHandle(ref, () => ({
Expand All @@ -50,7 +50,7 @@ function _CopiedContentIndicator(
},
}))

function handlePoseComplete() {
function handlePoseComplete(): void {
if (pose === 'effectStart') {
setPose('effectEnd')
} else {
Expand Down
14 changes: 7 additions & 7 deletions frontend/components/customizer/customizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Customizer({
initialStyle?: string
isPrefilled: boolean
link?: string
}) {
}): JSX.Element {
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/35572
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/28884#issuecomment-471341041
const indicatorRef = useRef<
Expand All @@ -48,12 +48,12 @@ export default function Customizer({
const [markup, setMarkup] = useState()
const [message, setMessage] = useState()

function generateBuiltBadgeUrl() {
function generateBuiltBadgeUrl(): string {
const suffix = queryString ? `?${queryString}` : ''
return `${baseUrl || getBaseUrlFromWindowLocation()}${path}${suffix}`
}

function renderLivePreview() {
function renderLivePreview(): JSX.Element {
// There are some usability issues here. It would be better if the message
// changed from a validation error to a loading message once the
// parameters were filled in, and also switched back to loading when the
Expand All @@ -75,7 +75,7 @@ export default function Customizer({
)
}

async function copyMarkup(markupFormat: MarkupFormat) {
async function copyMarkup(markupFormat: MarkupFormat): Promise<void> {
const builtBadgeUrl = generateBuiltBadgeUrl()
const markup = generateMarkup({
badgeUrl: builtBadgeUrl,
Expand All @@ -98,7 +98,7 @@ export default function Customizer({
}
}

function renderMarkupAndLivePreview() {
function renderMarkupAndLivePreview(): JSX.Element {
return (
<div>
{renderLivePreview()}
Expand All @@ -124,7 +124,7 @@ export default function Customizer({
}: {
path: string
isComplete: boolean
}) {
}): void {
setPath(path)
setPathIsComplete(isComplete)
}
Expand All @@ -135,7 +135,7 @@ export default function Customizer({
}: {
queryString: string
isComplete: boolean
}) {
}): void {
setQueryString(queryString)
}

Expand Down
12 changes: 6 additions & 6 deletions frontend/components/customizer/path-builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function constructPath({
}: {
tokens: Token[]
namedParams: { [k: string]: string }
}) {
}): { path: string; isComplete: boolean } {
let isComplete = true
const path = tokens
.map(token => {
Expand Down Expand Up @@ -123,7 +123,7 @@ export default function PathBuilder({
isComplete: boolean
}) => void
isPrefilled: boolean
}) {
}): JSX.Element {
const [tokens] = useState(() => parse(pattern))
const [namedParams, setNamedParams] = useState(() =>
isPrefilled
Expand All @@ -150,7 +150,7 @@ export default function PathBuilder({

function handleTokenChange({
target: { name, value },
}: ChangeEvent<HTMLInputElement | HTMLSelectElement>) {
}: ChangeEvent<HTMLInputElement | HTMLSelectElement>): void {
setNamedParams({
...namedParams,
[name]: value,
Expand All @@ -161,7 +161,7 @@ export default function PathBuilder({
literal: string,
tokenIndex: number,
pathContainsOnlyLiterals: boolean
) {
): JSX.Element {
return (
<PathBuilderColumn
key={`${tokenIndex}-${literal}`}
Expand All @@ -177,7 +177,7 @@ export default function PathBuilder({
)
}

function renderNamedParamInput(token: Key) {
function renderNamedParamInput(token: Key): JSX.Element {
const { pattern } = token
const name = `${token.name}`
const options = patternToOptions(pattern)
Expand Down Expand Up @@ -219,7 +219,7 @@ export default function PathBuilder({
token: Key,
tokenIndex: number,
namedParamIndex: number
) {
): JSX.Element {
const { delimiter, optional } = token
const name = `${token.name}`

Expand Down
Loading

0 comments on commit 0d8a2d5

Please sign in to comment.