From 783873a6be3ec0c54775760d35e55dc95c11ab88 Mon Sep 17 00:00:00 2001 From: Jayden Seric Date: Mon, 6 Dec 2021 23:35:31 +1100 Subject: [PATCH] Configure Prettier option `singleQuote` to the default, `false`. --- .prettierrc.json | 3 +-- api/.prettierrc.json | 3 +-- api/config/UPLOAD_DIRECTORY_URL.mjs | 2 +- api/schema/FileType.mjs | 14 +++++------ api/schema/MutationType.mjs | 18 +++++++-------- api/schema/QueryType.mjs | 12 +++++----- api/schema/index.mjs | 6 ++--- api/server.mjs | 14 +++++------ api/storeUpload.mjs | 12 +++++----- app/.prettierrc.json | 3 +-- app/components/Header.js | 2 +- app/components/Page.js | 4 ++-- app/components/Section.js | 2 +- app/components/UploadBlob.js | 18 +++++++-------- app/components/UploadFile.js | 2 +- app/components/UploadFileList.js | 2 +- app/components/Uploads.js | 6 ++--- app/next.config.js | 4 ++-- app/pages/_app.js | 36 ++++++++++++++--------------- app/pages/index.js | 20 ++++++++-------- 20 files changed, 90 insertions(+), 93 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index b8de456..d2504b4 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,4 +1,3 @@ { - "proseWrap": "never", - "singleQuote": true + "proseWrap": "never" } diff --git a/api/.prettierrc.json b/api/.prettierrc.json index b8de456..d2504b4 100644 --- a/api/.prettierrc.json +++ b/api/.prettierrc.json @@ -1,4 +1,3 @@ { - "proseWrap": "never", - "singleQuote": true + "proseWrap": "never" } diff --git a/api/config/UPLOAD_DIRECTORY_URL.mjs b/api/config/UPLOAD_DIRECTORY_URL.mjs index d107257..5ce4487 100644 --- a/api/config/UPLOAD_DIRECTORY_URL.mjs +++ b/api/config/UPLOAD_DIRECTORY_URL.mjs @@ -1 +1 @@ -export default new URL('../uploads/', import.meta.url); +export default new URL("../uploads/", import.meta.url); diff --git a/api/schema/FileType.mjs b/api/schema/FileType.mjs index 404ec47..07219ab 100644 --- a/api/schema/FileType.mjs +++ b/api/schema/FileType.mjs @@ -1,22 +1,22 @@ -import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'; -import UPLOAD_DIRECTORY_URL from '../config/UPLOAD_DIRECTORY_URL.mjs'; +import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from "graphql"; +import UPLOAD_DIRECTORY_URL from "../config/UPLOAD_DIRECTORY_URL.mjs"; export default new GraphQLObjectType({ - name: 'File', - description: 'A stored file.', + name: "File", + description: "A stored file.", fields: () => ({ id: { - description: 'Unique ID.', + description: "Unique ID.", type: new GraphQLNonNull(GraphQLString), resolve: (storedFileName) => storedFileName, }, name: { - description: 'File name.', + description: "File name.", type: new GraphQLNonNull(GraphQLString), resolve: (storedFileName) => storedFileName, }, url: { - description: 'File URL.', + description: "File URL.", type: new GraphQLNonNull(GraphQLString), resolve: (storedFileName) => new URL(storedFileName, UPLOAD_DIRECTORY_URL), diff --git a/api/schema/MutationType.mjs b/api/schema/MutationType.mjs index b812d54..ebaf1d1 100644 --- a/api/schema/MutationType.mjs +++ b/api/schema/MutationType.mjs @@ -1,28 +1,28 @@ -import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql'; -import GraphQLUpload from 'graphql-upload/public/GraphQLUpload.js'; -import storeUpload from '../storeUpload.mjs'; -import FileType from './FileType.mjs'; +import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from "graphql"; +import GraphQLUpload from "graphql-upload/public/GraphQLUpload.js"; +import storeUpload from "../storeUpload.mjs"; +import FileType from "./FileType.mjs"; export default new GraphQLObjectType({ - name: 'Mutation', + name: "Mutation", fields: () => ({ singleUpload: { - description: 'Stores a single file.', + description: "Stores a single file.", type: new GraphQLNonNull(FileType), args: { file: { - description: 'File to store.', + description: "File to store.", type: new GraphQLNonNull(GraphQLUpload), }, }, resolve: (parent, { file }) => storeUpload(file), }, multipleUpload: { - description: 'Stores multiple files.', + description: "Stores multiple files.", type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(FileType))), args: { files: { - description: 'Files to store.', + description: "Files to store.", type: new GraphQLNonNull( new GraphQLList(new GraphQLNonNull(GraphQLUpload)) ), diff --git a/api/schema/QueryType.mjs b/api/schema/QueryType.mjs index 9d05275..4cf3b15 100644 --- a/api/schema/QueryType.mjs +++ b/api/schema/QueryType.mjs @@ -1,13 +1,13 @@ -import fs from 'fs'; -import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql'; -import UPLOAD_DIRECTORY_URL from '../config/UPLOAD_DIRECTORY_URL.mjs'; -import FileType from './FileType.mjs'; +import fs from "fs"; +import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from "graphql"; +import UPLOAD_DIRECTORY_URL from "../config/UPLOAD_DIRECTORY_URL.mjs"; +import FileType from "./FileType.mjs"; export default new GraphQLObjectType({ - name: 'Query', + name: "Query", fields: () => ({ uploads: { - description: 'All stored files.', + description: "All stored files.", type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(FileType))), resolve: () => fs.promises.readdir(UPLOAD_DIRECTORY_URL), }, diff --git a/api/schema/index.mjs b/api/schema/index.mjs index 8f64c95..f0f57c8 100644 --- a/api/schema/index.mjs +++ b/api/schema/index.mjs @@ -1,6 +1,6 @@ -import { GraphQLSchema } from 'graphql'; -import MutationType from './MutationType.mjs'; -import QueryType from './QueryType.mjs'; +import { GraphQLSchema } from "graphql"; +import MutationType from "./MutationType.mjs"; +import QueryType from "./QueryType.mjs"; export default new GraphQLSchema({ query: QueryType, diff --git a/api/server.mjs b/api/server.mjs index 7486b15..5b5c4a7 100644 --- a/api/server.mjs +++ b/api/server.mjs @@ -1,10 +1,10 @@ -import { fileURLToPath } from 'url'; -import { ApolloServer } from 'apollo-server-koa'; -import graphqlUploadKoa from 'graphql-upload/public/graphqlUploadKoa.js'; -import Koa from 'koa'; -import makeDir from 'make-dir'; -import UPLOAD_DIRECTORY_URL from './config/UPLOAD_DIRECTORY_URL.mjs'; -import schema from './schema/index.mjs'; +import { fileURLToPath } from "url"; +import { ApolloServer } from "apollo-server-koa"; +import graphqlUploadKoa from "graphql-upload/public/graphqlUploadKoa.js"; +import Koa from "koa"; +import makeDir from "make-dir"; +import UPLOAD_DIRECTORY_URL from "./config/UPLOAD_DIRECTORY_URL.mjs"; +import schema from "./schema/index.mjs"; /** * Starts the API server. diff --git a/api/storeUpload.mjs b/api/storeUpload.mjs index 458bd45..7e74f4c 100644 --- a/api/storeUpload.mjs +++ b/api/storeUpload.mjs @@ -1,6 +1,6 @@ -import { createWriteStream, unlink } from 'fs'; -import shortId from 'shortid'; -import UPLOAD_DIRECTORY_URL from './config/UPLOAD_DIRECTORY_URL.mjs'; +import { createWriteStream, unlink } from "fs"; +import shortId from "shortid"; +import UPLOAD_DIRECTORY_URL from "./config/UPLOAD_DIRECTORY_URL.mjs"; /** * Stores a GraphQL file upload in the filesystem. @@ -19,11 +19,11 @@ export default async function storeUpload(upload) { const writeStream = createWriteStream(storedFileUrl); // When the upload is fully written, resolve the promise. - writeStream.on('finish', resolve); + writeStream.on("finish", resolve); // If there's an error writing the file, remove the partially written file // and reject the promise. - writeStream.on('error', (error) => { + writeStream.on("error", (error) => { unlink(storedFileUrl, () => { reject(error); }); @@ -32,7 +32,7 @@ export default async function storeUpload(upload) { // In Node.js <= v13, errors are not automatically propagated between piped // streams. If there is an error receiving the upload, destroy the write // stream with the corresponding error. - stream.on('error', (error) => writeStream.destroy(error)); + stream.on("error", (error) => writeStream.destroy(error)); // Pipe the upload into the write stream. stream.pipe(writeStream); diff --git a/app/.prettierrc.json b/app/.prettierrc.json index b8de456..d2504b4 100644 --- a/app/.prettierrc.json +++ b/app/.prettierrc.json @@ -1,4 +1,3 @@ { - "proseWrap": "never", - "singleQuote": true + "proseWrap": "never" } diff --git a/app/components/Header.js b/app/components/Header.js index e0a48a8..213d932 100644 --- a/app/components/Header.js +++ b/app/components/Header.js @@ -1,4 +1,4 @@ -import styles from './Header.module.css'; +import styles from "./Header.module.css"; export const Header = (props) => (
diff --git a/app/components/Page.js b/app/components/Page.js index 935f1eb..36d858a 100644 --- a/app/components/Page.js +++ b/app/components/Page.js @@ -1,5 +1,5 @@ -import Head from 'next/head'; -import PropTypes from 'prop-types'; +import Head from "next/head"; +import PropTypes from "prop-types"; export const Page = ({ title, children }) => ( <> diff --git a/app/components/Section.js b/app/components/Section.js index a40626e..81bdd9f 100644 --- a/app/components/Section.js +++ b/app/components/Section.js @@ -1,4 +1,4 @@ -import styles from './Section.module.css'; +import styles from "./Section.module.css"; export const Section = (props) => (
diff --git a/app/components/UploadBlob.js b/app/components/UploadBlob.js index d1adbf4..8be249d 100644 --- a/app/components/UploadBlob.js +++ b/app/components/UploadBlob.js @@ -1,9 +1,9 @@ -import { gql, useApolloClient, useMutation } from '@apollo/client'; -import ButtonSubmit from 'device-agnostic-ui/ButtonSubmit.mjs'; -import Code from 'device-agnostic-ui/Code.mjs'; -import Fieldset from 'device-agnostic-ui/Fieldset.mjs'; -import Textbox from 'device-agnostic-ui/Textbox.mjs'; -import React from 'react'; +import { gql, useApolloClient, useMutation } from "@apollo/client"; +import ButtonSubmit from "device-agnostic-ui/ButtonSubmit.mjs"; +import Code from "device-agnostic-ui/Code.mjs"; +import Fieldset from "device-agnostic-ui/Fieldset.mjs"; +import Textbox from "device-agnostic-ui/Textbox.mjs"; +import React from "react"; const SINGLE_UPLOAD_MUTATION = gql` mutation singleUpload($file: Upload!) { @@ -14,8 +14,8 @@ const SINGLE_UPLOAD_MUTATION = gql` `; export function UploadBlob() { - const [name, setName] = React.useState(''); - const [content, setContent] = React.useState(''); + const [name, setName] = React.useState(""); + const [content, setContent] = React.useState(""); const [singleUploadMutation, { loading }] = useMutation( SINGLE_UPLOAD_MUTATION ); @@ -26,7 +26,7 @@ export function UploadBlob() { const onSubmit = (event) => { event.preventDefault(); - const file = new Blob([content], { type: 'text/plain' }); + const file = new Blob([content], { type: "text/plain" }); file.name = `${name}.txt`; singleUploadMutation({ variables: { file } }).then(() => { diff --git a/app/components/UploadFile.js b/app/components/UploadFile.js index 8b7290a..12962b0 100644 --- a/app/components/UploadFile.js +++ b/app/components/UploadFile.js @@ -1,4 +1,4 @@ -import { gql, useApolloClient, useMutation } from '@apollo/client'; +import { gql, useApolloClient, useMutation } from "@apollo/client"; const SINGLE_UPLOAD_MUTATION = gql` mutation singleUpload($file: Upload!) { diff --git a/app/components/UploadFileList.js b/app/components/UploadFileList.js index 88fe4ea..488f8fc 100644 --- a/app/components/UploadFileList.js +++ b/app/components/UploadFileList.js @@ -1,4 +1,4 @@ -import { gql, useApolloClient, useMutation } from '@apollo/client'; +import { gql, useApolloClient, useMutation } from "@apollo/client"; const MULTIPLE_UPLOAD_MUTATION = gql` mutation multipleUpload($files: [Upload!]!) { diff --git a/app/components/Uploads.js b/app/components/Uploads.js index a8d2279..32e519d 100644 --- a/app/components/Uploads.js +++ b/app/components/Uploads.js @@ -1,6 +1,6 @@ -import { gql, useQuery } from '@apollo/client'; -import Scroll from 'device-agnostic-ui/Scroll.mjs'; -import Table from 'device-agnostic-ui/Table.mjs'; +import { gql, useQuery } from "@apollo/client"; +import Scroll from "device-agnostic-ui/Scroll.mjs"; +import Table from "device-agnostic-ui/Table.mjs"; const UPLOADS_QUERY = gql` query uploads { diff --git a/app/next.config.js b/app/next.config.js index 2fb97a5..bb72f47 100644 --- a/app/next.config.js +++ b/app/next.config.js @@ -3,8 +3,8 @@ module.exports = { API_URI: process.env.API_URI, }, i18n: { - locales: ['en-US'], - defaultLocale: 'en-US', + locales: ["en-US"], + defaultLocale: "en-US", }, reactStrictMode: true, }; diff --git a/app/pages/_app.js b/app/pages/_app.js index eafaf3b..0d80673 100644 --- a/app/pages/_app.js +++ b/app/pages/_app.js @@ -1,23 +1,23 @@ -import 'device-agnostic-ui/theme.css'; -import 'device-agnostic-ui/global.css'; -import 'device-agnostic-ui/Button.css'; -import 'device-agnostic-ui/ButtonSubmit.css'; -import 'device-agnostic-ui/Code.css'; -import 'device-agnostic-ui/Fieldset.css'; -import 'device-agnostic-ui/Heading.css'; -import 'device-agnostic-ui/Loading.css'; -import 'device-agnostic-ui/Margin.css'; -import 'device-agnostic-ui/Scroll.css'; -import 'device-agnostic-ui/Table.css'; -import 'device-agnostic-ui/Textbox.css'; -import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'; -import { createUploadLink } from 'apollo-upload-client'; -import Head from 'next/head'; -import PropTypes from 'prop-types'; +import "device-agnostic-ui/theme.css"; +import "device-agnostic-ui/global.css"; +import "device-agnostic-ui/Button.css"; +import "device-agnostic-ui/ButtonSubmit.css"; +import "device-agnostic-ui/Code.css"; +import "device-agnostic-ui/Fieldset.css"; +import "device-agnostic-ui/Heading.css"; +import "device-agnostic-ui/Loading.css"; +import "device-agnostic-ui/Margin.css"; +import "device-agnostic-ui/Scroll.css"; +import "device-agnostic-ui/Table.css"; +import "device-agnostic-ui/Textbox.css"; +import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client"; +import { createUploadLink } from "apollo-upload-client"; +import Head from "next/head"; +import PropTypes from "prop-types"; const createApolloClient = (cache = {}) => new ApolloClient({ - ssrMode: typeof window === 'undefined', + ssrMode: typeof window === "undefined", cache: new InMemoryCache().restore(cache), link: createUploadLink({ uri: process.env.API_URI }), }); @@ -49,7 +49,7 @@ App.getInitialProps = async (context) => { if (context.ctx.req) { const apolloClient = createApolloClient(); try { - const { getDataFromTree } = await import('@apollo/client/react/ssr'); + const { getDataFromTree } = await import("@apollo/client/react/ssr"); await getDataFromTree( (