Skip to content

Commit

Permalink
Upgrade linter, provide consistent cross-platform env
Browse files Browse the repository at this point in the history
  • Loading branch information
adanski committed Dec 6, 2023
1 parent ad5c2eb commit 1449bd1
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 55 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ rules:
- ignoreRestSiblings: true
argsIgnorePattern: '^_'
'@typescript-eslint/no-explicit-any': 'error'
'prettier/prettier': 'error'
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
packages/jquery-textcomplete/dist/* linguist-vendored
packages/jquery-textcomplete/src/vendor/* linguist-vendored

* text=auto eol=lf
2 changes: 2 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trailingComma: 'es5'
semi: false
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"private": true,
"version": "0.1.12",
"scripts": {
"build": "rm -fr dist .cache && parcel build index.pug --public-url /textcomplete",
"format:eslint": "eslint --fix '**/*.ts' '**/*.tsx'",
"format:prettier": "prettier --write '**/*.ts' '**/*.tsx'",
"build": "rimraf dist .cache && parcel build index.pug --public-url /textcomplete",
"format:eslint": "eslint --fix **/*.ts **/*.tsx",
"format:prettier": "prettier --write **/*.ts **/*.tsx",
"format": "run-s format:eslint format:prettier",
"lint": "eslint '**/*.ts' '**/*.tsx'",
"lint": "eslint **/*.ts **/*.tsx",
"start": "parcel index.pug"
},
"dependencies": {
Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
},
"devDependencies": {
"@types/jest": "^29.5.10",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"eslint": "^7.21.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "~29.7.0",
"lerna": "^8.0.0",
"rimraf": "^5.0.5",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"prettier": "^3.1.0",
"ts-jest": "^29.1.1",
"typescript": "^5.3.2"
},
"prettier": {
"semi": false
}
}
8 changes: 4 additions & 4 deletions packages/textcomplete-codemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"author": "Yuku Takahashi",
"license": "MIT",
"scripts": {
"build": "rm -fr dist && tsc",
"format:eslint": "eslint --fix 'src/**/*.ts'",
"format:prettier": "prettier --write 'src/**/*.ts'",
"build": "rimraf dist && tsc",
"format:eslint": "eslint --fix src/**/*.ts",
"format:prettier": "prettier --write src/**/*.ts",
"format": "run-s format:eslint format:prettier",
"lint": "eslint 'src/**/*.ts'"
"lint": "eslint src/**/*.ts"
},
"devDependencies": {
"@textcomplete/core": "^0.1.12",
Expand Down
8 changes: 4 additions & 4 deletions packages/textcomplete-contenteditable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"author": "Yuku Takahashi",
"license": "MIT",
"scripts": {
"build": "rm -fr dist && tsc",
"format:eslint": "eslint --fix 'src/**/*.ts'",
"format:prettier": "prettier --write 'src/**/*.ts'",
"build": "rimraf dist && tsc",
"format:eslint": "eslint --fix src/**/*.ts",
"format:prettier": "prettier --write src/**/*.ts",
"format": "run-s format:eslint format:prettier",
"lint": "eslint 'src/**/*.ts'"
"lint": "eslint src/**/*.ts"
},
"dependencies": {
"@textcomplete/utils": "^0.1.12"
Expand Down
8 changes: 4 additions & 4 deletions packages/textcomplete-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"author": "Yuku Takahashi",
"license": "MIT",
"scripts": {
"build": "rm -fr dist && tsc",
"format:eslint": "eslint --fix 'src/**/*.ts'",
"format:prettier": "prettier --write 'src/**/*.ts'",
"build": "rimraf dist && tsc",
"format:eslint": "eslint --fix src/**/*.ts",
"format:prettier": "prettier --write src/**/*.ts",
"format": "run-s format:eslint format:prettier",
"lint": "eslint 'src/**/*.ts'",
"lint": "eslint src/**/*.ts",
"test": "jest"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/textcomplete-core/src/Dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,17 @@ export class Dropdown extends EventEmitter {
return this.activeIndex < this.items.length - 1
? this.activeIndex + 1
: this.option.rotate
? 0
: null
? 0
: null
}

private getPrevActiveIndex(): number | null {
if (this.activeIndex == null) throw new Error()
return this.activeIndex !== 0
? this.activeIndex - 1
: this.option.rotate
? this.items.length - 1
: null
? this.items.length - 1
: null
}

private renderItems(): this {
Expand Down
33 changes: 18 additions & 15 deletions packages/textcomplete-core/src/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,23 @@ export abstract class Editor extends EventEmitter {
* @see {@link Textarea} for live example.
*/
protected getCode(e: KeyboardEvent): KeyCode {
return e.keyCode === 9 // tab
? "ENTER"
: e.keyCode === 13 // enter
? "ENTER"
: e.keyCode === 27 // esc
? "ESC"
: e.keyCode === 38 // up
? "UP"
: e.keyCode === 40 // down
? "DOWN"
: e.keyCode === 78 && e.ctrlKey // ctrl-n
? "DOWN"
: e.keyCode === 80 && e.ctrlKey // ctrl-p
? "UP"
: "OTHER"
switch (e.keyCode) {
case 9: // tab
case 13: // enter
return "ENTER"
case 27: // esc
return "ESC"
case 38: // up
return "UP"
case 40: // down
return "DOWN"
case 78: // ctrl-n
if (e.ctrlKey) return "DOWN"
break
case 80: // ctrl-p
if (e.ctrlKey) return "UP"
break
}
return "OTHER"
}
}
8 changes: 4 additions & 4 deletions packages/textcomplete-textarea/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"author": "Yuku Takahashi",
"license": "MIT",
"scripts": {
"build": "rm -fr dist && tsc",
"format:eslint": "eslint --fix 'src/**/*.ts'",
"format:prettier": "prettier --write 'src/**/*.ts'",
"build": "rimraf dist && tsc",
"format:eslint": "eslint --fix src/**/*.ts",
"format:prettier": "prettier --write src/**/*.ts",
"format": "run-s format:eslint format:prettier",
"lint": "eslint 'src/**/*.ts'"
"lint": "eslint src/**/*.ts"
},
"dependencies": {
"@textcomplete/utils": "^0.1.12",
Expand Down
11 changes: 4 additions & 7 deletions packages/textcomplete-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"author": "Yuku Takahashi",
"license": "MIT",
"scripts": {
"build": "rm -fr dist && tsc",
"format:eslint": "eslint --fix 'src/**/*.ts'",
"format:prettier": "prettier --write 'src/**/*.ts'",
"build": "rimraf dist && tsc",
"format:eslint": "eslint --fix src/**/*.ts",
"format:prettier": "prettier --write src/**/*.ts",
"format": "run-s format:eslint format:prettier",
"lint": "eslint 'src/**/*.ts'"
"lint": "eslint src/**/*.ts"
},
"devDependencies": {
"@textcomplete/core": "^0.1.12",
Expand All @@ -27,8 +27,5 @@
},
"publishConfig": {
"access": "public"
},
"prettier": {
"semi": false
}
}

0 comments on commit 1449bd1

Please sign in to comment.