From 1a997710954eb96abe2ed3efa01392725e660be6 Mon Sep 17 00:00:00 2001 From: Mirone Date: Sun, 22 Dec 2024 12:27:36 +0800 Subject: [PATCH] ci: enable more oxlint rules (#1599) --- .oxlintrc.json | 23 +++++++++++++++++-- e2e/tests/misc/index.ts | 2 +- .../icons/{alignCenter.ts => align-center.ts} | 0 .../src/icons/{alignLeft.ts => align-left.ts} | 0 .../icons/{alignRight.ts => align-right.ts} | 0 .../icons/{bulletList.ts => bullet-list.ts} | 0 ...heckBoxChecked.ts => check-box-checked.ts} | 0 ...BoxUnchecked.ts => check-box-unchecked.ts} | 0 .../icons/{chevronDown.ts => chevron-down.ts} | 0 .../icons/{dragHandle.ts => drag-handle.ts} | 0 packages/crepe/src/icons/index.ts | 20 ++++++++-------- .../icons/{orderedList.ts => ordered-list.ts} | 0 .../src/icons/{todoList.ts => todo-list.ts} | 0 .../react/src/{Editor.tsx => editor.tsx} | 2 +- packages/integrations/react/src/index.ts | 6 ++--- .../react/src/{useEditor.ts => use-editor.ts} | 2 +- .../{useGetEditor.ts => use-get-editor.ts} | 0 .../src/{useInstance.ts => use-instance.ts} | 2 +- .../vue/src/{Editor.tsx => editor.tsx} | 2 +- packages/integrations/vue/src/index.ts | 6 ++--- .../vue/src/{useEditor.ts => use-editor.ts} | 0 .../{useGetEditor.ts => use-get-editor.ts} | 0 .../src/{useInstance.ts => use-instance.ts} | 0 .../{$inputRule.ts => $input-rule.ts} | 0 packages/utils/src/composable/index.ts | 2 +- 25 files changed, 43 insertions(+), 24 deletions(-) rename packages/crepe/src/icons/{alignCenter.ts => align-center.ts} (100%) rename packages/crepe/src/icons/{alignLeft.ts => align-left.ts} (100%) rename packages/crepe/src/icons/{alignRight.ts => align-right.ts} (100%) rename packages/crepe/src/icons/{bulletList.ts => bullet-list.ts} (100%) rename packages/crepe/src/icons/{checkBoxChecked.ts => check-box-checked.ts} (100%) rename packages/crepe/src/icons/{checkBoxUnchecked.ts => check-box-unchecked.ts} (100%) rename packages/crepe/src/icons/{chevronDown.ts => chevron-down.ts} (100%) rename packages/crepe/src/icons/{dragHandle.ts => drag-handle.ts} (100%) rename packages/crepe/src/icons/{orderedList.ts => ordered-list.ts} (100%) rename packages/crepe/src/icons/{todoList.ts => todo-list.ts} (100%) rename packages/integrations/react/src/{Editor.tsx => editor.tsx} (93%) rename packages/integrations/react/src/{useEditor.ts => use-editor.ts} (91%) rename packages/integrations/react/src/{useGetEditor.ts => use-get-editor.ts} (100%) rename packages/integrations/react/src/{useInstance.ts => use-instance.ts} (88%) rename packages/integrations/vue/src/{Editor.tsx => editor.tsx} (94%) rename packages/integrations/vue/src/{useEditor.ts => use-editor.ts} (100%) rename packages/integrations/vue/src/{useGetEditor.ts => use-get-editor.ts} (100%) rename packages/integrations/vue/src/{useInstance.ts => use-instance.ts} (100%) rename packages/utils/src/composable/{$inputRule.ts => $input-rule.ts} (100%) diff --git a/.oxlintrc.json b/.oxlintrc.json index 18c58651c86e..26a8a2fe76e1 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -1,14 +1,33 @@ { "plugins": ["import", "typescript", "unicorn", "promise"], "rules": { - "eslint/no-unused-vars": "off", "no-console": "error", + "eslint/no-unused-vars": "off", + "unicorn/prefer-array-some": "error", "unicorn/no-useless-promise-resolve-reject": "error", + "unicorn/no-unnecessary-await": "error", + "unicorn/no-useless-fallback-in-spread": "error", + "unicorn/filename-case": [ + "error", + { + "case": "kebabCase" + } + ], + "unicorn/prefer-date-now": "error", + "unicorn/prefer-blob-reading-methods": "error", + "unicorn/no-typeof-undefined": "error", + "unicorn/no-new-array": "error", "import/no-cycle": [ "error", { "ignoreTypes": true } - ] + ], + "import/sort-imports": "error", + "import/no-duplicates": "error", + "import/no-import-assign": "error", + "import/no-self-import": "error", + "typescript/consistent-type-imports": "error", + "typescript/no-import-type-side-effects": "error" } } diff --git a/e2e/tests/misc/index.ts b/e2e/tests/misc/index.ts index d8972926d0c5..aeea24c12b2e 100644 --- a/e2e/tests/misc/index.ts +++ b/e2e/tests/misc/index.ts @@ -1,4 +1,4 @@ -import { Page } from '@playwright/test' +import type { Page } from '@playwright/test' import fs from 'node:fs/promises' import path from 'node:path' diff --git a/packages/crepe/src/icons/alignCenter.ts b/packages/crepe/src/icons/align-center.ts similarity index 100% rename from packages/crepe/src/icons/alignCenter.ts rename to packages/crepe/src/icons/align-center.ts diff --git a/packages/crepe/src/icons/alignLeft.ts b/packages/crepe/src/icons/align-left.ts similarity index 100% rename from packages/crepe/src/icons/alignLeft.ts rename to packages/crepe/src/icons/align-left.ts diff --git a/packages/crepe/src/icons/alignRight.ts b/packages/crepe/src/icons/align-right.ts similarity index 100% rename from packages/crepe/src/icons/alignRight.ts rename to packages/crepe/src/icons/align-right.ts diff --git a/packages/crepe/src/icons/bulletList.ts b/packages/crepe/src/icons/bullet-list.ts similarity index 100% rename from packages/crepe/src/icons/bulletList.ts rename to packages/crepe/src/icons/bullet-list.ts diff --git a/packages/crepe/src/icons/checkBoxChecked.ts b/packages/crepe/src/icons/check-box-checked.ts similarity index 100% rename from packages/crepe/src/icons/checkBoxChecked.ts rename to packages/crepe/src/icons/check-box-checked.ts diff --git a/packages/crepe/src/icons/checkBoxUnchecked.ts b/packages/crepe/src/icons/check-box-unchecked.ts similarity index 100% rename from packages/crepe/src/icons/checkBoxUnchecked.ts rename to packages/crepe/src/icons/check-box-unchecked.ts diff --git a/packages/crepe/src/icons/chevronDown.ts b/packages/crepe/src/icons/chevron-down.ts similarity index 100% rename from packages/crepe/src/icons/chevronDown.ts rename to packages/crepe/src/icons/chevron-down.ts diff --git a/packages/crepe/src/icons/dragHandle.ts b/packages/crepe/src/icons/drag-handle.ts similarity index 100% rename from packages/crepe/src/icons/dragHandle.ts rename to packages/crepe/src/icons/drag-handle.ts diff --git a/packages/crepe/src/icons/index.ts b/packages/crepe/src/icons/index.ts index 2bf994e0d779..0d409ebed16f 100644 --- a/packages/crepe/src/icons/index.ts +++ b/packages/crepe/src/icons/index.ts @@ -1,19 +1,19 @@ -export * from './alignCenter' -export * from './alignLeft' -export * from './alignRight' +export * from './align-center' +export * from './align-left' +export * from './align-right' export * from './bold' export * from './bullet' -export * from './bulletList' +export * from './bullet-list' export * from './caption' -export * from './checkBoxChecked' -export * from './checkBoxUnchecked' -export * from './chevronDown' +export * from './check-box-checked' +export * from './check-box-unchecked' +export * from './chevron-down' export * from './clear' export * from './code' export * from './confirm' export * from './copy' export * from './divider' -export * from './dragHandle' +export * from './drag-handle' export * from './edit' export * from './h1' export * from './h2' @@ -25,7 +25,7 @@ export * from './image' export * from './italic' export * from './link' export * from './menu' -export * from './orderedList' +export * from './ordered-list' export * from './plus' export * from './quote' export * from './remove' @@ -33,4 +33,4 @@ export * from './search' export * from './strikethrough' export * from './table' export * from './text' -export * from './todoList' +export * from './todo-list' diff --git a/packages/crepe/src/icons/orderedList.ts b/packages/crepe/src/icons/ordered-list.ts similarity index 100% rename from packages/crepe/src/icons/orderedList.ts rename to packages/crepe/src/icons/ordered-list.ts diff --git a/packages/crepe/src/icons/todoList.ts b/packages/crepe/src/icons/todo-list.ts similarity index 100% rename from packages/crepe/src/icons/todoList.ts rename to packages/crepe/src/icons/todo-list.ts diff --git a/packages/integrations/react/src/Editor.tsx b/packages/integrations/react/src/editor.tsx similarity index 93% rename from packages/integrations/react/src/Editor.tsx rename to packages/integrations/react/src/editor.tsx index 1cd26be4a680..4ece7d12d84f 100644 --- a/packages/integrations/react/src/Editor.tsx +++ b/packages/integrations/react/src/editor.tsx @@ -3,7 +3,7 @@ import type { FC, ReactNode } from 'react' import React, { useMemo, useRef, useState } from 'react' import type { EditorInfoCtx, GetEditor } from './types' -import { editorInfoContext, useGetEditor } from './useGetEditor' +import { editorInfoContext, useGetEditor } from './use-get-editor' export const Milkdown: FC = () => { const domRef = useGetEditor() diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts index 265e60a03cbc..801642883a2f 100644 --- a/packages/integrations/react/src/index.ts +++ b/packages/integrations/react/src/index.ts @@ -1,4 +1,4 @@ -export * from './Editor' +export * from './editor' export * from './types' -export * from './useEditor' -export * from './useInstance' +export * from './use-editor' +export * from './use-instance' diff --git a/packages/integrations/react/src/useEditor.ts b/packages/integrations/react/src/use-editor.ts similarity index 91% rename from packages/integrations/react/src/useEditor.ts rename to packages/integrations/react/src/use-editor.ts index ff126ca40884..3c518f143379 100644 --- a/packages/integrations/react/src/useEditor.ts +++ b/packages/integrations/react/src/use-editor.ts @@ -2,7 +2,7 @@ import type { DependencyList } from 'react' import { useCallback, useContext, useLayoutEffect } from 'react' import type { GetEditor, UseEditorReturn } from './types' -import { editorInfoContext } from './useGetEditor' +import { editorInfoContext } from './use-get-editor' export function useEditor( getEditor: GetEditor, diff --git a/packages/integrations/react/src/useGetEditor.ts b/packages/integrations/react/src/use-get-editor.ts similarity index 100% rename from packages/integrations/react/src/useGetEditor.ts rename to packages/integrations/react/src/use-get-editor.ts diff --git a/packages/integrations/react/src/useInstance.ts b/packages/integrations/react/src/use-instance.ts similarity index 88% rename from packages/integrations/react/src/useInstance.ts rename to packages/integrations/react/src/use-instance.ts index c34b96d11749..44961525b501 100644 --- a/packages/integrations/react/src/useInstance.ts +++ b/packages/integrations/react/src/use-instance.ts @@ -1,6 +1,6 @@ import type { Editor } from '@milkdown/core' import { useCallback, useContext } from 'react' -import { editorInfoContext } from './useGetEditor' +import { editorInfoContext } from './use-get-editor' export type Instance = [true, () => undefined] | [false, () => Editor] diff --git a/packages/integrations/vue/src/Editor.tsx b/packages/integrations/vue/src/editor.tsx similarity index 94% rename from packages/integrations/vue/src/Editor.tsx rename to packages/integrations/vue/src/editor.tsx index 11df9d1a5e84..f948adf2a1bc 100644 --- a/packages/integrations/vue/src/Editor.tsx +++ b/packages/integrations/vue/src/editor.tsx @@ -3,7 +3,7 @@ import type { Ref } from 'vue' import { Fragment, defineComponent, h, provide, ref } from 'vue' import type { GetEditor } from './types' -import { useGetEditor } from './useGetEditor' +import { useGetEditor } from './use-get-editor' import { editorInfoCtxKey } from './consts' h diff --git a/packages/integrations/vue/src/index.ts b/packages/integrations/vue/src/index.ts index 265e60a03cbc..801642883a2f 100644 --- a/packages/integrations/vue/src/index.ts +++ b/packages/integrations/vue/src/index.ts @@ -1,4 +1,4 @@ -export * from './Editor' +export * from './editor' export * from './types' -export * from './useEditor' -export * from './useInstance' +export * from './use-editor' +export * from './use-instance' diff --git a/packages/integrations/vue/src/useEditor.ts b/packages/integrations/vue/src/use-editor.ts similarity index 100% rename from packages/integrations/vue/src/useEditor.ts rename to packages/integrations/vue/src/use-editor.ts diff --git a/packages/integrations/vue/src/useGetEditor.ts b/packages/integrations/vue/src/use-get-editor.ts similarity index 100% rename from packages/integrations/vue/src/useGetEditor.ts rename to packages/integrations/vue/src/use-get-editor.ts diff --git a/packages/integrations/vue/src/useInstance.ts b/packages/integrations/vue/src/use-instance.ts similarity index 100% rename from packages/integrations/vue/src/useInstance.ts rename to packages/integrations/vue/src/use-instance.ts diff --git a/packages/utils/src/composable/$inputRule.ts b/packages/utils/src/composable/$input-rule.ts similarity index 100% rename from packages/utils/src/composable/$inputRule.ts rename to packages/utils/src/composable/$input-rule.ts diff --git a/packages/utils/src/composable/index.ts b/packages/utils/src/composable/index.ts index 394164c8134b..4b50b0043d95 100644 --- a/packages/utils/src/composable/index.ts +++ b/packages/utils/src/composable/index.ts @@ -1,5 +1,5 @@ export * from './$command' -export * from './$inputRule' +export * from './$input-rule' export * from './$mark' export * from './$node' export * from './$prose'