Skip to content

Commit

Permalink
style: format code with prettier 3 with reduced changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Oct 20, 2023
1 parent 4d5b250 commit ecead99
Show file tree
Hide file tree
Showing 28 changed files with 64 additions and 108 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
2 changes: 1 addition & 1 deletion packages/adapter-next/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugins": ["prettier-plugin-jsdoc"],
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"jsdocCommentLineStrategy": "keep",
"tsdoc": true,
"printWidth": 80,
"useTabs": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nuxt/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugins": ["prettier-plugin-jsdoc"],
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"jsdocCommentLineStrategy": "keep",
"tsdoc": true,
"printWidth": 80,
"useTabs": true,
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-nuxt/src/hooks/documentation-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const documentationRead: DocumentationReadHook<PluginOptions> = async (
model.id
}-uid-\${route.params.uid}]\`, () =>
prismic.client.getByUID("${model.id}", route.params.uid${
isTypeScriptProject ? " as string" : ""
})
isTypeScriptProject ? " as string" : ""
})
);
useHead({
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nuxt2/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugins": ["prettier-plugin-jsdoc"],
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"jsdocCommentLineStrategy": "keep",
"tsdoc": true,
"printWidth": 80,
"useTabs": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-sveltekit/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugins": ["prettier-plugin-jsdoc"],
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"jsdocCommentLineStrategy": "keep",
"tsdoc": true,
"printWidth": 80,
"useTabs": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/init/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugins": ["prettier-plugin-jsdoc"],
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"jsdocCommentLineStrategy": "keep",
"tsdoc": true,
"printWidth": 80,
"useTabs": true,
Expand Down
5 changes: 2 additions & 3 deletions packages/init/src/lib/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ type promptArgs<
export const prompt = async <TReturn, TProperty extends string = string>(
question: promptArgs<TReturn, TProperty>,
): Promise<Record<TProperty, TReturn>> => {
const answers: Record<TProperty, TReturn> = await prompts<TProperty>(
question,
);
const answers: Record<TProperty, TReturn> =
await prompts<TProperty>(question);

if (!Object.keys(answers).length) {
process.exit(130);
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugins": ["prettier-plugin-jsdoc"],
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"jsdocCommentLineStrategy": "keep",
"tsdoc": true,
"printWidth": 80,
"useTabs": true,
Expand Down
10 changes: 4 additions & 6 deletions packages/manager/src/managers/slices/SlicesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,8 @@ export class SlicesManager extends BaseManager {
mocks: mockSlice({ model: args.model }),
};

const { errors: updateSliceHookErrors } = await this.updateSliceMocks(
updateSliceMocksArgs,
);
const { errors: updateSliceHookErrors } =
await this.updateSliceMocks(updateSliceMocksArgs);

return {
errors: [...hookResult.errors, ...updateSliceHookErrors],
Expand Down Expand Up @@ -368,9 +367,8 @@ export class SlicesManager extends BaseManager {
mocks: updatedMocks,
};

const { errors: updateSliceMocksHookResult } = await this.updateSliceMocks(
updateSliceMocksArgs,
);
const { errors: updateSliceMocksHookResult } =
await this.updateSliceMocks(updateSliceMocksArgs);

return {
errors: [...hookResult.errors, ...updateSliceMocksHookResult],
Expand Down
3 changes: 2 additions & 1 deletion packages/manager/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type { APIEndpoints } from "./constants/API_ENDPOINTS";
* @typeParam TSliceMachinePluginOptions - User-provided options for the plugin.
*/
export type SliceMachineConfigPluginRegistration<
TSliceMachinePluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,
TSliceMachinePluginOptions extends
SliceMachinePluginOptions = SliceMachinePluginOptions,
> =
| string
| {
Expand Down
5 changes: 2 additions & 3 deletions packages/manager/test/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ vi.mock("fs/promises", async () => {
};

const memfs: typeof import("memfs") = await vi.importActual("memfs");
const _fs: typeof import("node:fs/promises") = await vi.importActual(
"node:fs/promises",
);
const _fs: typeof import("node:fs/promises") =
await vi.importActual("node:fs/promises");

const readFile = escapeOnigurumaMethod(
_fs.readFile,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-kit/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugins": ["prettier-plugin-jsdoc"],
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"jsdocCommentLineStrategy": "keep",
"tsdoc": true,
"printWidth": 80,
"useTabs": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import * as path from "node:path";
import * as plugin from "./__fixtures__/plugin";

const createRequireMock =
vi.fn<Parameters<typeof import("node:module")["createRequire"]>>();
vi.fn<Parameters<(typeof import("node:module"))["createRequire"]>>();

vi.mock("module", async () => {
const actual: typeof import("node:module") = await vi.importActual(
"node:module",
);
const actual: typeof import("node:module") =
await vi.importActual("node:module");

return {
...actual,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ScreenDimensions } from "@lib/models/common/Screenshots";

function useSimulatorClient(): readonly [
SimulatorClient | undefined,
RefCallback<HTMLIFrameElement>
RefCallback<HTMLIFrameElement>,
] {
const [client, setClient] = useState<SimulatorClient | undefined>();
const clientRef = useRef<SimulatorClient>();
Expand Down
5 changes: 4 additions & 1 deletion packages/slice-machine/lib/models/common/ErrorWithStatus.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export default class ErrorWithStatus extends Error {
constructor(readonly reason: string, readonly status: number) {
constructor(
readonly reason: string,
readonly status: number
) {
super(reason);
}
}
2 changes: 1 addition & 1 deletion packages/slice-machine/lib/utils/poll.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export async function startPolling<
Result,
ValidatedResult extends Result = Result
ValidatedResult extends Result = Result,
>(
fn: () => Promise<Result>,
validate: (result: Result) => result is ValidatedResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type UseLabArgs = keyof Required<SliceMachineConfig>["labs"];

export type UseLabReturnType = [
lab: { enabled: boolean },
setLab: (enabled: boolean) => Promise<void>
setLab: (enabled: boolean) => Promise<void>,
];

export function useLab(key: UseLabArgs): UseLabReturnType {
Expand Down
17 changes: 10 additions & 7 deletions packages/slice-machine/src/hooks/useModelStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ function computeStatuses(
models: LocalOrRemoteModel[],
userHasAccessToModels: boolean
) {
return models.reduce<{ [id: string]: ModelStatus }>((acc, model) => {
const { status } = computeModelStatus(model, userHasAccessToModels);
return models.reduce<{ [id: string]: ModelStatus }>(
(acc, model) => {
const { status } = computeModelStatus(model, userHasAccessToModels);

return {
...acc,
[hasLocal(model) ? model.local.id : model.remote.id]: status,
};
}, {} as { [sliceId: string]: ModelStatus });
return {
...acc,
[hasLocal(model) ? model.local.id : model.remote.id]: status,
};
},
{} as { [sliceId: string]: ModelStatus }
);
}

export const useModelStatus = ({
Expand Down
2 changes: 1 addition & 1 deletion packages/slice-machine/src/hooks/useSliceMachineConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { managerClient } from "@src/managerClient";

type UseSliceMachineConfigReturnType = [
config: SliceMachineConfig,
setConfig: (config: SliceMachineConfig) => Promise<void>
setConfig: (config: SliceMachineConfig) => Promise<void>,
];

export function useSliceMachineConfig(): UseSliceMachineConfigReturnType {
Expand Down
15 changes: 9 additions & 6 deletions packages/slice-machine/src/hooks/useThrottle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ function useThrottle<T>(
const lastRan = useRef(Date.now());

useEffect(() => {
const handler = setTimeout(function () {
if (Date.now() - lastRan.current >= limit) {
setThrottledValue(cb());
lastRan.current = Date.now();
}
}, limit - (Date.now() - lastRan.current));
const handler = setTimeout(
function () {
if (Date.now() - lastRan.current >= limit) {
setThrottledValue(cb());
lastRan.current = Date.now();
}
},
limit - (Date.now() - lastRan.current)
);

return () => {
clearTimeout(handler);
Expand Down
4 changes: 3 additions & 1 deletion packages/slice-machine/src/modules/useSliceMachineActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ const useSliceMachineActions = () => {
dispatch(modalOpenCreator({ modalKey: ModalKeysEnum.DELETE_SLICE }));
const openDeleteDocumentsDrawer = () =>
dispatch(
modalOpenCreator({ modalKey: ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER })
modalOpenCreator({
modalKey: ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER,
})
);
const openDeleteDocumentsDrawerOverLimit = () =>
dispatch(
Expand Down
2 changes: 1 addition & 1 deletion packages/slice-machine/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,6 @@ const AppTheme = (): Theme =>
bg: "muted",
},
},
} as Theme);
}) as Theme;

export default AppTheme;
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type CreateTestPluginArgs<TPluginOptions extends SliceMachinePluginOptions> =
};

export const createTestPlugin = <
TPluginOptions extends SliceMachinePluginOptions
TPluginOptions extends SliceMachinePluginOptions,
>({
setup,
__autofillRequiredAdapterHooks = true,
Expand Down
5 changes: 2 additions & 3 deletions packages/slice-machine/test/src/hooks/useModelStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import { ModelStatus } from "@lib/models/common/ModelStatus";

const mockSelector = vi.fn();
vi.mock("react-redux", async () => {
const actual: typeof import("react-redux") = await vi.importActual(
"react-redux"
);
const actual: typeof import("react-redux") =
await vi.importActual("react-redux");

return {
...actual,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ describe("[Available Custom types module]", () => {

it("should return the initial state if no matching action", () => {
expect(
// @ts-expect-error TS(2322) FIXME: Type '"NO.MATCH"' is not assignable to type '"CUST... Remove this comment to see the full error message
availableCustomTypesReducer(dummyCustomTypesState, { type: "NO.MATCH" })
availableCustomTypesReducer(dummyCustomTypesState, {
// @ts-expect-error TS(2322) FIXME: Type '"NO.MATCH"' is not assignable to type '"CUST... Remove this comment to see the full error message
type: "NO.MATCH",
})
).toEqual(dummyCustomTypesState);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/start-slicemachine/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"plugins": ["prettier-plugin-jsdoc"],
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"jsdocCommentLineStrategy": "keep",
"tsdoc": true,
"printWidth": 80,
"useTabs": true,
Expand Down
55 changes: 0 additions & 55 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24831,8 +24831,6 @@ __metadata:
"@types/react": ^18.2.25
"@types/react-dom": ^18.2.11
next: ^13.5.4
prettier: ^3.0.3
prettier-plugin-tailwindcss: ^0.5.6
react: ^18.2.0
react-dom: ^18.2.0
slice-machine-ui: "workspace:*"
Expand Down Expand Up @@ -28155,59 +28153,6 @@ __metadata:
languageName: node
linkType: hard

"prettier-plugin-tailwindcss@npm:^0.5.6":
version: 0.5.6
resolution: "prettier-plugin-tailwindcss@npm:0.5.6"
peerDependencies:
"@ianvs/prettier-plugin-sort-imports": "*"
"@prettier/plugin-pug": "*"
"@shopify/prettier-plugin-liquid": "*"
"@shufo/prettier-plugin-blade": "*"
"@trivago/prettier-plugin-sort-imports": "*"
prettier: ^3.0
prettier-plugin-astro: "*"
prettier-plugin-css-order: "*"
prettier-plugin-import-sort: "*"
prettier-plugin-jsdoc: "*"
prettier-plugin-organize-attributes: "*"
prettier-plugin-organize-imports: "*"
prettier-plugin-style-order: "*"
prettier-plugin-svelte: "*"
peerDependenciesMeta:
"@ianvs/prettier-plugin-sort-imports":
optional: true
"@prettier/plugin-pug":
optional: true
"@shopify/prettier-plugin-liquid":
optional: true
"@shufo/prettier-plugin-blade":
optional: true
"@trivago/prettier-plugin-sort-imports":
optional: true
prettier-plugin-astro:
optional: true
prettier-plugin-css-order:
optional: true
prettier-plugin-import-sort:
optional: true
prettier-plugin-jsdoc:
optional: true
prettier-plugin-marko:
optional: true
prettier-plugin-organize-attributes:
optional: true
prettier-plugin-organize-imports:
optional: true
prettier-plugin-style-order:
optional: true
prettier-plugin-svelte:
optional: true
prettier-plugin-twig-melody:
optional: true
checksum: ea5b18daf8727ee77eb6f10e5ceb43416aedee48350b838faae5764083dadb93edba33b84ed5c6ce606de33c875fc444ca979e669f340373fa0f0b76a5cafeac
languageName: node
linkType: hard

"prettier@npm:*, prettier@npm:3.0.3, prettier@npm:^3.0.3":
version: 3.0.3
resolution: "prettier@npm:3.0.3"
Expand Down

0 comments on commit ecead99

Please sign in to comment.