Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta: fix more linter warnings #3757

Merged
merged 1 commit into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ module.exports = {
'object-shorthand': ['error', 'always'],
'strict': 'off',
'key-spacing': 'off',
'max-classes-per-file': ['error', 2],
'react/no-unknown-property': ['error', {
ignore: svgPresentationAttributes,
}],

// rules we want to enforce
'array-callback-return': 'error',
Expand Down Expand Up @@ -79,7 +83,6 @@ module.exports = {
'global-require': ['warn'],
'import/no-unresolved': ['warn'],
'import/order': ['warn'],
'max-classes-per-file': ['warn', 2],
'no-mixed-operators': ['warn'],
'no-param-reassign': ['warn'],
'no-redeclare': ['warn'],
Expand All @@ -98,9 +101,6 @@ module.exports = {
'react/prefer-stateless-function': 'error',
'react/sort-comp': 'error',
'react/style-prop-object': 'error',
'react/no-unknown-property': ['error', {
ignore: svgPresentationAttributes,
}],

// accessibility
'jsx-a11y/alt-text': 'error',
Expand Down
4 changes: 2 additions & 2 deletions bin/upload-to-cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async function main (packageName, version) {
// version should only be a positional arg and semver string
// this deals with usage like `npm run uploadcdn uppy -- --force`
// where we force push a local build
if (version && version.startsWith('-')) version = undefined
if (version?.startsWith('-')) version = undefined // eslint-disable-line no-param-reassign

const s3 = new AWS.S3({
credentials: new AWS.Credentials({
Expand All @@ -118,7 +118,7 @@ async function main (packageName, version) {

const remote = !!version
if (!remote) {
// eslint-disable-next-line import/no-dynamic-require
// eslint-disable-next-line import/no-dynamic-require, global-require, no-param-reassign
version = require(`../packages/${packageName}/package.json`).version
}

Expand Down
14 changes: 7 additions & 7 deletions e2e/clients/dashboard-tus/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import Url from '@uppy/url'
import '@uppy/core/dist/style.css'
import '@uppy/dashboard/dist/style.css'

const companionUrl = 'http://localhost:3020'
const uppy = new Uppy()
.use(Dashboard, { target: '#app', inline: true })
.use(Tus, { endpoint: 'https://tusd.tusdemo.net/files', onShouldRetry })
.use(Url, { target: Dashboard, companionUrl })
.use(Unsplash, { target: Dashboard, companionUrl })

function onShouldRetry (err, retryAttempt, options, next) {
if (err?.originalResponse?.getStatus() === 418) {
return true
}
return next(err)
}

const companionUrl = 'http://localhost:3020'
const uppy = new Uppy()
.use(Dashboard, { target: '#app', inline: true })
.use(Tus, { endpoint: 'https://tusd.tusdemo.net/files', onShouldRetry })
.use(Url, { target: Dashboard, companionUrl })
.use(Unsplash, { target: Dashboard, companionUrl })

// Keep this here to access uppy in tests
window.uppy = uppy
3 changes: 3 additions & 0 deletions e2e/cypress/support/createFakeFile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
declare global {
namespace Cypress {
interface Chainable {
// eslint-disable-next-line no-use-before-define
createFakeFile: typeof createFakeFile;
}
}
Expand All @@ -14,7 +15,9 @@ interface File {
}

export function createFakeFile (name?: string, type?: string, b64?: string): File {
// eslint-disable-next-line no-param-reassign
if (!b64) b64 = 'PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg=='
// eslint-disable-next-line no-param-reassign
if (!type) type = 'image/svg+xml'

// https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/core/types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { expectError, expectType } from 'tsd'
import DefaultStore from '@uppy/store-default'
import Uppy, { UIPlugin } from '..'
Expand Down
67 changes: 34 additions & 33 deletions packages/@uppy/react-native/file-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,39 @@ import selectImage from './selectImage.js'
import selectDocument from './selectDocument.js'
import Provider from './provider.js'

const styles = StyleSheet.create({
providerList: {
flex: 1,
marginTop: 22,
justifyContent: 'center',
},
providerButton: {
alignItems: 'center',
backgroundColor: '#0077cc',
marginBottom: 15,
marginLeft: 50,
marginRight: 50,
padding: 10,
borderRadius: 5,
},
providerButtonText: {
color: '#fff',
},
cancelButton: {
alignItems: 'center',
borderWidth: 1,
borderColor: '#0077cc',
marginBottom: 15,
marginLeft: 50,
marginRight: 50,
padding: 10,
borderRadius: 5,
},
cancelButtonText: {
color: '#0077cc',
},
})

export default class UppyReactNativeFilePicker extends React.Component {
constructor () {
super()
Expand Down Expand Up @@ -147,6 +180,7 @@ export default class UppyReactNativeFilePicker extends React.Component {
})
this.props.onRequestClose()
}}
// eslint-disable-next-line react/jsx-props-no-spreading
{...this.props}
/>
) : (
Expand All @@ -156,36 +190,3 @@ export default class UppyReactNativeFilePicker extends React.Component {
)
}
}

const styles = StyleSheet.create({
providerList: {
flex: 1,
marginTop: 22,
justifyContent: 'center',
},
providerButton: {
alignItems: 'center',
backgroundColor: '#0077cc',
marginBottom: 15,
marginLeft: 50,
marginRight: 50,
padding: 10,
borderRadius: 5,
},
providerButtonText: {
color: '#fff',
},
cancelButton: {
alignItems: 'center',
borderWidth: 1,
borderColor: '#0077cc',
marginBottom: 15,
marginLeft: 50,
marginRight: 50,
padding: 10,
borderRadius: 5,
},
cancelButtonText: {
color: '#0077cc',
},
})
28 changes: 15 additions & 13 deletions packages/@uppy/react-native/file-picker/instagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ import {
import Instagram from '@uppy/instagram'

function getQueryParamValueFromUrl (name, url) {
// eslint-disable-next-line no-param-reassign
name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]')
const regexS = `[\\?&]${name}=([^&#]*)`
const regex = new RegExp(regexS)
const results = regex.exec(url)
return results == null ? null : results[1]
}

const styles = StyleSheet.create({
container: {
justifyContent: 'center',
flex: 1,
paddingTop: 30,
},
item: {
justifyContent: 'center',
alignItems: 'center',
height: 100,
},
})

// how instagram provider can be render, not ready
export default class UppyRNInstagram extends React.Component {
constructor () {
Expand Down Expand Up @@ -60,6 +74,7 @@ export default class UppyRNInstagram extends React.Component {
uppy.removePlugin(this.plugin)
}

// eslint-disable-next-line class-methods-use-this
renderGrid (items) {
return (
<View style={styles.container}>
Expand Down Expand Up @@ -96,16 +111,3 @@ export default class UppyRNInstagram extends React.Component {
return this.renderInstagram()
}
}

const styles = StyleSheet.create({
container: {
justifyContent: 'center',
flex: 1,
paddingTop: 30,
},
item: {
justifyContent: 'center',
alignItems: 'center',
height: 100,
},
})
48 changes: 24 additions & 24 deletions packages/@uppy/react-native/file-picker/provider-grid.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
import React from 'react'
import { StyleSheet, View, Text } from 'react-native'
import { FlatGrid } from 'react-native-super-grid'
import { FlatGrid } from 'react-native-super-grid' // eslint-disable-line import/no-unresolved

const styles = StyleSheet.create({
gridView: {
marginTop: 20,
flex: 1,
},
itemContainer: {
justifyContent: 'flex-end',
borderRadius: 5,
padding: 10,
height: 150,
},
itemName: {
fontSize: 16,
color: '#fff',
fontWeight: '600',
},
itemCode: {
fontWeight: '600',
fontSize: 12,
color: '#fff',
},
})

// test grid, can be used for instagram
export default class Example extends React.Component {
Expand Down Expand Up @@ -36,26 +59,3 @@ export default class Example extends React.Component {
)
}
}

const styles = StyleSheet.create({
gridView: {
marginTop: 20,
flex: 1,
},
itemContainer: {
justifyContent: 'flex-end',
borderRadius: 5,
padding: 10,
height: 150,
},
itemName: {
fontSize: 16,
color: '#fff',
fontWeight: '600',
},
itemCode: {
fontWeight: '600',
fontSize: 12,
color: '#fff',
},
})
2 changes: 2 additions & 0 deletions packages/@uppy/react-native/file-picker/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import Url from './url.js'
export default class UppyRNProvider extends React.Component {
render () {
if (this.props.providerID === 'Url') {
// eslint-disable-next-line react/jsx-props-no-spreading
return <Url {...this.props} />
}
// return this.renderInstagram()
return undefined
}
}
3 changes: 2 additions & 1 deletion packages/@uppy/react-native/file-picker/selectDocument.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as DocumentPicker from 'expo-document-picker'
import * as DocumentPicker from 'expo-document-picker' // eslint-disable-line import/no-unresolved

function selectDocumentWithExpo () {
return DocumentPicker.getDocumentAsync({
Expand All @@ -7,6 +7,7 @@ function selectDocumentWithExpo () {
if (!result.cancelled && result.type !== 'cancel') {
return result
}
return undefined
})
}

Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/react-native/file-picker/selectImage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Using leading underscore so eslint compat plugin doesn't yell at us.
import * as _Permissions from 'expo-permissions'
import * as ImagePicker from 'expo-image-picker'
import * as _Permissions from 'expo-permissions' // eslint-disable-line import/no-unresolved
import * as ImagePicker from 'expo-image-picker' // eslint-disable-line import/no-unresolved

function selectImageWithExpo (options) {
return _Permissions.askAsync(_Permissions.CAMERA_ROLL)
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/react-native/file-picker/takePicture.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Using leading underscore so eslint compat plugin doesn't yell at us.
import * as _Permissions from 'expo-permissions'
import * as ImagePicker from 'expo-image-picker'
import * as _Permissions from 'expo-permissions' // eslint-disable-line import/no-unresolved
import * as ImagePicker from 'expo-image-picker' // eslint-disable-line import/no-unresolved

function takePictureWithExpo () {
return _Permissions.askAsync(_Permissions.CAMERA)
Expand Down
Loading