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

Prettier: CI/CD, Remove deprecated options #3260

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ jobs:

- name: Report Test Renderer size
run: yarn run analyze-test

- name: Check formatting
run: yarn run format
Comment on lines +44 to +45
Copy link
Contributor Author

@satelllte satelllte May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optionally, this can be moved earlier: before or after "Check lint" step

6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/
coverage/
node_modules/
.yarn/
*.gltf
*.mdx
Copy link
Contributor Author

@satelllte satelllte May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignored MDX files, because semi rule set to false and it adds semicolons at the beginning of root-level JSX code.

For example, this:

import { PerspectiveCamera } from '@react-three/drei'
<Canvas>
  <PerspectiveCamera makeDefault manual />
</Canvas>

gets replaced by this:

import { PerspectiveCamera } from '@react-three/drei'
;<Canvas>
  <PerspectiveCamera makeDefault manual />
</Canvas>

2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"singleQuote": true,
"tabWidth": 2,
"printWidth": 120,
"jsxBracketSameLine": true,
"bracketSameLine": true,
"endOfLine": "auto"
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"vers": "yarn changeset version",
"codegen:eslint": "cd packages/eslint-plugin && yarn codegen",
"analyze-fiber": "cd packages/fiber && npm publish --dry-run",
"analyze-test": "cd packages/test-renderer && npm publish --dry-run"
"analyze-test": "cd packages/test-renderer && npm publish --dry-run",
"format": "prettier --check .",
"format:fix": "prettier --write ."
},
"devDependencies": {
"@babel/core": "7.17.8",
Expand Down
27 changes: 16 additions & 11 deletions packages/fiber/tests/core/events.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,16 @@ describe('events', () => {
const handlePointerLeave = jest.fn()

/* This component lets us unmount the event-handling object */
function PointerCaptureTest(props: { hasMesh: boolean, manualRelease?: boolean }) {
function PointerCaptureTest(props: { hasMesh: boolean; manualRelease?: boolean }) {
return (
<Canvas>
{props.hasMesh && (
<mesh onPointerDown={handlePointerDown} onPointerMove={handlePointerMove} onPointerUp={props.manualRelease ? handlePointerUp : undefined} onPointerLeave={handlePointerLeave} onPointerEnter={handlePointerEnter}>
<mesh
onPointerDown={handlePointerDown}
onPointerMove={handlePointerMove}
onPointerUp={props.manualRelease ? handlePointerUp : undefined}
onPointerLeave={handlePointerLeave}
onPointerEnter={handlePointerEnter}>
<boxGeometry args={[2, 2]} />
<meshBasicMaterial />
</mesh>
Expand Down Expand Up @@ -350,9 +355,9 @@ describe('events', () => {

/* testing-utils/react's fireEvent wraps the event like React does, so it doesn't match how our event handlers are called in production, so we call dispatchEvent directly. */
await act(async () => canvas.dispatchEvent(moveIn))
expect(handlePointerEnter).toHaveBeenCalledTimes(1);
expect(handlePointerMove).toHaveBeenCalledTimes(1);
expect(handlePointerEnter).toHaveBeenCalledTimes(1)
expect(handlePointerMove).toHaveBeenCalledTimes(1)

const down = new PointerEvent('pointerdown', { pointerId })
Object.defineProperty(down, 'offsetX', { get: () => 577 })
Object.defineProperty(down, 'offsetY', { get: () => 480 })
Expand All @@ -362,11 +367,11 @@ describe('events', () => {
// If we move the pointer now, when it is captured, it should raise the onPointerMove event even though the pointer is not over the element,
// and NOT raise the onPointerLeave event.
await act(async () => canvas.dispatchEvent(moveOut))
expect(handlePointerMove).toHaveBeenCalledTimes(2);
expect(handlePointerLeave).not.toHaveBeenCalled();
expect(handlePointerMove).toHaveBeenCalledTimes(2)
expect(handlePointerLeave).not.toHaveBeenCalled()

await act(async () => canvas.dispatchEvent(moveIn))
expect(handlePointerMove).toHaveBeenCalledTimes(3);
expect(handlePointerMove).toHaveBeenCalledTimes(3)

const up = new PointerEvent('pointerup', { pointerId })
Object.defineProperty(up, 'offsetX', { get: () => 577 })
Expand All @@ -377,11 +382,11 @@ describe('events', () => {
await act(async () => canvas.dispatchEvent(lostpointercapture))

// The pointer is still over the element, so onPointerLeave should not have been called.
expect(handlePointerLeave).not.toHaveBeenCalled();
expect(handlePointerLeave).not.toHaveBeenCalled()

// The element pointer should no longer be captured, so moving it away should call onPointerLeave.
await act(async () => canvas.dispatchEvent(moveOut));
expect(handlePointerEnter).toHaveBeenCalledTimes(1);
await act(async () => canvas.dispatchEvent(moveOut))
expect(handlePointerEnter).toHaveBeenCalledTimes(1)
expect(handlePointerLeave).toHaveBeenCalledTimes(1)
})
})
Expand Down