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

Tidy up formatting #9179

Merged
merged 8 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ module.exports = {
'@babel/preset-typescript',
],
plugins: ['@babel/plugin-transform-runtime'],
};
}
1 change: 0 additions & 1 deletion design-system/packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export const useId = (idFromProps?: string | null) => {
if (id === null) {
setId(genId())
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function getContrastText (color: string) {
const [r, g, b] = hexToTriplet(color)

// calculate contrast against grayscale
var contrast = (Math.round(r * 299) + Math.round(g * 587) + Math.round(b * 114)) / 1000
let contrast = (Math.round(r * 299) + Math.round(g * 587) + Math.round(b * 114)) / 1000

return contrast >= 128 ? 'black' : 'white'
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function parseHex (hex: string) {
return result
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function hexToTriplet (dirtyHex: string, alpha?: number) {
const cleanHex = parseHex(dirtyHex)

Expand Down
1 change: 0 additions & 1 deletion design-system/packages/icons/build-icons.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('node:path')
const fs = require('node:fs/promises')

/* eslint-disable import/no-extraneous-dependencies */
const svgr = require('@svgr/core').default
const { icons } = require('feather-icons')
const toPascalCase = require('to-pascal-case')
Expand Down
1 change: 0 additions & 1 deletion design-system/packages/modals/src/drawer-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export const useDrawerManager = (uniqueKey: string) => {
return () => {
modalState.popFromDrawerStack()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
// the last key in the array is the "top" modal visually, so the depth is the inverse index
// be careful not to mutate the stack
Expand Down
1 change: 0 additions & 1 deletion design-system/packages/toast/src/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export const ToastElement = forwardRef<HTMLDivElement, ToastElementProps>((props
}
// this is not like other components because the consumer cannot update the props once they `addToast()`
// we intentionally only want this to be run when the toast element mounts/unmounts
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

const iconElement = {
Expand Down
2 changes: 1 addition & 1 deletion docs/components/docs/DocumentEditorDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const componentBlocks = {
carousel: componentBlocksInSandboxProject.carousel,
}

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
type DocumentFieldConfig = Parameters<typeof import('@keystone-6/fields-document').document>[0]

function documentFeaturesCodeExample (config: DocumentFieldConfig | DocumentFeatures) {
Expand Down Expand Up @@ -292,7 +293,6 @@ export const DocumentEditorDemo = () => {
// slate looks like it's a controlled component but it actually isn't
// so we need to re-mount it so that it looks at the updated value
setKey(x => x + 1)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [documentFeatures])

return (
Expand Down
1 change: 0 additions & 1 deletion docs/components/primitives/Emoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function Emoji ({ symbol, alt, ...props }: EmojiProps) {
const posRef = useRef<HTMLElement>(null)
const [showOnTop, setShownTop] = useState(true)

// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(() => {
if (posRef.current && posRef.current.offsetTop - window.pageYOffset < 50) {
setShownTop(false)
Expand Down
6 changes: 3 additions & 3 deletions docs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// you don't need this if you're building something outside of the Keystone repo
import withPreconstruct from '@preconstruct/next';
import redirects from './redirects.mjs';
import withPreconstruct from '@preconstruct/next'
import redirects from './redirects.mjs'

export default withPreconstruct({
env: {
Expand All @@ -15,4 +15,4 @@ export default withPreconstruct({
ignoreBuildErrors: true,
},
redirects,
});
})
4 changes: 2 additions & 2 deletions docs/pages/updates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,9 @@ export default function WhatsNew () {
</Box> */}
<Timeline date="16th September 2021" />
<Box heading="create-keystone-app now uses SQLite">
Our CLI app now uses <InlineCode>SQLite</InlineCode> under the hood so you don’t have to
Our CLI app now uses <InlineCode>SQLite</InlineCode> under the hood so you don’t have to
spend time on DB config when trying out new ideas. We also updated the{' '}
<Link href="/docs/getting-started">getting started walkthrough</Link> to reflect this
<Link href="/docs/getting-started">getting started walkthrough</Link> to reflect this
improvement.
</Box>
<Timeline date="15th September 2021" />
Expand Down
14 changes: 7 additions & 7 deletions docs/redirects.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const KEYSTONE_4 = [
// destination: 'https://v4.keystonejs.com/getting-started',
// permanent: true,
// },
];
]

/* URLs from v5.keystonejs.com */
const KEYSTONE_5 = [
Expand Down Expand Up @@ -56,7 +56,7 @@ const KEYSTONE_5 = [
destination: '/docs',
permanent: false,
},
];
]

/* URLs from the original next.keystonejs.com website */
const ORIGINAL_NEXT = [
Expand Down Expand Up @@ -95,7 +95,7 @@ const ORIGINAL_NEXT = [
},
{ source: '/roadmap', destination: '/updates/roadmap', permanent: true },
{ source: '/whats-new', destination: '/updates/whats-new-in-v6', permanent: true },
];
]

/* Splitbee Proxy */
const SPLITBEE = [
Expand All @@ -109,7 +109,7 @@ const SPLITBEE = [
destination: 'https://hive.splitbee.io/:slug',
permanent: false,
},
];
]

/* Current website redirections */
const CURRENT = [
Expand Down Expand Up @@ -274,14 +274,14 @@ const CURRENT = [
destination: '/blog/embedded-mode-with-sqlite-nextjs',
permanent: true,
},
];
]

export default async function redirects() {
export default async function redirects () {
return [
...SPLITBEE,
...CURRENT,
...ORIGINAL_NEXT,
...KEYSTONE_5,
...KEYSTONE_4
];
]
}
5 changes: 4 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module.exports = tseslint.config(
'**/.keystone/',
'**/dist/',
'**/node_modules/',
'**/syntax-error.js'
'**/syntax-error.js',
'**/public/'
],
},
eslint.configs.recommended,
Expand All @@ -19,6 +20,7 @@ module.exports = tseslint.config(
rules: {
// TODO: remove
'no-empty': 'off',
'no-empty-pattern': ['error', { allowObjectPatternsAsParameters: true }],
'no-extra-boolean-cast': 'off',
'no-async-promise-executor': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
Expand All @@ -37,6 +39,7 @@ module.exports = tseslint.config(
// TODO: remove

semi: ['error', 'never'],
quotes: ['error', 'single', { allowTemplateLiterals: true, avoidEscape: true }],
'block-spacing': ['error', 'always'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'comma-spacing': ['error', { before: false, after: true }],
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-field/1-text-field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function text<ListTypeInfo extends BaseListTypeInfo> ({
input: {
create: {
arg: graphql.arg({ type: graphql.String }),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve (value, context) {
return value
},
Expand All @@ -36,7 +36,7 @@ export function text<ListTypeInfo extends BaseListTypeInfo> ({
},
output: graphql.field({
type: graphql.String,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve ({ value, item }, args, context, info) {
return value
},
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-field/2-stars-field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const stars =
// this field type doesn't need to do anything special
// but field types can specify resolvers for inputs like they can for their output GraphQL field
// this function can be omitted, it is here purely to show how you could change it
// eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve (val, context) {
// if it's null, then the value will be set to null in the database
if (val === null) {
Expand All @@ -77,7 +77,7 @@ export const stars =
type: graphql.Int,
// like the input resolvers, providing the resolver is unnecessary if you're just returning the value
// it is shown here to show what you could do
// eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve ({ value, item }, args, context, info) {
return value
},
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-field/4-conditional-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function feedback<ListTypeInfo extends BaseListTypeInfo> ({
input: {
create: {
arg: graphql.arg({ type: graphql.String }),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve (value, context) {
return value
},
Expand All @@ -41,7 +41,7 @@ export function feedback<ListTypeInfo extends BaseListTypeInfo> ({
},
output: graphql.field({
type: graphql.String,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve ({ value, item }, args, context, info) {
return value
},
Expand Down
20 changes: 10 additions & 10 deletions examples/extend-graphql-schema-nexus/nexus-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/


import type { Context } from "./keystone-types"
import type { Context } from './keystone-types'
gautamsi marked this conversation as resolved.
Show resolved Hide resolved



Expand Down Expand Up @@ -164,15 +164,15 @@ export interface NexusGenInputs {
}

export interface NexusGenEnums {
KeystoneAdminUIFieldMetaCreateViewFieldMode: "edit" | "hidden"
KeystoneAdminUIFieldMetaIsNonNull: "create" | "read" | "update"
KeystoneAdminUIFieldMetaItemViewFieldMode: "edit" | "hidden" | "read"
KeystoneAdminUIFieldMetaItemViewFieldPosition: "form" | "sidebar"
KeystoneAdminUIFieldMetaListViewFieldMode: "hidden" | "read"
KeystoneAdminUISortDirection: "ASC" | "DESC"
OrderDirection: "asc" | "desc"
PostStatusType: "draft" | "published"
QueryMode: "default" | "insensitive"
KeystoneAdminUIFieldMetaCreateViewFieldMode: 'edit' | 'hidden'
KeystoneAdminUIFieldMetaIsNonNull: 'create' | 'read' | 'update'
KeystoneAdminUIFieldMetaItemViewFieldMode: 'edit' | 'hidden' | 'read'
KeystoneAdminUIFieldMetaItemViewFieldPosition: 'form' | 'sidebar'
KeystoneAdminUIFieldMetaListViewFieldMode: 'hidden' | 'read'
KeystoneAdminUISortDirection: 'ASC' | 'DESC'
OrderDirection: 'asc' | 'desc'
PostStatusType: 'draft' | 'published'
QueryMode: 'default' | 'insensitive'
}

export interface NexusGenScalars {
Expand Down
1 change: 1 addition & 0 deletions examples/extend-graphql-schema-nexus/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function extendGraphqlSchema (baseSchema: GraphQLSchema) {

// Typescript output settings, probably something you might commit in dev
// TODO: remove false ??, it is not part of the example, but we are having monorepo issues
// eslint-disable-next-line no-constant-binary-expression
shouldGenerateArtifacts: false ?? process.env.NODE_ENV !== 'production',
outputs: {
typegen: path.join(process.cwd(), 'nexus-types.ts'),
Expand Down
2 changes: 1 addition & 1 deletion examples/extend-graphql-subscriptions/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { type Context } from '.keystone/types'

// Setup pubsub as a Global variable in dev so it survives Hot Reloads.
declare global {
var graphqlSubscriptionPubSub: PubSub
let graphqlSubscriptionPubSub: PubSub
}

// The 'graphql-subscriptions' pubsub library is not recommended for production use, but can be useful as an example
Expand Down
4 changes: 2 additions & 2 deletions examples/framework-astro/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'astro/config';
import { defineConfig } from 'astro/config'

// https://astro.build/config
export default defineConfig({
Expand All @@ -9,4 +9,4 @@ export default defineConfig({
external: ['@keystone-6/core/context', '@keystone-6/core', '@keystone-6/core/fields'],
},
},
});
})
1 change: 0 additions & 1 deletion examples/framework-astro/src/keystone/context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getContext } from '@keystone-6/core/context'
// Using myprisma/client as vite does not like .
// This should be @prisma/client in a project outside of the Keystone monorepo
// eslint-disable-next-line import/no-extraneous-dependencies
import * as PrismaModule from 'myprisma/client'
import config from '../../keystone'
import type { Context } from '.keystone/types'
Expand Down
4 changes: 2 additions & 2 deletions examples/framework-nextjs-app-directory/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// you don't need this if you're building something outside of the Keystone repo
import withPreconstruct from '@preconstruct/next';
import withPreconstruct from '@preconstruct/next'

export default withPreconstruct({
experimental: {
Expand All @@ -12,4 +12,4 @@ export default withPreconstruct({
typescript: {
ignoreBuildErrors: true,
},
});
})
1 change: 1 addition & 0 deletions examples/graphql-ts-gql/schema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/consistent-type-imports */
import { list, graphql } from '@keystone-6/core'
import { select, relationship, text, timestamp, virtual } from '@keystone-6/core/fields'
import { allowAll } from '@keystone-6/core/access'
Expand Down
6 changes: 3 additions & 3 deletions packages/fields-document/src/DocumentEditor/editor-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ export function createDocumentEditor (
componentBlocks: Record<string, ComponentBlock>,
relationships: Relationships,
slate?: {
withReact: (editor: Editor) => any,
withReact: (editor: Editor) => any
ReactEditor: {
focus: (editor: Editor) => void,
},
focus: (editor: Editor) => void
}
},
) {
return withPasting(
Expand Down
4 changes: 2 additions & 2 deletions packages/fields-document/src/DocumentEditor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export function insertNodesButReplaceIfSelectionIsAtEmptyParagraphOrHeading (
nodes: Node | Node[],
slate?: {
ReactEditor: {
focus: (editor: Editor) => void,
},
focus: (editor: Editor) => void
}
},
) {
let pathRefForEmptyNodeAtCursor: PathRef | undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/fields-document/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export type DocumentFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
db?: { map?: string, extendPrismaSchema?: (field: string) => string }
}

export function document <ListTypeInfo extends BaseListTypeInfo>({
export function document <ListTypeInfo extends BaseListTypeInfo> ({
componentBlocks = {},
dividers,
formatting,
Expand Down
2 changes: 0 additions & 2 deletions scripts/prepare-release.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { spawnSync } = require('child_process')
const { readFileSync, writeFileSync } = require('fs')
// eslint-disable-next-line import/no-extraneous-dependencies
const { default: getReleasePlan } = require('@changesets/get-release-plan')
// eslint-disable-next-line import/no-extraneous-dependencies
const { getInfo } = require('@changesets/get-github-info')

// TODO: move this to CI linting
Expand Down