js: add and apply eslint rules
-- * mainly spacing, see .eslintrc.json for details
This commit is contained in:
parent
1954d27be8
commit
dd32daad0b
@ -27,6 +27,23 @@
|
||||
"no-var": [
|
||||
"warn"
|
||||
],
|
||||
"max-len": 1
|
||||
"max-len": 1,
|
||||
"default-case": 2,
|
||||
"no-invalid-this": 2,
|
||||
"no-lone-blocks": 1,
|
||||
"no-self-compare": 2,
|
||||
"radix": 2,
|
||||
"no-use-before-define": ["error", {
|
||||
"functions": false,
|
||||
"classes": false,
|
||||
"variables": true
|
||||
}],
|
||||
"no-useless-constructor": 1,
|
||||
"space-before-function-paren": ["error", "always"],
|
||||
"keyword-spacing": 2,
|
||||
"spaced-comment": 1,
|
||||
"space-unary-ops": 2,
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"array-bracket-spacing": ["error", "never"]
|
||||
}
|
||||
}
|
@ -98,6 +98,7 @@ class GPGME_Key {
|
||||
if (property === 'armored') {
|
||||
return gpgme_error('KEY_ASYNC_ONLY');
|
||||
}
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if (!validKeyProperties.hasOwnProperty(property)){
|
||||
return gpgme_error('PARAM_WRONG');
|
||||
} else {
|
||||
@ -268,7 +269,9 @@ class GPGME_Subkey {
|
||||
* @param private
|
||||
*/
|
||||
const setProperty = function (property, value){
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if (validSubKeyProperties.hasOwnProperty(property)){
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if (validSubKeyProperties[property](value) === true) {
|
||||
if (property === 'timestamp' || property === 'expires'){
|
||||
me._data[property] = new Date(value * 1000);
|
||||
@ -313,7 +316,9 @@ class GPGME_UserId {
|
||||
const me = this;
|
||||
let keys = Object.keys(data);
|
||||
const setProperty = function (property, value){
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if (validUserIdProperties.hasOwnProperty(property)){
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if (validUserIdProperties[property](value) === true) {
|
||||
if (property === 'last_update'){
|
||||
me._data[property] = new Date(value*1000);
|
||||
|
@ -31,8 +31,6 @@ import { gpgme_error } from './Errors';
|
||||
* This class offers access to the gnupg keyring
|
||||
*/
|
||||
export class GPGME_Keyring {
|
||||
constructor(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries Keys (all Keys or a subset) from gnupg.
|
||||
@ -378,6 +376,7 @@ export class GPGME_Keyring {
|
||||
generateKey (userId, algo = 'default', expires){
|
||||
if (
|
||||
typeof (userId) !== 'string' ||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
supportedKeyAlgos.indexOf(algo) < 0 ||
|
||||
(expires && !(expires instanceof Date))
|
||||
){
|
||||
|
@ -42,12 +42,14 @@ export function createSignature(sigObject){
|
||||
}
|
||||
let keys = Object.keys(sigObject);
|
||||
for (let i=0; i< keys.length; i++){
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if ( typeof (sigObject[keys[i]]) !== expKeys[keys[i]] ){
|
||||
return gpgme_error('SIG_WRONG');
|
||||
}
|
||||
}
|
||||
let sumkeys = Object.keys(sigObject.summary);
|
||||
for (let i=0; i< sumkeys.length; i++){
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if ( typeof (sigObject.summary[sumkeys[i]]) !== expSum[sumkeys[i]] ){
|
||||
return gpgme_error('SIG_WRONG');
|
||||
}
|
||||
@ -60,6 +62,7 @@ export function createSignature(sigObject){
|
||||
let notation = sigObject.notations[i];
|
||||
let notekeys = Object.keys(notation);
|
||||
for (let j=0; j < notekeys.length; j++){
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
if ( typeof (notation[notekeys[j]]) !== expNote[notekeys[j]] ){
|
||||
return gpgme_error('SIG_WRONG');
|
||||
}
|
||||
|
@ -365,9 +365,9 @@ export const permittedOperations = {
|
||||
data: 'string',
|
||||
base64:'boolean',
|
||||
info: 'object'
|
||||
// file_name: Optional string of the plaintext file name.
|
||||
// is_mime: Boolean if the messages claims it is MIME.
|
||||
// signatures: Array of signatures
|
||||
// info.file_name: Optional string of the plaintext file name.
|
||||
// info.is_mime: Boolean if the messages claims it is MIME.
|
||||
// info.signatures: Array of signatures
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user