mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-08-09 20:25:42 +00:00
Swap to eslint (#154)
* 311 problems (173 errors, 138 warnings) * Make a start... * swap to react config * Literally a handful left * Clean. * any removal * Use Record * Adjust versions * Update with latest eslint-standard ruleset * Update defaults.ts
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { KeyringStore } from '../types';
|
||||
import { KeyringStore, KeyringJson } from '../types';
|
||||
|
||||
import fs from 'fs';
|
||||
import mkdirp from 'mkdirp';
|
||||
@@ -12,7 +12,7 @@ import path from 'path';
|
||||
export default class FileStore implements KeyringStore {
|
||||
private _path: string;
|
||||
|
||||
constructor (path: string) {
|
||||
public constructor (path: string) {
|
||||
if (!fs.existsSync(path)) {
|
||||
mkdirp.sync(path);
|
||||
}
|
||||
@@ -20,23 +20,25 @@ export default class FileStore implements KeyringStore {
|
||||
this._path = path;
|
||||
}
|
||||
|
||||
all (cb: (key: string, value: any) => void): void {
|
||||
public all (cb: (key: string, value: KeyringJson) => void): void {
|
||||
fs
|
||||
.readdirSync(this._path)
|
||||
.filter((key) => !['.', '..'].includes(key))
|
||||
.forEach((key) => cb(key, this._readKey(key)));
|
||||
.filter((key): boolean => !['.', '..'].includes(key))
|
||||
.forEach((key): void => {
|
||||
cb(key, this._readKey(key));
|
||||
});
|
||||
}
|
||||
|
||||
get (key: string, cb: (value: any) => void): void {
|
||||
public get (key: string, cb: (value: KeyringJson) => void): void {
|
||||
cb(this._readKey(key));
|
||||
}
|
||||
|
||||
remove (key: string, cb?: () => void): void {
|
||||
public remove (key: string, cb?: () => void): void {
|
||||
fs.unlinkSync(this._getPath(key));
|
||||
cb && cb();
|
||||
}
|
||||
|
||||
set (key: string, value: any, cb?: () => void): void {
|
||||
public set (key: string, value: KeyringJson, cb?: () => void): void {
|
||||
fs.writeFileSync(this._getPath(key), Buffer.from(JSON.stringify(value), 'utf-8'));
|
||||
cb && cb();
|
||||
}
|
||||
@@ -45,7 +47,7 @@ export default class FileStore implements KeyringStore {
|
||||
return path.join(this._path, key);
|
||||
}
|
||||
|
||||
private _readKey (key: string): any {
|
||||
private _readKey (key: string): KeyringJson {
|
||||
return JSON.parse(
|
||||
fs.readFileSync(this._getPath(key)).toString('utf-8')
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user