chore: enforce lint across codebase and ban "maybe" in identifiers
Remove member-ordering and complexity eslint-disable comments by reordering class members and applying targeted fixes. Add metoyou/no-maybe-in-naming, type-safe WebRTC e2e harness helpers, and resolve remaining lint errors so npm run lint exits cleanly. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,23 @@ function createReplaceFix(range, replacement) {
|
||||
return (fixer) => fixer.replaceTextRange(range, replacement);
|
||||
}
|
||||
|
||||
const MAYBE_PATTERN = /maybe/i;
|
||||
|
||||
function identifierContainsMaybe(name) {
|
||||
return typeof name === 'string' && MAYBE_PATTERN.test(name);
|
||||
}
|
||||
|
||||
function checkIdentifier(context, node, name) {
|
||||
if (!identifierContainsMaybe(name))
|
||||
return;
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'noMaybeInNaming',
|
||||
data: { name }
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
rules: {
|
||||
'angular-template-spacing': {
|
||||
@@ -35,6 +52,71 @@ module.exports = {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
'no-maybe-in-naming': {
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Disallow the word "maybe" in identifiers (variables, functions, classes, parameters)'
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
noMaybeInNaming: 'Identifier "{{name}}" must not contain "maybe". Use an explicit name that states intent.'
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const reportDefinition = (node, name) => checkIdentifier(context, node, name);
|
||||
|
||||
return {
|
||||
VariableDeclarator(node) {
|
||||
if (node.id.type === 'Identifier')
|
||||
reportDefinition(node.id, node.id.name);
|
||||
},
|
||||
FunctionDeclaration(node) {
|
||||
if (node.id)
|
||||
reportDefinition(node.id, node.id.name);
|
||||
},
|
||||
ClassDeclaration(node) {
|
||||
if (node.id)
|
||||
reportDefinition(node.id, node.id.name);
|
||||
},
|
||||
MethodDefinition(node) {
|
||||
if (node.key.type === 'Identifier')
|
||||
reportDefinition(node.key, node.key.name);
|
||||
},
|
||||
PropertyDefinition(node) {
|
||||
if (node.key.type === 'Identifier')
|
||||
reportDefinition(node.key, node.key.name);
|
||||
},
|
||||
TSInterfaceDeclaration(node) {
|
||||
reportDefinition(node.id, node.id.name);
|
||||
},
|
||||
TSTypeAliasDeclaration(node) {
|
||||
reportDefinition(node.id, node.id.name);
|
||||
},
|
||||
TSMethodSignature(node) {
|
||||
if (node.key.type === 'Identifier')
|
||||
reportDefinition(node.key, node.key.name);
|
||||
},
|
||||
TSPropertySignature(node) {
|
||||
if (node.key.type === 'Identifier')
|
||||
reportDefinition(node.key, node.key.name);
|
||||
},
|
||||
TSParameterProperty(node) {
|
||||
if (node.parameter.type === 'Identifier')
|
||||
reportDefinition(node.parameter, node.parameter.name);
|
||||
},
|
||||
'FunctionDeclaration > Identifier[id]': function onParam(node) {
|
||||
reportDefinition(node, node.name);
|
||||
},
|
||||
'FunctionExpression > Identifier[id]': function onParam(node) {
|
||||
reportDefinition(node, node.name);
|
||||
},
|
||||
'ArrowFunctionExpression > Identifier[id]': function onParam(node) {
|
||||
reportDefinition(node, node.name);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
'no-unicode-symbols': {
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
|
||||
Reference in New Issue
Block a user