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

chore(deps): update dependency typescript to v4.9.5 #129

Merged
merged 4 commits into from
Sep 26, 2024
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
68 changes: 40 additions & 28 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,20 @@ module.exports = {
sourceType: 'module',
},
env: {
browser: true,
es6: true,
jest: true,
node: true,
webextensions: false,
},
overrides: [
{
files: [
'./**/*.ts',
'./**/*.tsx',
'./**/*.js',
'./**/*.jsx',
],
files: ['./**/*.ts', './**/*.tsx', './**/*.js', './**/*.jsx'],
extends: ['plugin:react-hooks/recommended'],
},
{
files: [
'./**/*.ts',
'./**/*.tsx',
'./**/*.js',
'./**/*.jsx',
'./**/*.vue',
],
plugins: [
'html',
'cypress',
'@typescript-eslint',
'simple-import-sort',
],
files: ['./**/*.ts', './**/*.tsx', './**/*.js', './**/*.jsx', './**/*.vue'],
plugins: ['html', 'cypress', '@typescript-eslint', 'simple-import-sort'],
env: {
'cypress/globals': true,
},
Expand All @@ -45,15 +32,26 @@ module.exports = {
'airbnb-base',
],
rules: {
'import/extensions': [
'error',
'ignorePackages',
{
'': 'never',
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
curly: ['error', 'all'],
'newline-after-var': ['error', 'always'],
'no-continue': 'off',
'no-alert': 'off',
'no-console': ['warn', { allow: ['warn', 'error'] }],
semi: ['error', 'never'],
'import/order': 'off',
'import/extensions': ['error', 'ignorePackages'],
'no-restricted-imports': ['error',
'no-restricted-imports': [
'error',
{
paths: [
{
Expand All @@ -67,6 +65,17 @@ module.exports = {
],
},
],
'no-restricted-syntax': [
'off',
{
selector: 'ForOfStatement',
message: 'Avoid using for...of loops',
},
{
selector: 'YieldExpression',
message: 'Avoid using generators and yield.',
},
],
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'import/no-dynamic-require': 'off',
Expand All @@ -81,14 +90,17 @@ module.exports = {
'vue/one-component-per-file': 'off',
'vue/this-in-template': ['error', 'never'],
'vue/multi-word-component-names': 'off',
'vue/max-attributes-per-line': ['error', {
singleline: {
max: 3,
},
multiline: {
max: 1,
'vue/max-attributes-per-line': [
'error',
{
singleline: {
max: 3,
},
multiline: {
max: 1,
},
},
}],
],
'vue/singleline-html-element-content-newline': 'off',
'no-param-reassign': 'off',
'import/prefer-default-export': 'off',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"ts-jest": "^27.0.4",
"tslib": "^2.3.0",
"turbo": "2.0.6",
"typescript": "4.3.2"
"typescript": "4.9.5"
},
"commitlint": {
"extends": [
Expand Down
17 changes: 15 additions & 2 deletions packages/core/__tests__/editor/dom-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
*/

import { Editor, Range as SlateRange } from 'slate'

import { DomEditor } from '../../src/editor/dom-editor'
import { IDomEditor } from '../../src/editor/interface'
import createCoreEditor from '../create-core-editor' // packages/core 不依赖 packages/editor ,不能使用后者的 createEditor
import { Key } from '../../src/utils/key'
import { NODE_TO_KEY } from '../../src/utils/weak-maps'
import createCoreEditor from '../create-core-editor' // packages/core 不依赖 packages/editor ,不能使用后者的 createEditor

let editor: IDomEditor

Expand All @@ -30,7 +31,7 @@ describe('Core DomEditor', () => {
try {
DomEditor.getWindow(editor)
} catch (err) {
expect(err.message).toBe('Unable to find a host window element for this editor')
expect((err as Error).message).toBe('Unable to find a host window element for this editor')
}
})

Expand Down Expand Up @@ -83,6 +84,7 @@ describe('Core DomEditor', () => {
expect(NODE_TO_KEY.get(node)).toBeUndefined()

const newKey = DomEditor.findKey(editor, node)

expect(NODE_TO_KEY.get(node)).toEqual(newKey)
})

Expand All @@ -105,11 +107,13 @@ describe('Core DomEditor', () => {
const textNode = p.children[0]

const path = DomEditor.findPath(null, textNode)

expect(path).toEqual([0, 0])
})

test('findDocumentOrShadowRoot', () => {
const doc = DomEditor.findDocumentOrShadowRoot(editor)

expect(doc).toBe(document)
})

Expand All @@ -128,6 +132,7 @@ describe('Core DomEditor', () => {
const textNode = p.children[0]

const parents = DomEditor.getParentsNodes(editor, textNode)

expect(parents[0]).toBe(p)
expect(parents[1]).toBe(editor)
})
Expand All @@ -138,6 +143,7 @@ describe('Core DomEditor', () => {
const textNode = p.children[0]

const topNode = DomEditor.getTopNode(editor, textNode)

expect(topNode).toBe(p)
})

Expand All @@ -147,6 +153,7 @@ describe('Core DomEditor', () => {
const key = DomEditor.findKey(editor, p)

const domNode = DomEditor.toDOMNode(editor, p)

expect(domNode.tagName).toBe('DIV')
expect(domNode.id).toBe(`w-e-element-${key.id}`)
})
Expand All @@ -156,6 +163,7 @@ describe('Core DomEditor', () => {
const domNode = DomEditor.toDOMNode(editor, p)

const res = DomEditor.hasDOMNode(editor, domNode)

expect(res).toBeTruthy()
})

Expand All @@ -170,6 +178,7 @@ describe('Core DomEditor', () => {
const domNode = DomEditor.toDOMNode(editor, p)

const slateNode = DomEditor.toSlateNode(null, domNode)

expect(slateNode).toBe(p)
})

Expand All @@ -187,6 +196,7 @@ describe('Core DomEditor', () => {
editor.selectAll()

const res = DomEditor.hasRange(editor, editor.selection as SlateRange)

expect(res).toBeTruthy()

// expect(1).toBe(1)
Expand All @@ -203,6 +213,7 @@ describe('Core DomEditor', () => {

test('checkNodeType', () => {
const p = editor.children[0]

expect(DomEditor.checkNodeType(p, 'paragraph')).toBeTruthy()
})

Expand All @@ -222,6 +233,7 @@ describe('Core DomEditor', () => {
test('getSelectedNodeByType', () => {
const p = editor.children[0]
const selectedNode = DomEditor.getSelectedNodeByType(editor, 'paragraph')

expect(selectedNode).toBe(p)
})

Expand All @@ -231,6 +243,7 @@ describe('Core DomEditor', () => {
const textNode = p.children[0]

const selectedTextNode = DomEditor.getSelectedTextNode(editor)

expect(selectedTextNode).toBe(textNode)
})

Expand Down
Loading