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 = { module.exports = {
plugins: ['html', 'cypress', '@typescript-eslint'],
parserOptions: { parserOptions: {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
sourceType: 'module', sourceType: 'module',
}, },
env: { env: {
es6: true, es6: true,
node: true, node: true,
'cypress/globals': true,
}, },
overrides: [
globals: { {
document: false, files: [
window: false, './**/*.ts',
}, './**/*.js',
'./**/*.vue',
extends: [ ],
'plugin:vue/strongly-recommended', excludedFiles: [
'airbnb-base', 'dist/**',
], ],
plugins: [
rules: { 'html',
semi: ['error', 'never'], 'cypress',
'import/extensions': 'off', '@typescript-eslint',
'import/no-extraneous-dependencies': 'off', ],
'import/no-unresolved': 'off', env: {
'import/no-dynamic-require': 'off', 'cypress/globals': true,
'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,
}, },
}], globals: {
'no-param-reassign': 'off', document: false,
'import/prefer-default-export': 'off', window: false,
'consistent-return': 'off', },
'no-unused-vars': 'off', extends: [
'@typescript-eslint/no-unused-vars': ['error'], 'plugin:vue/strongly-recommended',
'no-use-before-define': 'off', 'airbnb-base',
'@typescript-eslint/no-use-before-define': ['error'], ],
}, 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:docs": "yarn --cwd ./docs build",
"build:packages": "yarn clean:packages && lerna exec --parallel -- microbundle --compress", "build:packages": "yarn clean:packages && lerna exec --parallel -- microbundle --compress",
"clean:packages": "rm -rf ./packages/*/dist", "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:open": "cypress open --project tests",
"test": "cypress run --project tests", "test": "cypress run --project tests",
"reset": "yarn clean:packages && rm -rf ./**/.cache && rm -rf ./**/node_modules && rm -rf ./yarn.lock && yarn install" "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 * @param name The name of the command
*/ */
// eslint-disable-next-line
private __get(name: string) { private __get(name: string) {
return this.commandManager.runSingleCommand(name) return this.commandManager.runSingleCommand(name)
} }

View File

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

View File

@@ -2,12 +2,13 @@ import deepmerge from 'deepmerge'
import collect from 'collect.js' import collect from 'collect.js'
import { Plugin } from 'prosemirror-state' import { Plugin } from 'prosemirror-state'
import { keymap } from 'prosemirror-keymap' 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 { inputRules } from 'prosemirror-inputrules'
import { EditorView, Decoration } from 'prosemirror-view' // import { EditorView, Decoration } from 'prosemirror-view'
import { Editor } from './Editor' import { Editor } from './Editor'
import capitalize from './utils/capitalize' // import capitalize from './utils/capitalize'
import { Extensions } from './types' import { Extensions } from './types'
import getTopNodeFromExtensions from './utils/getTopNodeFromExtensions' import getTopNodeFromExtensions from './utils/getTopNodeFromExtensions'
import getNodesFromExtensions from './utils/getNodesFromExtensions' import getNodesFromExtensions from './utils/getNodesFromExtensions'

5
shims/vue.d.ts vendored
View File

@@ -1,4 +1,5 @@
declare module "*.vue" { declare module '*.vue' {
import Vue from "vue" import Vue from 'vue'
export default 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 // This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing) // the project's config changing)
// eslint-disable-next-line
module.exports = (on, config) => { module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits // `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config // `config` is the resolved Cypress config