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

Misc lint fixes #13631

Merged
merged 3 commits into from
May 15, 2024
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
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/animation/src/components/test/animationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ function createWrapperWithProps<T>(
Wrapper: React.FunctionComponent<T>,
props: T
) {
const WrapperWithProps = function ({ children }: PropsWithChildren<T>) {
return <Wrapper {...props}>{children}</Wrapper>;
};
const WrapperWithProps = ({ children }: PropsWithChildren<T>) => (
<Wrapper {...props}>{children}</Wrapper>
);
return WrapperWithProps;
}

Expand Down
32 changes: 15 additions & 17 deletions packages/animation/src/parts/createAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,28 @@ function createAnimation<T extends Keyframes>(
? {}
: getInitialStyleFromKeyframes(keyframes);

const AMPTarget: VoidFunctionComponent<AMPAnimationProps> = function ({
const AMPTarget: VoidFunctionComponent<AMPAnimationProps> = ({
children,
style = {},
}) {
return (
<WithAnimation
id={id}
className="animation-wrapper"
useClippingContainer={useClippingContainer}
style={style}
animationStyle={animationStyle}
>
{children}
</WithAnimation>
);
};
}) => (
<WithAnimation
id={id}
className="animation-wrapper"
useClippingContainer={useClippingContainer}
style={style}
animationStyle={animationStyle}
>
{children}
</WithAnimation>
);

const selector = targetLeafElement
? `#${id} [data-leaf-element="true"]`
: `#${id}`;

const AMPAnimation: VoidFunctionComponent = function () {
return <AnimationOutput config={{ selector, keyframes, ...timings }} />;
};
const AMPAnimation: VoidFunctionComponent = () => (
<AnimationOutput config={{ selector, keyframes, ...timings }} />
);

return {
id,
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/src/parts/effects/backgroundPan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import createAnimation from '../createAnimation';
import {
type AMPEffectTiming,
AnimationDirection,
AnimationType,
type AnimationType,
type Element,
FieldType,
} from '../../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/src/parts/effects/drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { DimensionableElement } from '@googleforcreators/units';
import createAnimation from '../createAnimation';
import {
type AMPEffectTiming,
AnimationType,
type AnimationType,
type Element,
FieldType,
type Keyframes,
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/src/parts/effects/pan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import createAnimation from '../createAnimation';
import {
type AMPEffectTiming,
AnimationDirection,
AnimationType,
type AnimationType,
type Element,
FieldType,
} from '../../types';
Expand Down
6 changes: 5 additions & 1 deletion packages/animation/src/parts/simple/blinkOn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
*/
import generateLookupMap from '../../utils/generateLookupMap';
import padArray from '../../utils/padArray';
import { type AMPEffectTiming, AnimationType, FieldType } from '../../types';
import {
type AMPEffectTiming,
type AnimationType,
FieldType,
} from '../../types';
import createAnimation from '../createAnimation';

const DEFAULT_BLINKS = 10;
Expand Down
6 changes: 5 additions & 1 deletion packages/animation/src/parts/simple/fade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
/**
* Internal dependencies
*/
import { type AMPEffectTiming, AnimationType, FieldType } from '../../types';
import {
type AMPEffectTiming,
type AnimationType,
FieldType,
} from '../../types';
import createAnimation from '../createAnimation';

const defaults: AMPEffectTiming = {
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/src/parts/simple/flip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
import {
type AMPEffectTiming,
AnimationType,
type AnimationType,
Axis,
FieldType,
Rotation,
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/src/parts/simple/floatOn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import {
type AMPEffectTiming,
AnimationDirection,
AnimationType,
type AnimationType,
FieldType,
} from '../../types';
import createAnimation from '../createAnimation';
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/src/parts/simple/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
import {
type AMPEffectTiming,
AnimationType,
type AnimationType,
type Element,
FieldType,
} from '../../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/src/parts/simple/spin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
import {
type AMPEffectTiming,
AnimationType,
type AnimationType,
type Element,
FieldType,
} from '../../types';
Expand Down
6 changes: 5 additions & 1 deletion packages/animation/src/parts/simple/zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
/**
* Internal dependencies
*/
import { type AMPEffectTiming, AnimationType, FieldType } from '../../types';
import {
type AMPEffectTiming,
type AnimationType,
FieldType,
} from '../../types';
import createAnimation from '../createAnimation';

const defaults: AMPEffectTiming = { fill: 'forwards', duration: 1000 };
Expand Down
2 changes: 0 additions & 2 deletions packages/animation/src/typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ declare global {
}
}
}

export {};
4 changes: 3 additions & 1 deletion packages/animation/src/utils/createKeyframeEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function createKeyframeEffect(
const convertedTimings: EffectTiming = {
...timings,
iterations:
timings.iterations === 'infinity' ? Infinity : timings.iterations,
timings.iterations === 'infinity'
? Number.POSITIVE_INFINITY
: timings.iterations,
};

return new KeyframeEffect(target, keyframes, convertedTimings);
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/src/utils/padArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

function padArray(values: number[], padCount: number) {
return values.map((val) => Array<number>(padCount).fill(val)).flat();
return values.flatMap((val) => Array<number>(padCount).fill(val));
}

export default padArray;
2 changes: 1 addition & 1 deletion packages/animation/src/utils/test/createKeyframeEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('createKeyframeEffect', () => {

createKeyframeEffect(element, keyframes, timings);
expect(mockKeyframeEffect).toHaveBeenCalledWith(element, keyframes, {
iterations: Infinity,
iterations: Number.POSITIVE_INFINITY,
});
});

Expand Down
6 changes: 3 additions & 3 deletions packages/commander/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
/**
* External dependencies
*/
import { mkdirSync, rmSync, existsSync } from 'fs';
import { relative } from 'path';
import { mkdirSync, rmSync, existsSync } from 'node:fs';
import { relative } from 'node:path';
import { Command } from 'commander';
import { inc as semverInc, type ReleaseType } from 'semver';

Expand Down Expand Up @@ -181,7 +181,7 @@ program
const pluginFilePath = `${PLUGIN_DIR}/${PLUGIN_FILE}`;
updateCdnUrl(
pluginFilePath,
version === 'main' ? version : parseInt(version)
version === 'main' ? version : Number.parseInt(version)
);

console.log(`Assets CDN URL successfully updated!`);
Expand Down
2 changes: 1 addition & 1 deletion packages/commander/src/utils/appendRevisionToVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* External dependencies
*/
import { execSync } from 'child_process';
import { execSync } from 'node:child_process';

/**
* Appends the current revision to the version number for nightly builds.
Expand Down
2 changes: 1 addition & 1 deletion packages/commander/src/utils/bundlePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* External dependencies
*/
import { dirname } from 'path';
import { dirname } from 'node:path';

/**
* Internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/commander/src/utils/copyFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* External dependencies
*/
import { execFileSync } from 'child_process';
import { execFileSync } from 'node:child_process';

/**
* Copies all files minuses ignored ones from source to target directory.
Expand Down
2 changes: 1 addition & 1 deletion packages/commander/src/utils/deleteExistingZipFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* External dependencies
*/
import { readdirSync, unlinkSync } from 'fs';
import { readdirSync, unlinkSync } from 'node:fs';

/**
* Removes all existing ZIP files in the build folder.
Expand Down
6 changes: 3 additions & 3 deletions packages/commander/src/utils/generateZipFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
/**
* External dependencies
*/
import { dirname, basename, join } from 'path';
import { execFileSync } from 'child_process';
import { existsSync, unlinkSync } from 'fs';
import { dirname, basename, join } from 'node:path';
import { execFileSync } from 'node:child_process';
import { existsSync, unlinkSync } from 'node:fs';

/**
* Generates a ZIP file.
Expand Down
2 changes: 1 addition & 1 deletion packages/commander/src/utils/getCurrentVersionNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* External dependencies
*/
import { readFileSync } from 'fs';
import { readFileSync } from 'node:fs';

const VERSION_REGEX = /\* Version:(.+)/;
const VERSION_CONSTANT_REGEX =
Expand Down
2 changes: 1 addition & 1 deletion packages/commander/src/utils/getIgnoredFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* External dependencies
*/
import { existsSync, lstatSync, readFileSync } from 'fs';
import { existsSync, lstatSync, readFileSync } from 'node:fs';

/**
* Returns a list of files that should be ignored based on the .distignore file.
Expand Down
2 changes: 1 addition & 1 deletion packages/commander/src/utils/resizeSvgPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function resizeSvgPath(x: number, y: number, path: string) {
.split(' ');
let coordIndex = 0;
return coords.reduce((acc, value) => {
const parsed = parseFloat(value);
const parsed = Number.parseFloat(value);
if (!isNaN(parsed)) {
const scaled = coordIndex % 2 === 0 ? parsed / x : parsed / y;
return `${acc} ${scaled.toFixed(6)}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
import appendRevisionToVersion from '../appendRevisionToVersion';

jest.mock('child_process', () => {
jest.mock('node:child_process', () => {
return {
execSync: () => '1234567',
};
Expand Down
6 changes: 3 additions & 3 deletions packages/commander/src/utils/test/bundlePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* External dependencies
*/
import { __setMockFiles } from 'fs';
import { __setMockFiles } from 'node:fs';

/**
* Internal dependencies
Expand All @@ -27,8 +27,8 @@ import generateZipFile from '../generateZipFile';
import getCurrentVersionNumber from '../getCurrentVersionNumber';
import deleteExistingZipFiles from '../deleteExistingZipFiles';

jest.mock('fs');
jest.mock('child_process');
jest.mock('node:fs');
jest.mock('node:child_process');

jest.mock('../generateZipFile');
jest.mock('../getCurrentVersionNumber');
Expand Down
4 changes: 2 additions & 2 deletions packages/commander/src/utils/test/copyFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
/**
* External dependencies
*/
import { execFileSync } from 'child_process';
import { execFileSync } from 'node:child_process';

/**
* Internal dependencies
*/
import copyFiles from '../copyFiles';

jest.mock('child_process');
jest.mock('node:child_process');

describe('copyFiles', () => {
it('should sync source files to target', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/commander/src/utils/test/createBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
/**
* External dependencies
*/
import { __setMockFiles } from 'fs';
import { __setMockFiles } from 'node:fs';

/**
* Internal dependencies
*/
import createBuild from '../createBuild';
import copyFiles from '../copyFiles';

jest.mock('fs');
jest.mock('node:fs');

jest.mock('../getIgnoredFiles', () => jest.fn(() => ['bar.txt', 'baz/']));
jest.mock('../copyFiles');
Expand Down
4 changes: 2 additions & 2 deletions packages/commander/src/utils/test/deleteExistingZipFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
/**
* External dependencies
*/
import { __setMockFiles, readdirSync } from 'fs';
import { __setMockFiles, readdirSync } from 'node:fs';

/**
* Internal dependencies
*/
import deleteExistingZipFiles from '../deleteExistingZipFiles';

jest.mock('fs');
jest.mock('node:fs');

describe('deleteExistingZipFiles', () => {
const MOCK_FILE_INFO = {
Expand Down
4 changes: 2 additions & 2 deletions packages/commander/src/utils/test/generateZipFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
/**
* External dependencies
*/
import { execFileSync } from 'child_process';
import { execFileSync } from 'node:child_process';

/**
* Internal dependencies
*/
import generateZipFile from '../generateZipFile';

jest.mock('child_process');
jest.mock('node:child_process');

describe('generateZipFile', () => {
it('should ZIP the web-stories directory', () => {
Expand Down
Loading
Loading