mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-22 04:11:01 +00:00
build: add eslint rule forbidding TypeORM Equal constructor
TypeORMs Equal constructor is buggy and should not be used. This introduces a ESLint rule that checks for that. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
97389fe0c4
commit
925bb85d2f
2 changed files with 32 additions and 5 deletions
|
@ -52,10 +52,9 @@ module.exports = {
|
|||
jest: true,
|
||||
},
|
||||
rules: {
|
||||
"prettier/prettier": ["error",
|
||||
require('./.prettierrc.json')
|
||||
],
|
||||
'prettier/prettier': ['error', require('./.prettierrc.json')],
|
||||
'local-rules/correct-logger-context': 'error',
|
||||
'local-rules/no-typeorm-equal': 'error',
|
||||
'func-style': ['error', 'declaration'],
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = {
|
|||
fixable: 'code',
|
||||
type: 'problem',
|
||||
docs: {
|
||||
recommended: true
|
||||
recommended: true,
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
|
@ -45,7 +45,7 @@ module.exports = {
|
|||
fix: function (fixer) {
|
||||
return fixer.replaceText(
|
||||
node.arguments[1],
|
||||
`'${correctContext}'`,
|
||||
`'${correctContext}'`
|
||||
);
|
||||
},
|
||||
});
|
||||
|
@ -55,4 +55,32 @@ module.exports = {
|
|||
};
|
||||
},
|
||||
},
|
||||
'no-typeorm-equal': {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
noEqual:
|
||||
'TypeORMs Equal constructor is buggy and therefore not allowed.',
|
||||
},
|
||||
},
|
||||
create: function (context) {
|
||||
return {
|
||||
Identifier: function (node) {
|
||||
if (node.name === 'Equal' && node.parent.type === 'CallExpression') {
|
||||
context.report({
|
||||
node: node,
|
||||
messageId: 'noEqual',
|
||||
fix: function (fixer) {
|
||||
return fixer.replaceText(
|
||||
node.parent,
|
||||
`{ id: ${node.parent.arguments[0].name}.id }`
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue