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
10 changes: 0 additions & 10 deletions .eslintignore

This file was deleted.

31 changes: 0 additions & 31 deletions .eslintrc.js

This file was deleted.

76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import js from '@eslint/js'
import { configureVueProject, defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import globals from 'globals'

configureVueProject({
scriptLangs: ['ts', 'js', 'tsx', 'jsx']
})

export default defineConfigWithVueTs(
{
ignores: [
'.vscode',
'docs',
'**/dist',
'**/public',
'**/package-lock.json',
'**/node_modules',
'**/tmp',
'**/temp',
'mockServer',
'**/bin',
'**/expected',
'**/output',
'**/test'
]
},
{
files: ['**/*.{js,mjs,jsx,ts,mts,tsx,vue}']
},
js.configs.recommended,
pluginVue.configs['flat/essential'],
vueTsConfigs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
...globals.worker,
...globals.node,
...globals.jest
}
},
rules: {
'no-console': 'error',
'no-debugger': 'error',
'no-eq-null': 'error',
'no-extra-semi': 'off',
'no-eval': 'error',
'space-before-function-paren': 'off',
'vue/multi-word-component-names': 'off',
'vue/prefer-import-from-vue': 'off',
// 允许 @ts-ignore
'@typescript-eslint/ban-ts-comment': 'off',
// 允许非空断言
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
caughtErrors: 'none'
}
]
}
},
{
files: ['scripts/**/*'],
rules: {
'no-console': 'off',
'@typescript-eslint/no-require-imports': 'off'
}
}
)
4 changes: 2 additions & 2 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'./packages/**/**.{js,vue,jsx}': 'eslint',
'./packages/**/**.{vue,js,ts,html,json,less}': 'prettier --write'
'./packages/**/**.{js,mjs,jsx,ts,mts,tsx,vue}': 'eslint',
'./packages/**/**.{js,mjs,jsx,ts,mts,tsx,vue,html,json,less}': 'prettier --write'
}
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"build:alpha": "pnpm --filter designer-demo build:alpha",
"build:prod": "pnpm --filter designer-demo build",
"buildComponentSchemas": "node scripts/buildComponentSchemas.js",
"lint": "eslint . --ext .js,.vue,.jsx --fix",
"format": "prettier --write **/*{.vue,.js,.ts,.html,.json}",
"lint": "eslint . --ext .js,.mjs,.jsx,.ts,.mts,.tsx,.vue --fix",
"format": "prettier --write --list-different **/*{.vue,.js,.mjs,.jsx,.ts,.mts,.tsx,.html,.json}",
"prepare": "node -e \"if(require('fs').existsSync('.git')){process.exit(1)}\" || husky install",
"pub:premajor": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version premajor --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes",
"pub:preminor": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version preminor --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes",
Expand All @@ -23,24 +23,26 @@
"updateTemplate": "node ./scripts/updateTemplate.mjs"
},
"devDependencies": {
"@babel/eslint-parser": "^7.21.3",
"@eslint/js": "^8.57.1",
"@types/node": "^18.0.0",
"@vue/eslint-config-typescript": "^11.0.3",
"@vue/eslint-config-typescript": "^14.4.0",
"@vue/tsconfig": "^0.7.0",
"chokidar": "^3.5.3",
"concurrently": "^8.2.0",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"eslint": "^8.38.0",
"eslint-plugin-vue": "^8.0.0",
"eslint": "^9.21.0",
"eslint-plugin-vue": "^9.32.0",
"fast-glob": "^3.3.2",
"fs-extra": "^10.1.0",
"globals": "^16.0.0",
"husky": "^8.0.0",
"lerna": "^7.2.0",
"lint-staged": "^13.2.0",
"mysql": "^2.18.1",
"picocolors": "^1.0.0",
"prettier": "^2.7.1",
"vue-eslint-parser": "^8.0.1"
"typescript": "~5.4.5"
},
"browserslist": [
"> 1%",
Expand Down
27 changes: 0 additions & 27 deletions packages/block-compiler/.eslintrc.cjs

This file was deleted.

19 changes: 19 additions & 0 deletions packages/block-compiler/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import rootConfig from '../../eslint.config.mjs'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

/** @type {import('eslint').Linter.Config[]} */
export default [
...rootConfig,
{
languageOptions: {
parserOptions: {
projectService: true,
project: [path.join(__dirname, './tsconfig.json')]
}
}
}
]
2 changes: 1 addition & 1 deletion packages/block-compiler/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts", ".eslintrc.cjs"]
"include": ["vite.config.ts", "eslint.config.mjs"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export function relativePathPattern(relativePath) {
}

export function resolvePath(importPath, currentFilePath) {
if (['js', 'mjs'].some(suffix =>importPath.endsWith(suffix))) { // 文件名已经带有.js,.mjs后缀
if (['js', 'mjs'].some((suffix) => importPath.endsWith(suffix))) {
// 文件名已经带有.js,.mjs后缀
return importPath
}
const parentPath = path.resolve(currentFilePath, '../')
Expand All @@ -21,9 +22,9 @@ export function resolvePath(importPath, currentFilePath) {
const stat = fs.statSync(filePrefix)
if (stat.isDirectory()) {
let mainFileName = 'index.js'

const packageFile = path.resolve(filePrefix, 'package.json')

if (fs.existsSync(packageFile)) {
const packageFileContent = fs.readFileSync(packageFile, { encoding: 'utf-8' })
const packageJson = JSON.parse(packageFileContent)
Expand All @@ -39,7 +40,7 @@ export function resolvePath(importPath, currentFilePath) {
return importPath
}
const possibleSuffix = ['.js', '.mjs']
const suffix = possibleSuffix.find(suf => fs.existsSync(filePrefix + suf))
const suffix = possibleSuffix.find((suf) => fs.existsSync(filePrefix + suf))
if (suffix) {
return relativePathPattern(path.relative(path.resolve(currentFilePath, '../'), filePrefix + suffix))
}
Expand All @@ -62,16 +63,16 @@ export function babelReplaceImportPathWithCertainFileName(content, currentFilePa
return
}
const importPath = node.source.value
if(importPath.startsWith('.')) {
if (importPath.startsWith('.')) {
const certainPath = resolvePath(importPath, currentFilePath)
if(!certainPath) {
if (!certainPath) {
logger.warn(`File not found: ${importPath} used in ${currentFilePath}`)
result.error.push(importPath)
}
if(certainPath !== importPath) {
if (certainPath !== importPath) {
node.source.value = certainPath
fileChangedMark = true
result.success.push({before: importPath, after: certainPath})
result.success.push({ before: importPath, after: certainPath })
}
}
}
Expand All @@ -86,4 +87,3 @@ export function babelReplaceImportPathWithCertainFileName(content, currentFilePa
}
return result
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getDevAlias = (useSourceAlias) => {
'@opentiny/tiny-engine-plugin-datasource': path.resolve(basePath, 'packages/plugins/datasource/index.js'),
'@opentiny/tiny-engine-plugin-script': path.resolve(basePath, 'packages/plugins/script/index.js'),
'@opentiny/tiny-engine-plugin-tree': path.resolve(basePath, 'packages/plugins/tree/index.js'),
'@opentiny/tiny-engine-plugin-help': path.resolve(basePath, 'packages/plugins/help/index.js'),
'@opentiny/tiny-engine-plugin-help': path.resolve(basePath, 'packages/plugins/help/index.ts'),
'@opentiny/tiny-engine-plugin-schema': path.resolve(basePath, 'packages/plugins/schema/index.js'),
'@opentiny/tiny-engine-plugin-page': path.resolve(basePath, 'packages/plugins/page/index.js'),
'@opentiny/tiny-engine-plugin-i18n': path.resolve(basePath, 'packages/plugins/i18n/index.js'),
Expand Down
9 changes: 5 additions & 4 deletions packages/canvas/DesignCanvas/src/api/useCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*
*/

/* eslint-disable no-new-func */
import { reactive, ref, toRaw } from 'vue'
import * as jsonDiffPatch from 'jsondiffpatch'
import DiffMatchPatch from 'diff-match-patch'
Expand Down Expand Up @@ -90,7 +89,7 @@ const handleTinyGridColumnsSlots = (node) => {
nodesMap.value.set(item.id, { node: item, parent: node })

if (Array.isArray(item.children)) {
// eslint-disable-next-line no-use-before-define
// eslint-disable-next-line @typescript-eslint/no-use-before-define
generateNodesMap(item.children, item)
}
})
Expand Down Expand Up @@ -589,10 +588,12 @@ const getSchema = () => {
const getNodePath = (id, nodes = []) => {
const { parent, node } = getNodeWithParentById(id) || {}

node && nodes.unshift({ name: node.componentName, node: id })
if (node) {
nodes.unshift({ name: node.componentName, node: id })
}

if (parent) {
parent && getNodePath(parent.id, nodes)
getNodePath(parent.id, nodes)
} else {
nodes.unshift({ name: 'BODY', node: id })
}
Expand Down
4 changes: 2 additions & 2 deletions packages/canvas/container/src/CanvasContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export default {
const insertPanel = ref(null)
const insertPosition = ref(false)
const loading = computed(() => useCanvas().isLoading())
let showSettingModel = ref(false)
let target = ref(null)
const showSettingModel = ref(false)
const target = ref(null)
const srcAttrName = computed(() => (props.canvasSrc ? 'src' : 'srcdoc'))

const containerPanel = ref(null)
Expand Down
13 changes: 7 additions & 6 deletions packages/canvas/container/src/components/CanvasAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ export default {
const toIndex = index + addend

if (toIndex > -1 && toIndex < list.length) {
// eslint-disable-next-line no-extra-semi
;[list[index], list[toIndex]] = [list[toIndex], list[index]]

updateRect()
Expand All @@ -228,7 +227,9 @@ export default {

const selectParent = () => {
const parentId = getCurrent().parent?.id
parentId && selectNode(parentId)
if (parentId) {
selectNode(parentId)
}
}

const copy = () => {
Expand Down Expand Up @@ -266,20 +267,20 @@ export default {
const optionRef = ref(null)
const fixStyle = ref('')

let showPopover = ref(false)
const showPopover = ref(false)

const activeSetting = () => {
showPopover.value = false
}

const findParentHasClass = (target) => {
let parent = target.parentNode
const parent = target.parentNode

if (parent.className === undefined) {
return false
}

let name = JSON.stringify(parent.className)
const name = JSON.stringify(parent.className)

const preventClassNameList = ['short-cut-set', 'tiny-dialog-box', 'icon-popover', 'i18n-input-popover']

Expand Down Expand Up @@ -313,7 +314,7 @@ export default {
() => props.windowGetClickEventTarget,
(newProps) => {
if (newProps) {
let flag = findParentHasClass(newProps)
const flag = findParentHasClass(newProps)
if (!flag) {
showPopover.value = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default {
}

if (state.direction === 'vertical') {
let target = schema.componentName === 'CanvasRow' ? schema : parent
const target = schema.componentName === 'CanvasRow' ? schema : parent
const dis = clientY - state.startPosition.y
const minHeight = state.startPosition.height + dis

Expand Down
Loading