Skip to content
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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ jobs:
- name: Run lint
run: pnpm test:lint --format github

- name: Run eslint
run: pnpm test:eslint

unit:
runs-on: ubuntu-latest
needs: install-deps
Expand Down
3 changes: 2 additions & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"**/*.{js,ts,tsx,json,yaml,yml,md}": ["oxlint -c .oxlintrc.json --fix"]
"**/*.{js,ts,tsx,json,yaml,yml,md}": ["oxlint -c .oxlintrc.json --fix"],
"*": "oxfmt --no-error-on-unmatched-pattern"
}
27 changes: 27 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"printWidth": 80,
"sortImports": {
"groups": [
"type-import",
["value-builtin", "value-external"],
"type-internal",
"value-internal",
["type-parent", "type-sibling", "type-index"],
["value-parent", "value-sibling", "value-index"],
"unknown"
]
},
"ignorePatterns": [
"pnpm-lock.yaml",
"**/storybook-static",
"**/lib",
"**/.storybook",
"**/tests/data/*.md",
"**/templates/*.md"
]
}
8 changes: 7 additions & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"plugins": ["import", "typescript", "unicorn", "promise"],
"options": {
"typeAware": true
},
"rules": {
"no-console": ["error", { "allow": ["warn", "error"] }],
"for-direction": "error",
Expand Down Expand Up @@ -111,6 +115,8 @@
"allowDeclarations": true
}
],
"typescript/no-unnecessary-type-constraint": "error"
"typescript/no-unnecessary-type-constraint": "error",
"typescript/restrict-template-expressions": "off",
"typescript/no-base-to-string": "off"
}
}
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion dev/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@milkdown/dev",
"version": "0.0.0",
"private": true,
"type": "module",
"version": "0.0.0",
"exports": {
".": {
"import": "./lib/index.js",
Expand Down
8 changes: 6 additions & 2 deletions dev/src/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ export function exec(
{ silent }: { silent: boolean } = { silent: false }
): string {
const logger = new Logger(tag)
!silent && logger.info(cmd)
if (!silent) {
logger.info(cmd)
}
const result = execSync(cmd, { encoding: 'utf8' }).trim()
!silent && logger.log(result)
if (!silent) {
logger.log(result)
}
return result
}
38 changes: 22 additions & 16 deletions dev/src/generate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { applyEdits, modify } from 'jsonc-parser'
import { readFileSync, writeFileSync } from 'node:fs'
import { type BuiltInParserName, format } from 'prettier'
import { format } from 'oxfmt'

import type { Package } from './package'
import type { Path } from './path'
Expand Down Expand Up @@ -30,14 +30,17 @@ export class Generator {
}

generateWorkspaceFiles = async () => {
const filesToGenerate: [
Path,
(prev: string) => string,
BuiltInParserName?,
][] = [
const filesToGenerate: [Path, (prev: string) => string][] = [
[this.workspace.join('tsconfig.json'), this.genProjectTsConfig, 'json'],
[
this.workspace.join('tsconfig.legacy.json'),
this.genPackageTsConfig.bind(this, this.workspace.getPackage('tvh')),
'json',
],
...this.workspace.packages
.filter((p) => p.isTsProject)
// This legacy is handled by tvh's tsconfig.legacy.json
.filter((p) => p.name !== 'tvh')
.map(
(p) =>
[
Expand All @@ -48,22 +51,21 @@ export class Generator {
),
]

for (const [path, content, formatter] of filesToGenerate) {
for (const [path, content] of filesToGenerate) {
this.logger.info(`Generating: ${path}`)
const previous = readFileSync(path.value, 'utf-8')
let file = content(previous)
if (formatter) {
file = await this.format(file, formatter)
}
file = await this.format(path.value, file)
writeFileSync(path.value, file)
}
}

format = (content: string, parser: BuiltInParserName) => {
format = async (path: string, content: string) => {
const config = JSON.parse(
readFileSync(this.workspace.join('.prettierrc').value, 'utf-8')
readFileSync(this.workspace.join('.oxfmtrc.json').value, 'utf-8')
)
return format(content, { parser, ...config })
const output = await format(path, content, config)
return output.code
}

genProjectTsConfig = (prev: string) => {
Expand All @@ -72,9 +74,13 @@ export class Generator {
modify(
prev,
['references'],
this.workspace.packages
.filter((p) => p.isTsProject)
.map((p) => ({ path: p.path.relativePath })),
[
{ path: './tsconfig.legacy.json' },
...this.workspace.packages
.filter((p) => p.isTsProject)
.filter((p) => p.name !== 'tvh')
.map((p) => ({ path: p.path.relativePath })),
],
{}
)
)
Expand Down
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@milkdown/docs",
"private": true,
"version": "1.0.0",
"private": true,
"description": "Auto generated docs for Milkdown",
"scripts": {
"build": "tsx -C import ./src/index.ts"
},
"repository": {
"type": "git",
"url": "https://github.com/Milkdown/milkdown.git"
},
"scripts": {
"build": "tsx -C import ./src/index.ts"
},
"devDependencies": {
"@milkdown/dev": "workspace:*",
"@types/fs-extra": "^11.0.4",
Expand Down
1 change: 1 addition & 0 deletions e2e/shim.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* oxlint-disable no-var */
/// <reference types="node" />
/// <reference types="vite/client" />

import type { Editor, commandsCtx } from '@milkdown/core'
Expand Down
1 change: 0 additions & 1 deletion e2e/src/crepe/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Crepe } from '@milkdown/crepe'
import '@milkdown/crepe/theme/common/style.css'
import '@milkdown/crepe/theme/frame.css'

import { setup } from '../utils'

setup(async () => {
Expand Down
1 change: 1 addition & 0 deletions e2e/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createApp, defineComponent, h } from 'vue'
import './style.css'
import { cases } from './data'

// oxlint-disable-next-line no-unused-expressions
h

const App = defineComponent({
Expand Down
2 changes: 0 additions & 2 deletions e2e/src/multi-editor/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { nord } from '@milkdown/theme-nord'
import { callCommand } from '@milkdown/utils'

import { setup } from '../utils'

import '@milkdown/theme-nord/style.css'

import '../style.css'

setup(() => {
Expand Down
2 changes: 0 additions & 2 deletions e2e/src/plugin-automd/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { markInputRules as GFMMarkInputRules, gfm } from '@milkdown/preset-gfm'
import { nord } from '@milkdown/theme-nord'

import { setup } from '../utils'

import '@milkdown/theme-nord/style.css'

import '../style.css'

setup(() => {
Expand Down
2 changes: 0 additions & 2 deletions e2e/src/plugin-listener/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { commonmark } from '@milkdown/preset-commonmark'
import { nord } from '@milkdown/theme-nord'

import { setup } from '../utils'

import '@milkdown/theme-nord/style.css'

import '../style.css'

setup(() => {
Expand Down
2 changes: 0 additions & 2 deletions e2e/src/preset-commonmark/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import { nord } from '@milkdown/theme-nord'
import { callCommand } from '@milkdown/utils'

import { setup } from '../utils'

import '@milkdown/theme-nord/style.css'

import '../style.css'

setup(() => {
Expand Down
2 changes: 0 additions & 2 deletions e2e/src/preset-gfm/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { gfm } from '@milkdown/preset-gfm'
import { nord } from '@milkdown/theme-nord'

import { setup } from '../utils'

import '@milkdown/theme-nord/style.css'

import '../style.css'

setup(() => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/crepe/table.pom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Page } from '@playwright/test'

import { focusEditor } from 'tests/misc'
import { focusEditor } from '../../tests/misc'

export class TablePageObjectModel {
constructor(
Expand Down
7 changes: 6 additions & 1 deletion e2e/tests/crepe/table.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { expect, test } from '@playwright/test'
import { focusEditor, getMarkdown, paste, waitNextFrame } from 'tests/misc'

import {
focusEditor,
getMarkdown,
paste,
waitNextFrame,
} from '../../tests/misc'
import { TablePageObjectModel } from './table.pom'

test.beforeEach(async ({ page }) => {
Expand Down
1 change: 0 additions & 1 deletion e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"outDir": "lib",
"jsx": "preserve",
Expand Down
48 changes: 0 additions & 48 deletions eslint.config.mjs

This file was deleted.

Loading
Loading