Skip to content

Commit

Permalink
meta: fix React linter rules (#5317)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Jul 9, 2024
1 parent 489ca6d commit 473e164
Show file tree
Hide file tree
Showing 26 changed files with 34 additions and 178 deletions.
59 changes: 13 additions & 46 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ module.exports = {
name: 'JSX',
message: 'Use h.JSX.Element, ComponentChild, or ComponentChildren from Preact',
},
{
name: 'React',
message: 'Import the value instead of relying on global.React.',
},
],
'import/extensions': ['error', 'ignorePackages'],
},
Expand All @@ -207,52 +211,7 @@ module.exports = {
'private/dev/*.js',
'private/release/*.js',
'private/remark-lint-uppy/*.js',

// Packages that have switched to ESM sources:
'packages/@uppy/audio/src/**/*.js',
'packages/@uppy/aws-s3-multipart/src/**/*.js',
'packages/@uppy/aws-s3/src/**/*.js',
'packages/@uppy/box/src/**/*.js',
'packages/@uppy/companion-client/src/**/*.js',
'packages/@uppy/compressor/src/**/*.js',
'packages/@uppy/core/src/**/*.js',
'packages/@uppy/dashboard/src/**/*.js',
'packages/@uppy/drag-drop/src/**/*.js',
'packages/@uppy/drop-target/src/**/*.js',
'packages/@uppy/dropbox/src/**/*.js',
'packages/@uppy/facebook/src/**/*.js',
'packages/@uppy/file-input/src/**/*.js',
'packages/@uppy/form/src/**/*.js',
'packages/@uppy/golden-retriever/src/**/*.js',
'packages/@uppy/google-drive/src/**/*.js',
'packages/@uppy/google-photos/src/**/*.js',
'packages/@uppy/image-editor/src/**/*.js',
'packages/@uppy/informer/src/**/*.js',
'packages/@uppy/instagram/src/**/*.js',
'packages/@uppy/locales/src/**/*.js',
'packages/@uppy/locales/template.js',
'packages/@uppy/onedrive/src/**/*.js',
'packages/@uppy/progress-bar/src/**/*.js',
'packages/@uppy/provider-views/src/**/*.js',
'packages/@uppy/react/src/**/*.js',
'packages/@uppy/redux-dev-tools/src/**/*.js',
'packages/@uppy/remote-sources/src/**/*.js',
'packages/@uppy/screen-capture/src/**/*.js',
'packages/@uppy/status-bar/src/**/*.js',
'packages/@uppy/store-default/src/**/*.js',
'packages/@uppy/store-redux/src/**/*.js',
'packages/@uppy/svelte/rollup.config.js',
'packages/@uppy/svelte/src/**/*.js',
'packages/@uppy/thumbnail-generator/src/**/*.js',
'packages/@uppy/transloadit/src/**/*.js',
'packages/@uppy/tus/src/**/*.js',
'packages/@uppy/unsplash/src/**/*.js',
'packages/@uppy/url/src/**/*.js',
'packages/@uppy/utils/src/**/*.js',
'packages/@uppy/vue/src/**/*.js',
'packages/@uppy/webcam/src/**/*.js',
'packages/@uppy/xhr-upload/src/**/*.js',
'packages/@uppy/zoom/src/**/*.js',
'packages/@uppy/!(companion|react-native)/**/*.js',
],
parser: 'espree',
parserOptions: {
Expand Down Expand Up @@ -287,6 +246,14 @@ module.exports = {
name: 'require',
message: 'Use import instead',
},
{
name: 'JSX',
message: 'Use h.JSX.Element, ComponentChild, or ComponentChildren from Preact',
},
{
name: 'React',
message: 'Import the value instead of relying on global.React.',
},
],
'import/extensions': ['error', 'ignorePackages'],
},
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/integration/dashboard-tus.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
runRemoteUrlImageUploadTest,
runRemoteUnsplashUploadTest,
} from './reusable-tests'
} from './reusable-tests.ts'

// NOTE: we have to use different files to upload per test
// because we are uploading to https://tusd.tusdemo.net,
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/integration/dashboard-xhr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
interceptCompanionUrlMetaRequest,
runRemoteUrlImageUploadTest,
runRemoteUnsplashUploadTest,
} from './reusable-tests'
} from './reusable-tests.ts'

describe('Dashboard with XHR', () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//

import { createFakeFile } from './createFakeFile'
import { createFakeFile } from './createFakeFile.ts'

Cypress.Commands.add('createFakeFile', createFakeFile)
2 changes: 1 addition & 1 deletion e2e/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import './commands.ts'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/compressor/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ CompressorPlugin.prototype.compress = async (blob: File) => {
}
}

// eslint-disable-next-line no-restricted-globals
const sampleImage = fs.readFileSync(
// eslint-disable-next-line no-restricted-globals
path.join(__dirname, '../../../../e2e/cypress/fixtures/images/image.jpg'),
)

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/core/src/Uppy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import InvalidPluginWithoutType from './mocks/invalidPluginWithoutType.ts'
import DeepFrozenStore from '../../../../e2e/cypress/fixtures/DeepFrozenStore.mjs'
import type { State } from './Uppy.ts'

// eslint-disable-next-line no-restricted-globals
const sampleImage = fs.readFileSync(
// eslint-disable-next-line no-restricted-globals
path.join(__dirname, '../../../../e2e/cypress/fixtures/images/image.jpg'),
)

Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/core/src/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expectTypeOf, test } from 'vitest'

import type { Body, InternalMetadata, Meta } from '@uppy/utils/lib/UppyFile'
import Uppy, { type UnknownPlugin } from './Uppy'
import UIPlugin, { type UIPluginOptions } from './UIPlugin'
import Uppy, { type UnknownPlugin } from './Uppy.ts'
import UIPlugin, { type UIPluginOptions } from './UIPlugin.ts'

interface Opts extends UIPluginOptions {
foo: string
Expand Down
6 changes: 4 additions & 2 deletions packages/@uppy/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ a versatile file encoding service.

<!-- eslint-disable react/state-in-constructor -->

```js
```jsx
/** @jsx React */
import React from 'react'
import Uppy from '@uppy/core'
import { DashboardModal } from '@uppy/react'
Expand All @@ -27,10 +28,11 @@ class Example extends React.Component {
state = { open: false }

render() {
const { open } = this.state
return (
<DashboardModal
uppy={uppy}
open={this.state.open}
open={open}
onRequestClose={this.handleClose}
/>
)
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/react/src/Dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createElement as h, Component } from 'react'
import type React from 'react'
import type { UnknownPlugin, Uppy } from '@uppy/core'
import DashboardPlugin from '@uppy/dashboard'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/react/src/DashboardModal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createElement as h, Component } from 'react'
import type React from 'react'
import DashboardPlugin, { type DashboardOptions } from '@uppy/dashboard'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { Uppy } from '@uppy/core'
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/react/src/useUppyEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { renderHook, act } from '@testing-library/react'

import Uppy from '@uppy/core'
import type { Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import { useUppyEvent } from '.'
import { useUppyEvent } from './index.ts'

describe('useUppyEvent', () => {
it('should return and update value with the correct type', () => {
Expand Down
11 changes: 0 additions & 11 deletions packages/@uppy/react/types/CommonTypes.d.ts

This file was deleted.

26 changes: 0 additions & 26 deletions packages/@uppy/react/types/Dashboard.d.ts

This file was deleted.

24 changes: 0 additions & 24 deletions packages/@uppy/react/types/DashboardModal.d.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/@uppy/react/types/DragDrop.d.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/@uppy/react/types/FileInput.d.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/@uppy/react/types/ProgressBar.d.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/@uppy/react/types/StatusBar.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/@uppy/react/types/useUppy.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/@uppy/vue/src/dashboard-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineComponent, ref, watch, h, type PropType } from 'vue'
import DashboardPlugin, { type DashboardOptions } from '@uppy/dashboard'
import { Uppy } from '@uppy/core'
import type { Meta, Body } from '../../utils/src/UppyFile.js'
import useUppy from './useUppy'
import useUppy from './useUppy.ts'

type DashboardModalOptions<M extends Meta, B extends Body> = Omit<
DashboardOptions<M, B> & { inline: false },
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/vue/src/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineComponent, ref, h, type PropType } from 'vue'
import DashboardPlugin, { type DashboardOptions } from '@uppy/dashboard'
import type { Uppy } from '@uppy/core'
import type { Meta, Body } from '../../utils/src/UppyFile.js'
import useUppy from './useUppy'
import useUppy from './useUppy.ts'

type DashboardInlineOptions<M extends Meta, B extends Body> = Omit<
DashboardOptions<M, B> & { inline: true },
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/vue/src/drag-drop.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineComponent, ref, h, type PropType } from 'vue'
import DragDropPlugin, { type DragDropOptions } from '@uppy/drag-drop'
import { Uppy } from '@uppy/core'
import useUppy from './useUppy'
import useUppy from './useUppy.ts'

export default defineComponent({
name: 'DragDrop',
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/vue/src/file-input.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineComponent, ref, h, type PropType } from 'vue'
import FileInputPlugin, { type FileInputOptions } from '@uppy/file-input'
import { Uppy } from '@uppy/core'
import useUppy from './useUppy'
import useUppy from './useUppy.ts'

export default defineComponent({
name: 'FileInput',
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/vue/src/progress-bar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineComponent, ref, h, type PropType } from 'vue'
import ProgressBarPlugin, { type ProgressBarOptions } from '@uppy/progress-bar'
import { Uppy } from '@uppy/core'
import useUppy from './useUppy'
import useUppy from './useUppy.ts'

export default defineComponent({
name: 'ProgressBar',
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/vue/src/status-bar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineComponent, ref, h, type PropType } from 'vue'
import StatusBarPlugin, { type StatusBarOptions } from '@uppy/status-bar'
import { Uppy } from '@uppy/core'
import useUppy from './useUppy'
import useUppy from './useUppy.ts'

export default defineComponent({
name: 'StatusBar',
Expand Down

0 comments on commit 473e164

Please sign in to comment.