improve eslint config

This commit is contained in:
Philipp Kühn 2020-09-24 09:35:18 +02:00
parent 617cdd4d99
commit 0b40a0db0f
8 changed files with 80 additions and 67 deletions

View File

@ -1,4 +0,0 @@
dist/**
tests/**
**/*.css
**/*.json

View File

@ -1,54 +1,67 @@
module.exports = {
plugins: ['html', 'cypress', '@typescript-eslint'],
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
},
env: {
es6: true,
node: true,
'cypress/globals': true,
},
globals: {
document: false,
window: false,
},
extends: [
'plugin:vue/strongly-recommended',
'airbnb-base',
],
rules: {
semi: ['error', 'never'],
'import/extensions': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'import/no-dynamic-require': 'off',
'arrow-parens': ['error', 'as-needed'],
'padded-blocks': 'off',
'class-methods-use-this': 'off',
'global-require': 'off',
'func-names': ['error', 'never'],
'arrow-body-style': 'off',
'max-len': 'off',
'vue/this-in-template': ['error', 'never'],
'vue/max-attributes-per-line': ['error', {
singleline: 3,
multiline: {
max: 1,
allowFirstLine: false,
overrides: [
{
files: [
'./**/*.ts',
'./**/*.js',
'./**/*.vue',
],
excludedFiles: [
'dist/**',
],
plugins: [
'html',
'cypress',
'@typescript-eslint',
],
env: {
'cypress/globals': true,
},
}],
'no-param-reassign': 'off',
'import/prefer-default-export': 'off',
'consistent-return': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
},
globals: {
document: false,
window: false,
},
extends: [
'plugin:vue/strongly-recommended',
'airbnb-base',
],
rules: {
semi: ['error', 'never'],
'import/extensions': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'import/no-dynamic-require': 'off',
'arrow-parens': ['error', 'as-needed'],
'padded-blocks': 'off',
'class-methods-use-this': 'off',
'global-require': 'off',
'func-names': ['error', 'never'],
'arrow-body-style': 'off',
'max-len': 'off',
'vue/this-in-template': ['error', 'never'],
'vue/max-attributes-per-line': ['error', {
singleline: 3,
multiline: {
max: 1,
allowFirstLine: false,
},
}],
'no-param-reassign': 'off',
'import/prefer-default-export': 'off',
'consistent-return': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
},
},
],
}

View File

@ -15,7 +15,7 @@
"build:docs": "yarn --cwd ./docs build",
"build:packages": "yarn clean:packages && lerna exec --parallel -- microbundle --compress",
"clean:packages": "rm -rf ./packages/*/dist",
"lint": "eslint --quiet --no-error-on-unmatched-pattern --ext .js,.jsx,.ts,.vue ./docs ./packages",
"lint": "eslint --quiet --no-error-on-unmatched-pattern ./",
"test:open": "cypress open --project tests",
"test": "cypress run --project tests",
"reset": "yarn clean:packages && rm -rf ./**/.cache && rm -rf ./**/node_modules && rm -rf ./yarn.lock && yarn install"

View File

@ -131,6 +131,7 @@ export class Editor extends EventEmitter {
*
* @param name The name of the command
*/
// eslint-disable-next-line
private __get(name: string) {
return this.commandManager.runSingleCommand(name)
}

View File

@ -1,19 +1,19 @@
export default class EventEmitter {
_callbacks: { [key: string]: Function[] } = {}
private callbacks: { [key: string]: Function[] } = {}
on(event: string, fn: Function) {
if (!this._callbacks[event]) {
this._callbacks[event] = []
public on(event: string, fn: Function) {
if (!this.callbacks[event]) {
this.callbacks[event] = []
}
this._callbacks[event].push(fn)
this.callbacks[event].push(fn)
return this
}
emit(event: string, ...args: any) {
const callbacks = this._callbacks[event]
protected emit(event: string, ...args: any) {
const callbacks = this.callbacks[event]
if (callbacks) {
callbacks.forEach(callback => callback.apply(this, args))
@ -22,21 +22,21 @@ export default class EventEmitter {
return this
}
off(event: string, fn?: Function) {
const callbacks = this._callbacks[event]
public off(event: string, fn?: Function) {
const callbacks = this.callbacks[event]
if (callbacks) {
if (fn) {
this._callbacks[event] = callbacks.filter(callback => callback !== fn)
this.callbacks[event] = callbacks.filter(callback => callback !== fn)
} else {
delete this._callbacks[event]
delete this.callbacks[event]
}
}
return this
}
removeAllListeners() {
this._callbacks = {}
protected removeAllListeners() {
this.callbacks = {}
}
}

View File

@ -2,12 +2,13 @@ import deepmerge from 'deepmerge'
import collect from 'collect.js'
import { Plugin } from 'prosemirror-state'
import { keymap } from 'prosemirror-keymap'
import { Schema, Node as ProsemirrorNode } from 'prosemirror-model'
import { Schema } from 'prosemirror-model'
// import { Schema, Node as ProsemirrorNode } from 'prosemirror-model'
import { inputRules } from 'prosemirror-inputrules'
import { EditorView, Decoration } from 'prosemirror-view'
// import { EditorView, Decoration } from 'prosemirror-view'
import { Editor } from './Editor'
import capitalize from './utils/capitalize'
// import capitalize from './utils/capitalize'
import { Extensions } from './types'
import getTopNodeFromExtensions from './utils/getTopNodeFromExtensions'
import getNodesFromExtensions from './utils/getNodesFromExtensions'

7
shims/vue.d.ts vendored
View File

@ -1,4 +1,5 @@
declare module "*.vue" {
import Vue from "vue"
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
}

View File

@ -11,6 +11,7 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
// eslint-disable-next-line
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config