Skip to content

Commit 9663c4f

Browse files
committed
feat(prefer-svelte-reactivity): added support for ES class element accessibility
1 parent 87d8894 commit 9663c4f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/eslint-plugin-svelte/src/rules/prefer-svelte-reactivity.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,13 @@ function isPropertyEncapsulated(
320320
returnedFunctionCalls: Map<FunctionLike, TSESTree.MethodDefinition[]>,
321321
returnedVariables: Map<FunctionLike, VariableLike[]>
322322
): boolean {
323-
if (node.accessibility === 'public') {
323+
if (isPublic(node)) {
324324
return false;
325325
}
326326
for (const classElement of node.parent.body) {
327327
if (
328328
classElement.type === 'MethodDefinition' &&
329-
classElement.accessibility === 'public' &&
329+
isPublic(classElement) &&
330330
methodReturnsProperty(classElement, node, returnedFunctionCalls, returnedVariables)
331331
) {
332332
return false;
@@ -335,6 +335,10 @@ function isPropertyEncapsulated(
335335
return true;
336336
}
337337

338+
function isPublic(node: TSESTree.MethodDefinition | TSESTree.PropertyDefinition): boolean {
339+
return node.accessibility === undefined || node.accessibility === 'public';
340+
}
341+
338342
function isDateMutable(referenceTracker: ReferenceTracker, ctorNode: TSESTree.Expression): boolean {
339343
return !referenceTracker
340344
.iteratePropertyReferences(ctorNode, {

0 commit comments

Comments
 (0)