Switch to eslint.
This commit is contained in:
parent
aa6ed9a3e2
commit
3748a2ebbd
24
.eslintrc.yml
Normal file
24
.eslintrc.yml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
extends:
|
||||||
|
- eslint:recommended
|
||||||
|
- plugin:import/errors
|
||||||
|
- plugin:import/warnings
|
||||||
|
|
||||||
|
parserOptions:
|
||||||
|
ecmaVersion: 8
|
||||||
|
sourceType: module
|
||||||
|
|
||||||
|
globals:
|
||||||
|
pageState: writable
|
||||||
|
pageContent: writable
|
||||||
|
realPages: writable
|
||||||
|
|
||||||
|
|
||||||
|
rules:
|
||||||
|
no-unused-vars:
|
||||||
|
- 2
|
||||||
|
- argsIgnorePattern: ^_
|
||||||
|
|
||||||
|
env:
|
||||||
|
browser: true
|
||||||
|
es6: true
|
22
.jshintrc
22
.jshintrc
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"esversion": 8,
|
|
||||||
"browser": true,
|
|
||||||
"onevar": true,
|
|
||||||
"passfail": false,
|
|
||||||
"white": true,
|
|
||||||
"maxerr": 100,
|
|
||||||
"predef": [
|
|
||||||
"define",
|
|
||||||
"require",
|
|
||||||
"console",
|
|
||||||
"ClipboardJS",
|
|
||||||
"UIkit",
|
|
||||||
"Prism",
|
|
||||||
"CodeJar",
|
|
||||||
"moment"
|
|
||||||
],
|
|
||||||
"indent": 2,
|
|
||||||
"globals": {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,12 @@
|
||||||
{
|
{
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/eslint-parser": "^7.13.14",
|
||||||
"clipboard": "^2.0.8",
|
"clipboard": "^2.0.8",
|
||||||
"codejar": "^3.4.0",
|
"codejar": "^3.4.0",
|
||||||
"css-loader": "^5.2.1",
|
"css-loader": "^5.2.1",
|
||||||
"date-fns": "^2.21.1",
|
"date-fns": "^2.21.1",
|
||||||
|
"eslint": "^7.24.0",
|
||||||
|
"eslint-plugin-import": "^2.22.1",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"html-webpack-plugin": "^5.3.1",
|
"html-webpack-plugin": "^5.3.1",
|
||||||
"mini-css-extract-plugin": "^1.4.1",
|
"mini-css-extract-plugin": "^1.4.1",
|
||||||
|
|
3
runLinter.sh
Executable file
3
runLinter.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
npx eslint -c .eslintrc.yml src
|
|
@ -22,7 +22,7 @@ export class PageState extends Page {
|
||||||
return localStorage.getItem('currentBaseMount') || "";
|
return localStorage.getItem('currentBaseMount') || "";
|
||||||
}
|
}
|
||||||
set currentBaseMount(value) {
|
set currentBaseMount(value) {
|
||||||
return localStorage.setItem('currentBaseMount', value);
|
localStorage.setItem('currentBaseMount', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,28 +43,28 @@ export class PageState extends Page {
|
||||||
return JSON.parse(localStorage.getItem('currentSecretPath') || "[]");
|
return JSON.parse(localStorage.getItem('currentSecretPath') || "[]");
|
||||||
}
|
}
|
||||||
set currentSecretPath(value) {
|
set currentSecretPath(value) {
|
||||||
return localStorage.setItem('currentSecretPath', JSON.stringify(value));
|
localStorage.setItem('currentSecretPath', JSON.stringify(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentSecretVersion() {
|
get currentSecretVersion() {
|
||||||
return localStorage.getItem('currentSecretVersion') || "0";
|
return localStorage.getItem('currentSecretVersion') || "0";
|
||||||
}
|
}
|
||||||
set currentSecretVersion(value) {
|
set currentSecretVersion(value) {
|
||||||
return localStorage.setItem('currentSecretVersion', value);
|
localStorage.setItem('currentSecretVersion', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentSecret() {
|
get currentSecret() {
|
||||||
return localStorage.getItem('currentSecret') || "";
|
return localStorage.getItem('currentSecret') || "";
|
||||||
}
|
}
|
||||||
set currentSecret(value) {
|
set currentSecret(value) {
|
||||||
return localStorage.setItem('currentSecret', value);
|
localStorage.setItem('currentSecret', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentMountType() {
|
get currentMountType() {
|
||||||
return localStorage.getItem('currentMountType') || "";
|
return localStorage.getItem('currentMountType') || "";
|
||||||
}
|
}
|
||||||
set currentMountType(value) {
|
set currentMountType(value) {
|
||||||
return localStorage.setItem('currentMountType', value);
|
localStorage.setItem('currentMountType', value);
|
||||||
}
|
}
|
||||||
get currentPage() {
|
get currentPage() {
|
||||||
let curPage = localStorage.getItem('currentPage') || "HOME";
|
let curPage = localStorage.getItem('currentPage') || "HOME";
|
||||||
|
|
|
@ -108,7 +108,7 @@ export class KeyValueSecretsPage extends Page {
|
||||||
pageState.currentSecretPath,
|
pageState.currentSecretPath,
|
||||||
pageState.currentSecret,
|
pageState.currentSecret,
|
||||||
pageState.currentSecretVersion
|
pageState.currentSecretVersion
|
||||||
).then(resp => {
|
).then(_ => {
|
||||||
changePage(pageState.currentPage);
|
changePage(pageState.currentPage);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -118,7 +118,7 @@ export class KeyValueSecretsPage extends Page {
|
||||||
|
|
||||||
const secretsMap = new Map(Object.entries(secretInfo).sort());
|
const secretsMap = new Map(Object.entries(secretInfo).sort());
|
||||||
|
|
||||||
for (let [key, value] of secretsMap) {
|
for (let value of secretsMap.values()) {
|
||||||
if (typeof value == 'object') isSecretNestedJson = true;
|
if (typeof value == 'object') isSecretNestedJson = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ export class KeyValueSecretsPage extends Page {
|
||||||
html: Prism.highlight(jsonText, Prism.languages.json, 'json')
|
html: Prism.highlight(jsonText, Prism.languages.json, 'json')
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
secretsMap.forEach(function (value, key) {
|
secretsMap.forEach((value, key) => {
|
||||||
let kvListElement = this.makeKVListElement(key, value);
|
let kvListElement = this.makeKVListElement(key, value);
|
||||||
kvList.appendChild(kvListElement);
|
kvList.appendChild(kvListElement);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
|
@ -54,7 +54,7 @@ export class KeyValueSecretsEditPage extends Page {
|
||||||
pageState.currentSecretPath,
|
pageState.currentSecretPath,
|
||||||
pageState.currentSecret,
|
pageState.currentSecret,
|
||||||
JSON.parse(jar.toString())
|
JSON.parse(jar.toString())
|
||||||
).then(resp => {
|
).then(_ => {
|
||||||
changePage("KEY_VALUE_SECRETS");
|
changePage("KEY_VALUE_SECRETS");
|
||||||
return;
|
return;
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
|
|
|
@ -122,7 +122,7 @@ export class LoginPage extends Page {
|
||||||
let formData = new FormData(tokenLoginForm);
|
let formData = new FormData(tokenLoginForm);
|
||||||
const token = formData.get("token");
|
const token = formData.get("token");
|
||||||
localStorage.setItem('token', token);
|
localStorage.setItem('token', token);
|
||||||
lookupSelf().then(res => {
|
lookupSelf().then(_ => {
|
||||||
changePage("HOME");
|
changePage("HOME");
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
document.getElementById("tokenInput").classList.add("uk-form-danger");
|
document.getElementById("tokenInput").classList.add("uk-form-danger");
|
||||||
|
|
|
@ -20,7 +20,7 @@ function random() {
|
||||||
|
|
||||||
function genPw(len) {
|
function genPw(len) {
|
||||||
let pw = "";
|
let pw = "";
|
||||||
const pwArray = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&'()*+,-./:;<=>?@[\]^_{|}~".split('');
|
const pwArray = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&'()*+,-./:;<=>?@[]^_{|}~".split('');
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
pw = pw.concat(pwArray[Math.floor(random() * pwArray.length)]);
|
pw = pw.concat(pwArray[Math.floor(random() * pwArray.length)]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ export class NewTOTPPage extends Page {
|
||||||
name: formData.get("name"),
|
name: formData.get("name"),
|
||||||
generate: false
|
generate: false
|
||||||
};
|
};
|
||||||
addNewTOTP(pageState.currentBaseMount, parms).then(res => {
|
addNewTOTP(pageState.currentBaseMount, parms).then(_ => {
|
||||||
changePage("TOTP");
|
changePage("TOTP");
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
setErrorText(`API Error: ${e.message}`);
|
setErrorText(`API Error: ${e.message}`);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Page } from "../../types/Page.js";
|
import { Page } from "../../types/Page.js";
|
||||||
import { getTOTPKeys, getTOTPCode, DoesNotExistError } from "../../api.js";
|
import { getTOTPKeys, getTOTPCode, DoesNotExistError } from "../../api.js";
|
||||||
import { setTitleElement, setPageContent, changePage } from "../../pageUtils.js";
|
import { setTitleElement, setPageContent, changePage, setErrorText } from "../../pageUtils.js";
|
||||||
import { CopyableInputBox } from "../../elements/CopyableInputBox.js";
|
import { CopyableInputBox } from "../../elements/CopyableInputBox.js";
|
||||||
import { makeElement } from "../../htmlUtils.js";
|
import { makeElement } from "../../htmlUtils.js";
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ export class UnsealPage extends Page {
|
||||||
async handleKeySubmit() {
|
async handleKeySubmit() {
|
||||||
let formData = new FormData(this.unsealKeyForm);
|
let formData = new FormData(this.unsealKeyForm);
|
||||||
|
|
||||||
submitUnsealKey(formData.get("key")).then(resp => {
|
submitUnsealKey(formData.get("key")).then(_ => {
|
||||||
getSealStatus().then(data => {
|
getSealStatus().then(data => {
|
||||||
this.updateSealProgress(data);
|
this.updateSealProgress(data);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
padding-bottom: 10px !important;
|
padding-bottom: 10px !important;
|
||||||
padding-left: 10px !important;
|
padding-left: 10px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wrap-pre {
|
.wrap-pre {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue