Skip to content

Commit

Permalink
Adds eslint + fixes linting errors 🧞‍♂️
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeJab committed May 29, 2020
1 parent 2a3472a commit 2ecfd5c
Show file tree
Hide file tree
Showing 10 changed files with 972 additions and 302 deletions.
629 changes: 347 additions & 282 deletions .eslintrc.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"scripts": {
"start": "rollup -c --watch",
"test:ci": "yarn build:docs && yarn build && testem ci -f testem-ci.js",
"test": "yarn format && yarn build && testem ci -f testem.js",
"test": "yarn lint && yarn build && testem ci -f testem.js",
"lint": "prettier src --check && eslint src",
"format": "prettier src --write",
"build": "rollup -c",
"build:docs": "jsdoc -c ./.jsdoc",
Expand Down Expand Up @@ -51,6 +52,8 @@
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"conventional-changelog-cli": "^2.0.34",
"eslint": "^7.1.0",
"eslint-config-prettier": "^6.11.0",
"jquery": "^3.5.1",
"jsdoc": "^3.6.4",
"prettier": "^2.0.5",
Expand Down
1 change: 1 addition & 0 deletions src/js/models/_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class Section extends LinkedItem {
return 0
}

// eslint-disable-next-line getter-return
get isBlank() {
unimplementedMethod('isBlank', this)
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/parsers/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ZWNJ } from 'mobiledoc-kit/renderers/editor-dom'
import SectionParser from 'mobiledoc-kit/parsers/section'
import Markup from 'mobiledoc-kit/models/markup'

const GOOGLE_DOCS_CONTAINER_ID_REGEX = /^docs\-internal\-guid/
const GOOGLE_DOCS_CONTAINER_ID_REGEX = /^docs-internal-guid/

const NO_BREAK_SPACE_REGEX = new RegExp(NO_BREAK_SPACE, 'g')
const TAB_CHARACTER_REGEX = new RegExp(TAB_CHARACTER, 'g')
Expand Down
2 changes: 2 additions & 0 deletions src/js/utils/cursor/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { FORWARD, BACKWARD } = DIRECTION

// generated via http://xregexp.com/ to cover chars that \w misses
// (new XRegExp('\\p{Alphabetic}|[0-9]|_|:')).toString()
// eslint-disable-next-line no-misleading-character-class
const WORD_CHAR_REGEX = /[A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͅͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևְ-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-ٗٙ-ٟٮ-ۓە-ۜۡ-ۭۨ-ۯۺ-ۼۿܐ-ܿݍ-ޱߊ-ߪߴߵߺ----------------------------------------------------------------------------ൿ--------------------က---------------------------------------------------------------ᶿ-----------------------------------------ⷿ--------------ꀀ-----------------------ꦿ------------------------------------------]|[0-9]|_|:/

function findParentSectionFromNode(renderTree, node) {
Expand Down Expand Up @@ -436,6 +437,7 @@ BlankPosition = class BlankPosition extends Position {
toRange() {
return Range.blankRange()
}
// eslint-disable-next-line getter-return
get leafSectionIndex() {
assert('must implement get leafSectionIndex', false)
}
Expand Down
2 changes: 2 additions & 0 deletions src/js/utils/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ const Key = class Key {
return this.isForwardDelete() ? DIRECTION.FORWARD : DIRECTION.BACKWARD
case this.isHorizontalArrow():
return this.isRightArrow() ? DIRECTION.FORWARD : DIRECTION.BACKWARD
default:
return DIRECTION.FORWARD
}
}

Expand Down
1 change: 1 addition & 0 deletions src/js/utils/merge.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-prototype-builtins */
function mergeWithOptions(original, updates, options) {
options = options || {}
for (var prop in updates) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils/parse-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const MIME_TEXT_PLAIN = 'text/plain'
export const MIME_TEXT_HTML = 'text/html'
export const NONSTANDARD_IE_TEXT_TYPE = 'Text'

const MOBILEDOC_REGEX = new RegExp(/data\-mobiledoc='(.*?)'>/)
const MOBILEDOC_REGEX = new RegExp(/data-mobiledoc='(.*?)'>/)

/**
* @return {Post}
Expand Down
10 changes: 5 additions & 5 deletions src/js/views/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ export default class Tooltip extends View {
}, HIDE_DELAY)
}

this.addEventListener(tooltipElement, 'mouseenter', e => {
this.addEventListener(tooltipElement, 'mouseenter', () => {
clearTimeout(hideTimeout)
})

this.addEventListener(tooltipElement, 'mouseleave', e => {
this.addEventListener(tooltipElement, 'mouseleave', () => {
scheduleHide()
})

this.addEventListener(rootElement, 'mouseover', e => {
let target = getEventTargetMatchingTag(options.showForTag, e.target, rootElement)
this.addEventListener(rootElement, 'mouseover', event => {
let target = getEventTargetMatchingTag(options.showForTag, event.target, rootElement)

if (target && target.isContentEditable) {
clearTimeout(hideTimeout)
Expand All @@ -63,7 +63,7 @@ export default class Tooltip extends View {
}
})

this.addEventListener(rootElement, 'mouseout', e => {
this.addEventListener(rootElement, 'mouseout', () => {
clearTimeout(showTimeout)
if (this.elementObserver) {
this.elementObserver.cancel()
Expand Down
Loading

0 comments on commit 2ecfd5c

Please sign in to comment.