mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-09 13:51:57 -04:00
feat(package): adjust packages to workspaces
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
046a173891
commit
2241a3faea
26 changed files with 5157 additions and 11075 deletions
58
eslint-local-rules.js
Normal file
58
eslint-local-rules.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const loggerFunctions = ['error', 'log', 'warn', 'debug', 'verbose'];
|
||||
|
||||
module.exports = {
|
||||
'correct-logger-context': {
|
||||
meta: {
|
||||
fixable: 'code',
|
||||
type: 'problem',
|
||||
docs: {
|
||||
recommended: true
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
create: function (context) {
|
||||
return {
|
||||
CallExpression: function (node) {
|
||||
if (
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
node.callee.object.type === 'MemberExpression' &&
|
||||
node.callee.object.property.name === 'logger' &&
|
||||
loggerFunctions.includes(node.callee.property.name) &&
|
||||
!!node.arguments &&
|
||||
node.arguments.length === 2
|
||||
) {
|
||||
const usedContext = node.arguments[1].value;
|
||||
let correctContext = 'undefined';
|
||||
const ancestors = context.getAncestors();
|
||||
for (let index = ancestors.length - 1; index >= 0; index--) {
|
||||
if (ancestors[index].type === 'MethodDefinition') {
|
||||
correctContext = ancestors[index].key.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (usedContext !== correctContext) {
|
||||
context.report({
|
||||
node: node,
|
||||
message: `Used wrong context in log statement`,
|
||||
fix: function (fixer) {
|
||||
return fixer.replaceText(
|
||||
node.arguments[1],
|
||||
`'${correctContext}'`,
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue