Skip to content

Commit

Permalink
update eslint config & fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
soulsands committed Apr 15, 2023
1 parent 2a34c8f commit f572935
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 264 deletions.
9 changes: 2 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ module.exports = {
es2021: true,
node: true,
},
plugins: ['prettier'],

// plugins: ['prettier'], // to be activated
extends: ['eslint:recommended', 'airbnb-base', 'plugin:jsonc/recommended-with-jsonc', 'prettier'],
overrides: [
{
Expand All @@ -18,7 +17,6 @@ module.exports = {
parser: 'jsonc-eslint-parser',
rules: {
'jsonc/sort-keys': [
// here is rule (to be deleted)
'off',
{
pathPattern: '^$',
Expand Down Expand Up @@ -121,8 +119,6 @@ module.exports = {
sourceType: 'module',
},
rules: {
// hi adam, those rules are //temporary off, you can turn them on one by one to check if we really need it. (to be deleted)

// eslint:recommended
'no-unused-vars': 'off',
'linebreak-style': 'off',
Expand All @@ -136,7 +132,6 @@ module.exports = {
'no-inner-declarations': 'off',

// prettier
// all about formating, it might take a while to excute it. you can change the config in .prettierrc.js (to be deleted)
'prettier/prettier': ['off', { endOfLine: 'auto' }],

// airbnb-base
Expand Down Expand Up @@ -213,6 +208,6 @@ module.exports = {
'import/no-named-as-default-member': 'off',
yoda: 'off',
'no-script-url': 'off',

'no-prototype-builtins':'off'
},
};
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
#npx lint-staged
1 change: 0 additions & 1 deletion docker_healthcheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ if (config.https) {
// built-in TLS (terminated by trilium) is not supported yet, PRs are welcome
// for reverse proxy terminated TLS this will works since config.https will be false
process.exit(0);
return;
}

const port = require('./src/services/port');
Expand Down
20 changes: 11 additions & 9 deletions src/public/app/components/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class Component {

get sanitizedClassName() {
// webpack mangles names and sometimes uses unsafe characters
return this.constructor.name.replace(/[^A-Z0-9]/ig, "_");
return this.constructor.name.replace(/[^A-Z0-9]/gi, '_');
}

setParent(parent) {
Expand Down Expand Up @@ -52,10 +52,11 @@ export default class Component {
// don't create promises if not needed (optimization)
return callMethodPromise && childrenPromise
? Promise.all([callMethodPromise, childrenPromise])
: (callMethodPromise || childrenPromise);
}
catch (e) {
console.error(`Handling of event '${name}' failed in ${this.constructor.name} with error ${e.message} ${e.stack}`);
: callMethodPromise || childrenPromise;
} catch (e) {
console.error(
`Handling of event '${name}' failed in ${this.constructor.name} with error ${e.message} ${e.stack}`
);

return null;
}
Expand All @@ -72,7 +73,6 @@ export default class Component {

for (const child of this.children) {
const ret = child.handleEvent(name, data);

if (ret) {
promises.push(ret);
}
Expand All @@ -88,8 +88,7 @@ export default class Component {

if (fun) {
return this.callMethod(fun, data);
}
else {
} else {
return this.parent.triggerCommand(name, data);
}
}
Expand All @@ -103,9 +102,12 @@ export default class Component {

const promise = fun.call(this, data);

// console.log(this, data);

const took = Date.now() - startTime;

if (glob.isDev && took > 20) { // measuring only sync handlers
if (glob.isDev && took > 20) {
// measuring only sync handlers
console.log(`Call to ${fun.name} in ${this.componentId} took ${took}ms`);
}

Expand Down
Loading

0 comments on commit f572935

Please sign in to comment.