chore: lint

This commit is contained in:
coderiaser 2025-07-04 12:51:42 +03:00
parent e99d084728
commit af77eeed8d
14 changed files with 143 additions and 91 deletions

View file

@ -1,5 +1,5 @@
.*
*.spec.js
*.spec.*
*.fixture.js*
manifest.yml
docker
@ -19,7 +19,7 @@ app.json
bower.json
manifest.yml
bin/release.js
bin/release.mjs
client
img/logo/cloudcmd-hq.png

View file

@ -19,8 +19,8 @@ await main();
async function main() {
const history = '## Version history\n\n';
const link = '//github.com/coderaiser/cloudcmd/releases/tag/';
const template =
'- *{{ date }}*, ' +
const template = '- ' +
'*{{ date }}*, ' +
'**[v{{ version }}]' +
'(' + link +
'v{{ version }})**\n';

View file

@ -31,7 +31,7 @@ const getOperations = (event, deps) => {
getCurrentName,
toggleSelectedFile,
Buffer = {},
Buffer = {},
} = deps;
return {

View file

@ -215,8 +215,7 @@ async function onPathElementClick(panel, event) {
function copyPath(el) {
clipboard
.writeText(el
.parentElement.title)
.writeText(el.parentElement.title)
.then(CloudCmd.log)
.catch(CloudCmd.log);
}
@ -422,7 +421,7 @@ function dragndrop() {
};
/**
* In Mac OS Chrome dropEffect = 'none'
* In macOS Chrome dropEffect = 'none'
* so drop do not firing up when try
* to upload file from download bar
*/

View file

@ -59,19 +59,19 @@ module.exports.init = promisify((callback) => {
exec.series([
DOM.loadSocket,
async (callback) => {
if (config('dropbox'))
return callback();
const {prefix, prefixSocket} = CloudCmd;
await loadAll();
await initOperations(prefix, prefixSocket, callback);
},
if (config('dropbox'))
return callback();
const {prefix, prefixSocket} = CloudCmd;
await loadAll();
await initOperations(prefix, prefixSocket, callback);
},
(callback) => {
Loaded = true;
Images.hide();
callback();
},
Loaded = true;
Images.hide();
callback();
},
], callback);
});

View file

@ -2,7 +2,12 @@
const fullstore = require('fullstore');
const {J, K, UP, DOWN} = require('../../key/key.js');
const {
J,
K,
UP,
DOWN,
} = require('../../key/key.js');
const store = fullstore(1);
const isDigit = (a) => /^\d+$/.test(a);

View file

@ -3,7 +3,12 @@
const test = require('supertape');
const navigate = require('./navigate');
const {UP, DOWN, J, K} = require('../../key/key.js');
const {
UP,
DOWN,
J,
K,
} = require('../../key/key.js');
test('cloudcmd: user-menu: navigate: DOWN', (t) => {
const el = {

View file

@ -173,6 +173,7 @@ module.exports.buildFromJSON = (params) => {
Path(path);
fileTable += `${header}<ul data-name="js-files" class="files">`;
/* Если мы не в корне */
if (path !== '/') {
const dotDot = getDotDot(path);
@ -203,43 +204,43 @@ module.exports.buildFromJSON = (params) => {
fileTable += files
.filter(filterOutDotFiles({
showDotFiles,
}))
showDotFiles,
}))
.map(updateField)
.map((file) => {
const name = encode(file.name);
const link = prefix + FS + path + name;
const {
type,
mode,
date,
owner,
size,
} = file;
const linkResult = rendy(templateLink, {
link,
title: name,
name,
attribute: getAttribute(file.type),
});
const dataName = getDataName(file.name);
const attribute = `draggable="true" ${dataName}`;
return rendy(templateFile, {
tag: 'li',
attribute,
className: '',
type,
name: linkResult,
size,
date,
owner,
mode,
});
})
const name = encode(file.name);
const link = prefix + FS + path + name;
const {
type,
mode,
date,
owner,
size,
} = file;
const linkResult = rendy(templateLink, {
link,
title: name,
name,
attribute: getAttribute(file.type),
});
const dataName = getDataName(file.name);
const attribute = `draggable="true" ${dataName}`;
return rendy(templateFile, {
tag: 'li',
attribute,
className: '',
type,
name: linkResult,
size,
date,
owner,
mode,
});
})
.join('');
fileTable += '</ul>';

42
eslint.config.mjs Normal file
View file

@ -0,0 +1,42 @@
import {safeAlign} from 'eslint-plugin-putout';
import {defineConfig} from 'eslint/config';
import n from 'eslint-plugin-n';
import globals from 'globals';
import {matchToFlat} from '@putout/eslint-flat';
export const match = {
'bin/release.mjs': {
'no-console': 'off',
'n/hashbang': 'off',
},
'client/dom/index.js': {
'no-multi-spaces': 'off',
},
'client/**/*.js': {
'n/no-extraneous-require': 'off',
'n/no-unsupported-features/node-builtins': 'off',
},
'bin/cloudcmd.js': {
'no-console': 'off',
},
};
export default defineConfig([
safeAlign, {
ignores: ['**/fixture'],
rules: {
'key-spacing': 'off',
'n/prefer-node-protocol': 'error',
},
plugins: {
n,
},
}, {
files: ['{client,common,static}/**/*.js'],
languageOptions: {
globals: {
...globals.browser,
},
},
},
...matchToFlat(match),
]);

View file

@ -120,6 +120,7 @@
"just-snake-case": "^3.2.0",
"markdown-it": "^14.0.0",
"mellow": "^3.0.0",
"mime-types": "^3.0.1",
"montag": "^1.2.1",
"nano-memoize": "^3.0.16",
"nomine": "^4.0.0",

View file

@ -6,22 +6,22 @@ const repl = require('node:repl');
module.exports = net
.createServer((socket) => {
const {pid} = process;
const addr = socket.remoteAddress;
const port = socket.remotePort;
const r = repl.start({
prompt: `[${pid} ${addr}:${port}>`,
input: socket,
output: socket,
terminal: true,
useGlobal: false,
});
r.on('exit', () => {
socket.end();
});
r.context.socket = socket;
})
const {pid} = process;
const addr = socket.remoteAddress;
const port = socket.remotePort;
const r = repl.start({
prompt: `[${pid} ${addr}:${port}>`,
input: socket,
output: socket,
terminal: true,
useGlobal: false,
});
r.on('exit', () => {
socket.end();
});
r.context.socket = socket;
})
.listen(1337);

View file

@ -11,9 +11,9 @@ module.exports = (config) => {
const data = Object
.keys(config)
.map((name) => [
name,
config[name],
]);
name,
config[name],
]);
if (!data.length)
return '';

View file

@ -74,10 +74,10 @@ async function onGET({req, res, menuName, readFile}) {
function getError(error, source) {
return montag`
const e = Error(\`<pre>${codeframe({
error,
source,
highlightCode: false,
})}</pre>\`);
error,
source,
highlightCode: false,
})}</pre>\`);
e.code = 'frame';

View file

@ -44,8 +44,7 @@ const data = {
}],
};
let Expect =
'<div data-name="js-path" class="reduce-text" title="/etc/X11/">' +
let Expect = '<div data-name="js-path" class="reduce-text" title="/etc/X11/">' +
'<span data-name="js-copy-path" class="path-icon icon-copy-to-clipboard"' +
' title="copy path (Ctrl+P)">' +
'</span>' +
@ -75,13 +74,13 @@ test('cloudfunc: render', (t) => {
const isNotOk = Expect
.split('')
.some((item, number) => {
const ret = result[number] !== item;
if (ret)
i = number;
return ret;
});
const ret = result[number] !== item;
if (ret)
i = number;
return ret;
});
timeEnd('CloudFunc.buildFromJSON');