add precommit hook for linting and automatic eslint fixes + update eslint packages (#2862)

* chore: add precommit hook for eslint fixes, fix linting issues
* chore: add eslint import sort plugin
This commit is contained in:
Dominik
2022-06-08 14:10:25 +02:00
committed by GitHub
parent 39f5e4c31e
commit 8c6751f0c6
394 changed files with 1328 additions and 1042 deletions

View File

@@ -15,7 +15,8 @@ export class BadWords extends LinterPlugin {
if (matches) {
this.record(
`Try not to say '${matches[0]}'`,
position + matches.index, position + matches.index + matches[0].length,
position + matches.index,
position + matches.index + matches[0].length,
)
}
})

View File

@@ -1,4 +1,5 @@
import { EditorView } from 'prosemirror-view'
import LinterPlugin, { Result as Issue } from '../LinterPlugin'
export class HeadingLevel extends LinterPlugin {
@@ -17,9 +18,12 @@ export class HeadingLevel extends LinterPlugin {
const { level } = node.attrs
if (lastHeadLevel != null && level > lastHeadLevel + 1) {
this.record(`Heading too small (${level} under ${lastHeadLevel})`,
position + 1, position + 1 + node.content.size,
this.fixHeader(lastHeadLevel + 1))
this.record(
`Heading too small (${level} under ${lastHeadLevel})`,
position + 1,
position + 1 + node.content.size,
this.fixHeader(lastHeadLevel + 1),
)
}
lastHeadLevel = level
}

View File

@@ -1,4 +1,5 @@
import { EditorView } from 'prosemirror-view'
import LinterPlugin, { Result as Issue } from '../LinterPlugin'
export class Punctuation extends LinterPlugin {
@@ -8,7 +9,8 @@ export class Punctuation extends LinterPlugin {
return function ({ state, dispatch }: EditorView, issue: Issue) {
dispatch(
state.tr.replaceWith(
issue.from, issue.to,
issue.from,
issue.to,
state.schema.text(replacement),
),
)
@@ -30,7 +32,8 @@ export class Punctuation extends LinterPlugin {
if (matches) {
this.record(
'Suspicious spacing around punctuation',
position + matches.index, position + matches.index + matches[0].length,
position + matches.index,
position + matches.index + matches[0].length,
this.fix(`${matches[1]} `),
)
}