mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-03-27 09:13:30 +00:00
Add ESLint plugin for Jest (#2098)
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
5a04cb092d
commit
4d63a5ce2a
5 changed files with 42 additions and 13 deletions
.eslintrc.jsonpackage.jsonyarn.lock
src
components/markdown-renderer/utils
redux/note-details/format-selection
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"root": true,
|
||||
"parserOptions": {
|
||||
"tsconfigRootDir": "",
|
||||
"tsconfigRootDir": ".",
|
||||
"project": [
|
||||
"./tsconfig.json"
|
||||
]
|
||||
|
@ -16,11 +16,21 @@
|
|||
"prefer": "type-imports",
|
||||
"disallowTypeAnnotations": false
|
||||
}
|
||||
]
|
||||
],
|
||||
"jest/no-disabled-tests": "warn",
|
||||
"jest/no-focused-tests": "error",
|
||||
"jest/no-identical-title": "error",
|
||||
"jest/prefer-to-have-length": "warn",
|
||||
"jest/valid-expect": "error"
|
||||
},
|
||||
"env": {
|
||||
"jest": true,
|
||||
"jest/globals": true
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"testing-library"
|
||||
"testing-library",
|
||||
"jest"
|
||||
],
|
||||
"extends": [
|
||||
"next/core-web-vitals",
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-chai-friendly": "0.7.2",
|
||||
"eslint-plugin-cypress": "2.12.1",
|
||||
"eslint-plugin-jest": "26.4.6",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "6.0.0",
|
||||
"eslint-plugin-testing-library": "5.5.1",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ import { NodeToReactTransformer } from './node-to-react-transformer'
|
|||
import { Element } from 'domhandler'
|
||||
import type { ReactElement, ReactHTMLElement } from 'react'
|
||||
import type { NodeReplacement } from '../replace-components/component-replacer'
|
||||
import { DO_NOT_REPLACE, REPLACE_WITH_NOTHING } from '../replace-components/component-replacer'
|
||||
import { ComponentReplacer, DO_NOT_REPLACE, REPLACE_WITH_NOTHING } from '../replace-components/component-replacer'
|
||||
|
||||
describe('node to react transformer', () => {
|
||||
let nodeToReactTransformer: NodeToReactTransformer
|
||||
|
@ -28,11 +28,11 @@ describe('node to react transformer', () => {
|
|||
|
||||
it('can replace an element nothing', () => {
|
||||
nodeToReactTransformer.setReplacers([
|
||||
{
|
||||
new (class extends ComponentReplacer {
|
||||
replace(): NodeReplacement {
|
||||
return REPLACE_WITH_NOTHING
|
||||
}
|
||||
}
|
||||
})()
|
||||
])
|
||||
const translation = nodeToReactTransformer.translateNodeToReactElement(defaultTestSpanElement, 1) as ReactElement
|
||||
expect(translation).toEqual(null)
|
||||
|
@ -40,11 +40,11 @@ describe('node to react transformer', () => {
|
|||
|
||||
it('can translate an element with no matching replacer', () => {
|
||||
nodeToReactTransformer.setReplacers([
|
||||
{
|
||||
new (class extends ComponentReplacer {
|
||||
replace(): NodeReplacement {
|
||||
return DO_NOT_REPLACE
|
||||
}
|
||||
}
|
||||
})()
|
||||
])
|
||||
const translation = nodeToReactTransformer.translateNodeToReactElement(defaultTestSpanElement, 1) as ReactElement
|
||||
|
||||
|
@ -54,11 +54,11 @@ describe('node to react transformer', () => {
|
|||
|
||||
it('can replace an element', () => {
|
||||
nodeToReactTransformer.setReplacers([
|
||||
{
|
||||
new (class extends ComponentReplacer {
|
||||
replace(): NodeReplacement {
|
||||
return <div data-test2={'test2'} />
|
||||
}
|
||||
}
|
||||
})()
|
||||
])
|
||||
const translation = nodeToReactTransformer.translateNodeToReactElement(defaultTestSpanElement, 1) as ReactElement
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ describe('apply format type to markdown lines', () => {
|
|||
expect(prependLinesOfSelectionMock).toBeCalledWith(markdownContentMock, cursorSelectionMock, expect.anything())
|
||||
})
|
||||
|
||||
it('can process the format type unordered list', () => {
|
||||
it('can process the format type ordered list', () => {
|
||||
const result = applyFormatTypeToMarkdownLines(markdownContentMock, cursorSelectionMock, FormatType.ORDERED_LIST)
|
||||
expect(result).toEqual(['1. input', cursorSelectionMock])
|
||||
expect(prependLinesOfSelectionMock).toBeCalledWith(markdownContentMock, cursorSelectionMock, expect.anything())
|
||||
|
|
20
yarn.lock
20
yarn.lock
|
@ -2050,6 +2050,7 @@ __metadata:
|
|||
eslint-config-prettier: 8.5.0
|
||||
eslint-plugin-chai-friendly: 0.7.2
|
||||
eslint-plugin-cypress: 2.12.1
|
||||
eslint-plugin-jest: 26.4.6
|
||||
eslint-plugin-node: 11.1.0
|
||||
eslint-plugin-promise: 6.0.0
|
||||
eslint-plugin-testing-library: 5.5.1
|
||||
|
@ -5127,7 +5128,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@typescript-eslint/utils@npm:5.27.0, @typescript-eslint/utils@npm:^5.13.0":
|
||||
"@typescript-eslint/utils@npm:5.27.0, @typescript-eslint/utils@npm:^5.10.0, @typescript-eslint/utils@npm:^5.13.0":
|
||||
version: 5.27.0
|
||||
resolution: "@typescript-eslint/utils@npm:5.27.0"
|
||||
dependencies:
|
||||
|
@ -9899,6 +9900,23 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"eslint-plugin-jest@npm:26.4.6":
|
||||
version: 26.4.6
|
||||
resolution: "eslint-plugin-jest@npm:26.4.6"
|
||||
dependencies:
|
||||
"@typescript-eslint/utils": ^5.10.0
|
||||
peerDependencies:
|
||||
"@typescript-eslint/eslint-plugin": ^5.0.0
|
||||
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
peerDependenciesMeta:
|
||||
"@typescript-eslint/eslint-plugin":
|
||||
optional: true
|
||||
jest:
|
||||
optional: true
|
||||
checksum: 1d4c35282abecbc3656f9a355c3e63df0b4134fae208ceb9ee75421ed95f6a108753ac86b54d9302f4ae192227c41b45a50034854e75fad3691868eaab8394a2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"eslint-plugin-jsx-a11y@npm:^6.5.1":
|
||||
version: 6.5.1
|
||||
resolution: "eslint-plugin-jsx-a11y@npm:6.5.1"
|
||||
|
|
Loading…
Reference in a new issue