Skip to content

Commit

Permalink
Fix code style and eslint rules
Browse files Browse the repository at this point in the history
PR-URL: metarhia#81
  • Loading branch information
tshemsedinov committed Feb 4, 2021
1 parent 4249c1a commit 6fcbd56
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
],
"arrow-parens": [
"error",
"as-needed"
"always"
],
"arrow-body-style": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion application/api/auth.2/register.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
({
access: 'public',
async method({ login, password, fullName }) => {
method: async ({ login, password, fullName }) => {
const hash = await metarhia.metautil.hashPassword(password);
await application.auth.registerUser(login, hash, fullName);
const token = await context.client.startSession();
Expand Down
2 changes: 1 addition & 1 deletion application/api/example.1/wait.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
async ({ delay }) => new Promise(resolve => {
async ({ delay }) => new Promise((resolve) => {
setTimeout(resolve, delay, 'done');
});
2 changes: 1 addition & 1 deletion application/domain/remote/start.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(async () => {
// Wait for server start
await new Promise(resolve => setTimeout(resolve, 100));
await new Promise((resolve) => setTimeout(resolve, 100));
console.debug('Connect to metacom');
const { url } = config.remote;
const Metacom = metarhia.metacom;
Expand Down
15 changes: 15 additions & 0 deletions application/static/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"parserOptions": {
"sourceType": "module"
},
"globals": {
"application": "readonly",
"api": "readonly"
},
"rules": {
"id-denylist": [
2,
"global"
]
}
}
14 changes: 10 additions & 4 deletions application/static/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const upload = () => {
};

class Keyboard {
constructor(application) {
constructor() {
this.controlKeyboard = document.getElementById('controlKeyboard');
if (!isMobile()) return;
for (let i = 0; i < KEYBOARD_LAYOUT.length; i++) {
Expand Down Expand Up @@ -446,6 +446,7 @@ class Application {
} else if (args[0] === 'download') {
const packet = await api.example.downloadFile();
console.log({ packet });
saveFile('fileName', packet);
} else if (args[0] === 'counter') {
const packet = await api.example.counter();
application.print(`counter: ${packet.result}`);
Expand All @@ -458,9 +459,14 @@ window.addEventListener('load', async () => {
window.application = new Application();
window.api = window.application.metacom.api;
await application.metacom.load('auth', 'console', 'example');
const result = await api.auth.status();
if (result.status !== 'logged') {
await api.auth.signIn({ login: 'marcus', password: 'marcus' });
const token = localStorage.getItem('metarhia.session.token');
if (token) {
await api.auth.restore({ token });
} else {
const res = await api.auth.signin({ login: 'marcus', password: 'marcus' });
if (res.token) {
localStorage.setItem('metarhia.session.token', res.token);
}
}
const { text } = await api.console.content({ name: 'home' });
application.print(text);
Expand Down
8 changes: 4 additions & 4 deletions test/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const tasks = [
}
];

const getRequest = task => {
const getRequest = (task) => {
const request = {
host: HOST,
port: PORT,
Expand All @@ -54,18 +54,18 @@ const getRequest = task => {
};

setTimeout(() => {
tasks.forEach(task => {
tasks.forEach((task) => {
const name = task.get || task.post;
console.log('HTTP request ' + name);
const request = getRequest(task);
const req = http.request(request);
req.on('response', res => {
req.on('response', (res) => {
const expectedStatus = task.status || 200;
setTimeout(() => {
assert.equal(res.statusCode, expectedStatus);
}, TEST_TIMEOUT);
});
req.on('error', err => {
req.on('error', (err) => {
console.log(err.stack);
});
if (task.data) req.write(task.data);
Expand Down

0 comments on commit 6fcbd56

Please sign in to comment.