Skip to content

Commit

Permalink
Lint and format .js files (#291)
Browse files Browse the repository at this point in the history
We were needlessly ignoring .js files in our eslint and prettier configs.
  • Loading branch information
rekmarks authored Oct 26, 2020
1 parent 846b2a5 commit 4523db5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 37 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
'@metamask/eslint-config/config/typescript',
],
ignorePatterns: [
'*.js',
'!.eslintrc.js',
'!jest.config.js',
'node_modules',
Expand All @@ -16,10 +15,7 @@ module.exports = {
'*.d.ts',
],
overrides: [{
files: [
'.eslintrc.js',
'jest.config.js',
],
files: ['*.js'],
parserOptions: {
sourceType: 'script',
},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
},
"scripts": {
"prepublishOnly": "yarn build",
"lint": "eslint --ext .ts .",
"lint": "eslint --ext js,ts .",
"test": "jest --coverage",
"format": "prettier **/*.ts --check --ignore-path=.gitignore",
"format:fix": "prettier **/*.ts --write --ignore-path=.gitignore",
"format": "prettier **/*.ts **/*.js --check --ignore-path=.gitignore",
"format:fix": "prettier **/*.ts **/*.js --write --ignore-path=.gitignore",
"build": "rm -rf dist && tsc",
"build:watch": "yarn build && tsc -w",
"build:link": "yarn build && cd dist && yarn link && rm -rf node_modules && cd ..",
Expand Down
22 changes: 10 additions & 12 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
const {
TokenRatesController
} = require('./dist');
const { TokenRatesController } = require('./dist');

const assets = new TokenRatesController({
disabled: false,
interval: 1000,
nativeCurrency: 'usd',
tokens: [
{ address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359' },
{ address: '0x960b236A07cf122663c4303350609A66A7B288C0' },
{ address: '0xB8c77482e45F1F44dE1745F52C74426C631bDD52' },
{ address: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2' }
]
disabled: false,
interval: 1000,
nativeCurrency: 'usd',
tokens: [
{ address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359' },
{ address: '0x960b236A07cf122663c4303350609A66A7B288C0' },
{ address: '0xB8c77482e45F1F44dE1745F52C74426C631bDD52' },
{ address: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2' },
],
});

assets.subscribe(console.log);
34 changes: 17 additions & 17 deletions tests/utils/mockEncryptor.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
const sinon = require('sinon')
const sinon = require('sinon');

const mockHex = '0xabcdef0123456789'
const mockKey = Buffer.alloc(32)
let cacheVal
const mockHex = '0xabcdef0123456789';
const mockKey = Buffer.alloc(32);
let cacheVal;

module.exports = {
encrypt: sinon.stub().callsFake(function (_password, dataObj) {
cacheVal = dataObj
return Promise.resolve(mockHex)
cacheVal = dataObj;
return Promise.resolve(mockHex);
}),

decrypt (_password, _text) {
return Promise.resolve(cacheVal || {})
decrypt(_password, _text) {
return Promise.resolve(cacheVal || {});
},

encryptWithKey (key, dataObj) {
return this.encrypt(key, dataObj)
encryptWithKey(key, dataObj) {
return this.encrypt(key, dataObj);
},

decryptWithKey (key, text) {
return this.decrypt(key, text)
decryptWithKey(key, text) {
return this.decrypt(key, text);
},

keyFromPassword (_password) {
return Promise.resolve(mockKey)
keyFromPassword(_password) {
return Promise.resolve(mockKey);
},

generateSalt () {
return 'WHADDASALT!'
generateSalt() {
return 'WHADDASALT!';
},
}
};

0 comments on commit 4523db5

Please sign in to comment.