Skip to content

Feat: Add no-member-access rule#5

Merged
Changqing-JING merged 25 commits intowasm-ecosystem:mainfrom
xpirad:main
Jul 3, 2025
Merged

Feat: Add no-member-access rule#5
Changqing-JING merged 25 commits intowasm-ecosystem:mainfrom
xpirad:main

Conversation

@xpirad
Copy link
Copy Markdown
Contributor

@xpirad xpirad commented Jun 3, 2025

This pull request introduces a new ESLint rule for optimizing repeated member access patterns in AssemblyScript code. The rule aims to improve performance, readability, and maintainability by suggesting the extraction of frequently accessed member chains into variables. Additionally, the pull request includes updates to documentation, plugin configuration, and test cases to support and validate the new rule.

New ESLint Rule: no-repeated-member-access

  • Implementation of Rule:

    • Added the no-repeated-member-access rule in plugins/rules/memberAccess.ts. This rule identifies repeated member access patterns and suggests extracting them into variables for better performance and readability. It avoids warning for computed properties, array indices, or properties modified within the scope.
    • Added the rule to the ESLint plugin configuration in plugins/perfPlugin.ts.
  • Documentation:

    • Created a detailed guide for the no-repeated-member-access rule in docs/rules/no-repeated-member-access.md. This includes rule details, options, examples (correct and incorrect usage), and related rules.

Testing Enhancements

  • Test Suite for New Rule:
    • Added comprehensive test cases for the no-repeated-member-access rule in tests/rules/noRepeatedMemberAccess.test.ts. These cover valid scenarios, invalid scenarios, and edge cases to ensure the rule behaves as expected.
    • Updated the test suite configuration in tests/perfPlugin.test.ts to include the new rule's tests.

Comment thread tests/rules/noRepeatedMemberAccess.test.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
@xpirad xpirad marked this pull request as draft June 17, 2025 06:01
@xpirad xpirad marked this pull request as draft June 17, 2025 06:01
@xpirad xpirad marked this pull request as ready for review June 17, 2025 08:07
Comment thread .vscode/launch.json Outdated
Comment thread loader.mjs Outdated
Comment thread tests/rules/noRepeatedMemberAccess.test.ts
Comment thread tests/rules/noRepeatedMemberAccess.test.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread tests/rules/noRepeatedMemberAccess.test.ts Outdated
@xpirad xpirad marked this pull request as draft June 19, 2025 09:24
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Comment thread plugins/rules/memberAccess.ts Outdated
Changqing-JING
Changqing-JING previously approved these changes Jul 1, 2025
@xpirad xpirad marked this pull request as ready for review July 1, 2025 05:40
@Changqing-JING Changqing-JING merged commit 0debd21 into wasm-ecosystem:main Jul 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants