Skip to content

Commit

Permalink
styles: updata eslint to v9 (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
tolking authored Dec 6, 2024
1 parent b5cea07 commit 45a6e4f
Show file tree
Hide file tree
Showing 149 changed files with 1,605 additions and 1,832 deletions.
28 changes: 0 additions & 28 deletions .eslintrc.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 0 additions & 4 deletions .lintstagedrc

This file was deleted.

2 changes: 1 addition & 1 deletion build/build-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function transform(input: string) {
}
}

(() => {
;(() => {
fg.sync(toAbsolute('../src/styles/*')).map(transform)
console.log('build-styles done')
})()
11 changes: 2 additions & 9 deletions build/plugin/create-container.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import container from 'markdown-it-container'
import type Token from 'markdown-it/lib/token'

type ContainerArgs = [
typeof container,
string,
{
render(tokens: Token[], idx: number): string
}
]
type ContainerArgs = [typeof container, string, container.ContainerOpts]

export default function createContainer(
klass: string,
defaultTitle: string
defaultTitle: string,
): ContainerArgs {
return [
container,
Expand Down
22 changes: 16 additions & 6 deletions build/plugin/demo.ts → build/plugin/create-demo.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { existsSync, readFileSync } from 'node:fs'
import markdown from 'markdown-it'
import { camelize } from '../utils'
import highlight from './highlight'
import type Token from 'markdown-it/lib/token'
import type MarkdownItContainer from 'markdown-it-container'
import type MarkdownIt from 'markdown-it'

let scripts: string[] = []
let count = 0
let isFirst = true

export default {
render: (tokens: Token[], idx: number): string => {
export default function createDemoContainer(md: MarkdownIt) {
const render: MarkdownItContainer.ContainerOpts['render'] = (
tokens,
idx: number,
) => {
const { nesting, info = '' } = tokens[idx]

if (nesting === 1) {
Expand All @@ -23,7 +26,7 @@ export default {

const matchedInfo = info.trim().match(/^demo\s+(.*)$/)
const description = matchedInfo && matchedInfo[1]
const descTemplate = markdown().render(description || '')
const descTemplate = md.render(description || '')
const link = tokens[idx + 2].content.trim()
const componentName = link.replace(/^@\/demo\/(.*).vue/, (_, $1) => {
return $1.replace(/\//g, '-').toLocaleLowerCase()
Expand Down Expand Up @@ -60,5 +63,12 @@ export default {
return '</pro-code>'
}
}
},
}

return {
validate(params) {
return !!params.trim().match(/^demo\s*(.*)$/)
},
render,
}
}
10 changes: 7 additions & 3 deletions build/plugin/external-link-icon.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import type MarkdownIt from 'markdown-it'
import type Renderer from 'markdown-it/lib/renderer'

type RenderRule = Exclude<
MarkdownIt['renderer']['rules']['container'],
undefined
>

export default (md: MarkdownIt): void => {
const renderToken: Renderer.RenderRule = (tokens, idx, options, env, self) =>
const renderToken: RenderRule = (tokens, idx, options, env, self) =>
self.renderToken(tokens, idx, options)
const defaultLinkOpenRenderer = md.renderer.rules.link_open || renderToken
const defaultLinkCloseRenderer = md.renderer.rules.link_close || renderToken
Expand Down Expand Up @@ -30,7 +34,7 @@ export default (md: MarkdownIt): void => {
return `<icon-external-link class="link-icon" />${self.renderToken(
tokens,
idx,
options
options,
)}`
}

Expand Down
1 change: 1 addition & 0 deletions build/plugin/highlight.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// copy from [vitepress](https://github.com/vuejs/vitepress)
// MIT License Copyright (c) 2019-present, Yuxi (Evan) You
import prism from 'prismjs'
import loadLanguages from 'prismjs/components/index'
import escapeHtml from 'escape-html'
Expand Down
2 changes: 1 addition & 1 deletion build/plugin/pre-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// copy from [vitepress](https://github.com/vuejs/vitepress)
// MIT License Copyright (c) 2019-present, Yuxi (Evan) You
import MarkdownIt from 'markdown-it'

export default (md: MarkdownIt): void => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const fence = md.renderer.rules.fence!
md.renderer.rules.fence = (...args) => {
const [tokens, idx] = args
Expand Down
88 changes: 45 additions & 43 deletions build/plugin/snippet.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
// copy from [vitepress](https://github.com/vuejs/vitepress)
import fs from 'fs'
// MIT License Copyright (c) 2019-present, Yuxi (Evan) You
import { existsSync, readFileSync } from 'node:fs'
import MarkdownIt from 'markdown-it'
import { RuleBlock } from 'markdown-it/lib/parser_block'

export default (md: MarkdownIt): void => {
const parser: RuleBlock = (state, startLine, endLine, silent) => {
const CH = '<'.charCodeAt(0)
const pos = state.bMarks[startLine] + state.tShift[startLine]
const max = state.eMarks[startLine]

// if it's indented more than 3 spaces, it should be a code block
if (state.sCount[startLine] - state.blkIndent >= 4) {
return false
}

for (let i = 0; i < 3; ++i) {
const ch = state.src.charCodeAt(pos + i)
if (ch !== CH || pos + i >= max) return false
}

if (silent) {
md.block.ruler.before(
'fence',
'snippet',
(state, startLine, endLine, silent) => {
const CH = '<'.charCodeAt(0)
const pos = state.bMarks[startLine] + state.tShift[startLine]
const max = state.eMarks[startLine]

// if it's indented more than 3 spaces, it should be a code block
if (state.sCount[startLine] - state.blkIndent >= 4) {
return false
}

for (let i = 0; i < 3; ++i) {
const ch = state.src.charCodeAt(pos + i)
if (ch !== CH || pos + i >= max) return false
}

if (silent) {
return true
}

const start = pos + 3
const end = state.skipSpacesBack(max, pos)
const rawPath = state.src
.slice(start, end)
.trim()
.replace(/^@/, process.cwd())
const content = existsSync(rawPath)
? readFileSync(rawPath).toString()
: 'Not found: ' + rawPath
const meta = rawPath.replace(rawPath, '')

state.line = startLine + 1

const token = state.push('fence', 'code', 0)
token.info = rawPath.split('.').pop() + meta
token.content = content
token.markup = '```'
token.map = [startLine, startLine + 1]

return true
}

const start = pos + 3
const end = state.skipSpacesBack(max, pos)
const rawPath = state.src
.slice(start, end)
.trim()
.replace(/^@/, process.cwd())
const content = fs.existsSync(rawPath)
? fs.readFileSync(rawPath).toString()
: 'Not found: ' + rawPath
const meta = rawPath.replace(rawPath, '')

state.line = startLine + 1

const token = state.push('fence', 'code', 0)
token.info = rawPath.split('.').pop() + meta
token.content = content
token.markup = '```'
token.map = [startLine, startLine + 1]

return true
}

md.block.ruler.before('fence', 'snippet', parser)
},
)
}
2 changes: 1 addition & 1 deletion build/sync-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function transform(input: string) {
copyFileRecursive(input, outDir)
}

(() => {
;(() => {
fg.sync([
toAbsolute('../types/locale/*'),
toAbsolute('../types/styles/*'),
Expand Down
2 changes: 1 addition & 1 deletion demo/AutocompleteTag/base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineComponent({
? list.filter((i) => {
return i.value.indexOf(queryString.toLowerCase()) === 0
})
: list
: list,
)
}
Expand Down
4 changes: 1 addition & 3 deletions demo/Card/base.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<template>
<pro-card header="header">
Content
</pro-card>
<pro-card header="header"> Content </pro-card>
</template>
26 changes: 4 additions & 22 deletions demo/Card/direction.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
<template>
<pro-radio-button
v-model="direction"
:data="data"
/>
<pro-radio-button v-model="direction" :data="data" />
<pro-card :direction="direction">
<pro-card
:span="12"
shadow="never"
>
span-12
</pro-card>
<pro-card
:span="6"
shadow="never"
>
span-6
</pro-card>
<pro-card
:span="3"
shadow="never"
>
span-3
</pro-card>
<pro-card :span="12" shadow="never"> span-12 </pro-card>
<pro-card :span="6" shadow="never"> span-6 </pro-card>
<pro-card :span="3" shadow="never"> span-3 </pro-card>
</pro-card>
</template>

Expand Down
4 changes: 1 addition & 3 deletions demo/Card/ghost.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<el-switch v-model="ghost" />
<pro-card :ghost="ghost">
Content
</pro-card>
<pro-card :ghost="ghost"> Content </pro-card>
</template>

<script>
Expand Down
Loading

0 comments on commit 45a6e4f

Please sign in to comment.