Skip to content

Commit

Permalink
Upgrade linting to 2.0.0-0 (#3280)
Browse files Browse the repository at this point in the history
* Upgrade linting to 2.0.0-0

* Adjust so we can pass without error

* Fix linting

* Update header-blacklist.js

* Update index.js

* Update Uppy.js

* Update Components.js

* Update StatusBar.js

* Update Assembly.js

* Upgrade to linting 2.0.0 (final release)
  • Loading branch information
kvz committed Nov 9, 2021
1 parent 0dbec60 commit bfe6598
Show file tree
Hide file tree
Showing 70 changed files with 161 additions and 163 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -19,3 +19,4 @@ website/src/_posts/2021-03-*.md
website/src/_posts/2021-04-*.md
website/src/_posts/2021-05-*.md
website/src/_posts/2021-06-*.md
website/src/docs/react-dashboard.md
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -43,7 +43,6 @@ module.exports = {
rules: {
// transloadit rules we are actually ok with in the uppy repo
'import/extensions': 'off',
'no-await-in-loop': 'off',
'object-shorthand': ['error', 'always'],
'strict': 'off',
'key-spacing': 'off',
Expand Down Expand Up @@ -79,6 +78,7 @@ module.exports = {
'global-require': ['warn'],
'import/no-unresolved': ['warn'],
'import/order': ['warn'],
'max-classes-per-file': ['warn'],
'no-mixed-operators': ['warn'],
'no-param-reassign': ['warn'],
'no-redeclare': ['warn'],
Expand Down
1 change: 0 additions & 1 deletion bin/after-version-bump.js
Expand Up @@ -42,7 +42,6 @@ async function updateVersions (files, packageName) {
console.log('replacing', replacements, 'in', files.length, 'files')

for (const f of files) {
// eslint-disable-next-line no-await-in-loop
await replaceInFile(f, replacements)
}
}
Expand Down
14 changes: 7 additions & 7 deletions bin/build-bundle.js
Expand Up @@ -96,17 +96,17 @@ const methods = [
buildBundle(
'./packages/uppy/index.js',
'./packages/uppy/dist/uppy.js',
{ standalone: 'Uppy' }
{ standalone: 'Uppy' },
).then(minifyBundle),
buildBundle(
'./packages/uppy/bundle.js',
'./packages/uppy/dist/uppy.legacy.js',
{ standalone: 'Uppy (with polyfills)' }
{ standalone: 'Uppy (with polyfills)' },
).then(transpileDownForIE),
buildBundle(
'./packages/@uppy/robodog/bundle.js',
'./packages/@uppy/robodog/dist/robodog.js',
{ standalone: 'Robodog' }
{ standalone: 'Robodog' },
).then(minifyBundle),
]

Expand All @@ -118,17 +118,17 @@ glob.sync(localePackagePath).forEach((localePath) => {
buildBundle(
`./packages/@uppy/locales/src/${localeName}.js`,
`./packages/@uppy/locales/dist/${localeName}.min.js`,
{ minify: true }
)
{ minify: true },
),
)
})

// Add BUNDLE-README.MD
methods.push(
fs.promises.copyFile(
`${__dirname}/../BUNDLE-README.md`,
`./packages/uppy/dist/README.md`
)
`./packages/uppy/dist/README.md`,
),
)

Promise.all(methods).then(() => {
Expand Down
6 changes: 2 additions & 4 deletions bin/build-css.js
Expand Up @@ -23,7 +23,6 @@ function handleErr (err) {
async function compileCSS () {
const files = await glob('packages/{,@uppy/}*/src/style.scss')

/* eslint-disable no-await-in-loop */
for (const file of files) {
const importedFiles = new Set()
const scssResult = await renderScss({
Expand Down Expand Up @@ -78,7 +77,7 @@ async function compileCSS () {
await writeFile(outfile, postcssResult.css)
console.info(
chalk.green('✓ Built Uppy CSS:'),
chalk.magenta(path.relative(cwd, outfile))
chalk.magenta(path.relative(cwd, outfile)),
)

const minifiedResult = await postcss([
Expand All @@ -90,10 +89,9 @@ async function compileCSS () {
await writeFile(outfile.replace(/\.css$/, '.min.css'), minifiedResult.css)
console.info(
chalk.green('✓ Minified Bundle CSS:'),
chalk.magenta(path.relative(cwd, outfile).replace(/\.css$/, '.min.css'))
chalk.magenta(path.relative(cwd, outfile).replace(/\.css$/, '.min.css')),
)
}
/* eslint-enable no-await-in-loop */
}

compileCSS().then(() => {
Expand Down
4 changes: 2 additions & 2 deletions bin/build-lib.js
Expand Up @@ -34,7 +34,7 @@ async function buildLib () {
const metaMtime = Math.max(...metaMtimes)

const files = await glob(SOURCE)
/* eslint-disable no-await-in-loop, no-continue */
/* eslint-disable no-continue */
for (const file of files) {
if (IGNORE.test(file)) {
continue
Expand All @@ -60,7 +60,7 @@ async function buildLib () {
])
console.log(chalk.green('Compiled lib:'), chalk.magenta(libFile))
}
/* eslint-enable no-await-in-loop, no-continue */
/* eslint-enable no-continue */
}

console.log('Using Babel version:', require('@babel/core/package.json').version)
Expand Down
2 changes: 1 addition & 1 deletion bin/upload-to-cdn.js
Expand Up @@ -85,7 +85,7 @@ async function getLocalDistFiles (packagePath) {
files.map(async (f) => [
f,
await readFile(path.join(packagePath, 'dist', f)),
])
]),
)

return new Map(entries)
Expand Down
2 changes: 1 addition & 1 deletion examples/redux/main.js
Expand Up @@ -25,7 +25,7 @@ const reducer = combineReducers({

let enhancer = applyMiddleware(
uppyReduxStore.middleware(),
logger
logger,
)
if (typeof __REDUX_DEVTOOLS_EXTENSION__ !== 'undefined') {
// eslint-disable-next-line no-undef
Expand Down
8 changes: 4 additions & 4 deletions examples/transloadit-textarea/main.js
Expand Up @@ -26,7 +26,7 @@ class MarkdownTextarea {
this.uploadLine.classList.add('mdtxt-upload')

this.uploadLine.appendChild(
document.createTextNode('Upload an attachment')
document.createTextNode('Upload an attachment'),
)
}

Expand Down Expand Up @@ -111,7 +111,7 @@ class MarkdownTextarea {
// Was cancelled
if (result == null) return
this.insertAttachments(
this.matchFilesAndThumbs(result.results)
this.matchFilesAndThumbs(result.results),
)
}).catch((err) => {
console.error(err)
Expand All @@ -130,7 +130,7 @@ class MarkdownTextarea {
// Was cancelled
if (result == null) return
this.insertAttachments(
this.matchFilesAndThumbs(result.results)
this.matchFilesAndThumbs(result.results),
)
}).catch((err) => {
console.error(err)
Expand All @@ -140,7 +140,7 @@ class MarkdownTextarea {
}

const textarea = new MarkdownTextarea(
document.querySelector('#new textarea')
document.querySelector('#new textarea'),
)
textarea.install()

Expand Down
7 changes: 4 additions & 3 deletions package.json
Expand Up @@ -68,17 +68,18 @@
"deep-freeze": "^0.0.1",
"disc": "^1.3.3",
"eslint": "^8.0.0",
"eslint-config-transloadit": "^1.2.0",
"eslint-config-transloadit": "^2.0.0",
"eslint-plugin-compat": "^3.8.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.0.0",
"eslint-plugin-jsdoc": "^36.0.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-markdown": "^2.2.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-import": "^0.0.1",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"events.once": "^2.0.2",
"exorcist": "^2.0.0",
"fakefile": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3-multipart/src/MultipartUploader.js
Expand Up @@ -254,7 +254,7 @@ class MultipartUploader {

if (typeof result?.presignedUrls !== 'object') {
throw new TypeError(
'AwsS3/Multipart: Got incorrect result from `prepareUploadParts()`, expected an object `{ presignedUrls }`.'
'AwsS3/Multipart: Got incorrect result from `prepareUploadParts()`, expected an object `{ presignedUrls }`.',
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3-multipart/src/index.js
Expand Up @@ -294,7 +294,7 @@ module.exports = class AwsS3Multipart extends BasePlugin {
protocol: 's3-multipart',
size: file.data.size,
metadata: file.meta,
}
},
).then((res) => {
this.uppy.setFileState(file.id, { serverToken: res.token })
file = this.uppy.getFile(file.id)
Expand Down
8 changes: 4 additions & 4 deletions packages/@uppy/aws-s3-multipart/src/index.test.js
Expand Up @@ -28,7 +28,7 @@ describe('AwsS3Multipart', () => {
const opts = {}

expect(() => awsS3Multipart.opts.createMultipartUpload(file)).toThrow(
err
err,
)
expect(() => awsS3Multipart.opts.listParts(file, opts)).toThrow(err)
expect(() => awsS3Multipart.opts.completeMultipartUpload(file, opts)).toThrow(err)
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('AwsS3Multipart', () => {

it('Calls the prepareUploadParts function totalChunks / limit times', async () => {
const scope = nock(
'https://bucket.s3.us-east-2.amazonaws.com'
'https://bucket.s3.us-east-2.amazonaws.com',
).defaultReplyHeaders({
'access-control-allow-method': 'PUT',
'access-control-allow-origin': '*',
Expand Down Expand Up @@ -103,15 +103,15 @@ describe('AwsS3Multipart', () => {
await core.upload()

expect(
awsS3Multipart.opts.prepareUploadParts.mock.calls.length
awsS3Multipart.opts.prepareUploadParts.mock.calls.length,
).toEqual(1)

scope.done()
})

it('Calls prepareUploadParts with a Math.ceil(limit / 2) minimum, instead of one at a time for the remaining chunks after the first limit batch', async () => {
const scope = nock(
'https://bucket.s3.us-east-2.amazonaws.com'
'https://bucket.s3.us-east-2.amazonaws.com',
).defaultReplyHeaders({
'access-control-allow-method': 'PUT',
'access-control-allow-origin': '*',
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/src/index.js
Expand Up @@ -140,7 +140,7 @@ module.exports = class AwsS3 extends BasePlugin {
const metadata = Object.fromEntries(
this.opts.metaFields
.filter(key => file.meta[key] != null)
.map(key => [`metadata[${key}]`, file.meta[key].toString()])
.map(key => [`metadata[${key}]`, file.meta[key].toString()]),
)

const query = new URLSearchParams({ filename, type, ...metadata })
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion-client/src/Provider.js
Expand Up @@ -29,7 +29,7 @@ module.exports = class Provider extends RequestClient {

if (this.companionKeysParams) {
authHeaders['uppy-credentials-params'] = btoa(
JSON.stringify({ params: this.companionKeysParams })
JSON.stringify({ params: this.companionKeysParams }),
)
}
return { ...headers, ...authHeaders }
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion-client/src/Socket.test.js
Expand Up @@ -43,7 +43,7 @@ describe('Socket', () => {
expect(
new UppySocket({
target: 'foo',
}) instanceof UppySocket
}) instanceof UppySocket,
)
})

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/companion.js
Expand Up @@ -237,7 +237,7 @@ const validateConfig = (companionOptions) => {
fs.accessSync(`${companionOptions.filePath}`, fs.R_OK | fs.W_OK) // eslint-disable-line no-bitwise
} catch (err) {
throw new Error(
`No access to "${companionOptions.filePath}". Please ensure the directory exists and with read/write permissions.`
`No access to "${companionOptions.filePath}". Please ensure the directory exists and with read/write permissions.`,
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/server/Uploader.js
Expand Up @@ -403,7 +403,7 @@ class Uploader {
logger.debug(
`${combinedBytes} ${bytesTotal} ${formattedPercentage}%`,
'uploader.total.progress',
this.shortToken
this.shortToken,
)

if (this._paused || this.uploadStopped) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/server/controllers/s3.js
Expand Up @@ -248,7 +248,7 @@ module.exports = function s3 (config) {
Body: '',
Expires: config.expires,
})
})
}),
).then((urls) => {
const presignedUrls = Object.create(null)
for (let index = 0; index < partNumbersArray.length; index++) {
Expand Down
3 changes: 1 addition & 2 deletions packages/@uppy/companion/src/server/header-blacklist.js
Expand Up @@ -40,8 +40,7 @@ const forbiddenRegex = [/^proxy-.*$/, /^sec-.*$/]
*/
const isForbiddenHeader = (header) => {
const headerLower = header.toLowerCase()
const forbidden
= forbiddenNames.indexOf(headerLower) >= 0
const forbidden = forbiddenNames.indexOf(headerLower) >= 0
|| forbiddenRegex.findIndex((regex) => regex.test(headerLower)) >= 0

if (forbidden) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/server/helpers/request.js
Expand Up @@ -98,7 +98,7 @@ module.exports.getRedirectEvaluator = (rawRequestURL, blockPrivateIPs) => {
const shouldRedirect = redirectURL.protocol === requestURL.protocol
if (!shouldRedirect) {
logger.info(
`blocking redirect from ${requestURL} to ${redirectURL}`, 'redirect.protection'
`blocking redirect from ${requestURL} to ${redirectURL}`, 'redirect.protection',
)
}

Expand Down
Expand Up @@ -173,7 +173,7 @@ class Drive extends Provider {
sharedDrives,
directory,
query,
isRoot && !query.cursor // we can only show it on the first page request, or else we will have duplicates of it
isRoot && !query.cursor, // we can only show it on the first page request, or else we will have duplicates of it
)
}

Expand Down
Expand Up @@ -142,8 +142,7 @@ class Unsplash extends SearchProvider {
error (err, resp) {
if (resp) {
const fallbackMessage = `request to Unsplash returned ${resp.statusCode}`
const msg
= resp.body && resp.body.errors ? `${resp.body.errors}` : fallbackMessage
const msg = resp.body && resp.body.errors ? `${resp.body.errors}` : fallbackMessage
return new ProviderApiError(msg, resp.statusCode)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/server/s3-client.js
Expand Up @@ -35,7 +35,7 @@ module.exports = (companionOptions) => {
s3ClientOptions.credentials = new AWS.Credentials(
s3ProviderOptions.key,
s3ProviderOptions.secret,
s3ProviderOptions.sessionToken
s3ProviderOptions.sessionToken,
)
}
s3Client = new S3(s3ClientOptions)
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/standalone/index.js
Expand Up @@ -119,7 +119,7 @@ module.exports = function server (inputCompanionOptions = {}) {
if (companionOptions.redisUrl) {
const RedisStore = require('connect-redis')(session)
const redisClient = redis.client(
merge({ url: companionOptions.redisUrl }, companionOptions.redisOptions)
merge({ url: companionOptions.redisUrl }, companionOptions.redisOptions),
)
sessionOptions.store = new RedisStore({ client: redisClient })
}
Expand Down
9 changes: 4 additions & 5 deletions packages/@uppy/core/src/Uppy.js
Expand Up @@ -419,7 +419,7 @@ class Uppy {
const inProgressFiles = files.filter(({ progress }) => !progress.uploadComplete && progress.uploadStarted)
const newFiles = files.filter((file) => !file.progress.uploadStarted)
const startedFiles = files.filter(
file => file.progress.uploadStarted || file.progress.preprocess || file.progress.postprocess
file => file.progress.uploadStarted || file.progress.preprocess || file.progress.postprocess,
)
const uploadStartedFiles = files.filter((file) => file.progress.uploadStarted)
const pausedFiles = files.filter((file) => file.isPaused)
Expand Down Expand Up @@ -1305,10 +1305,9 @@ class Uppy {
}

updateOnlineStatus () {
const online
= typeof window.navigator.onLine !== 'undefined'
? window.navigator.onLine
: true
const online = typeof window.navigator.onLine !== 'undefined'
? window.navigator.onLine
: true
if (!online) {
this.emit('is-offline')
this.info(this.i18n('noInternetConnection'), 'error', 0)
Expand Down

0 comments on commit bfe6598

Please sign in to comment.