stencil-community / stencil-eslint

ESLint rules specific to Stencil JS projects
MIT License
61 stars 34 forks source link

bug: `strict-mutable` rule impacted by order of source code #111

Closed nwhittaker closed 3 months ago

nwhittaker commented 4 months ago

Prerequisites

Stencil ESLint Version

0.7.2

Current Behavior

Given a mutable prop @Prop({ mutable: true }) that is mutated somewhere within the component, the strict-mutable rule:

  1. Will pass if the prop is mutated at a line in the code file below the line where the prop is defined.
  2. Will not pass if the prop is mutated at a line above the line where the prop is defined.

Expected Behavior

The rule passes regardless of where the prop is mutated relative to where the prop is defined in the code file.

Steps to Reproduce

  1. Visit the reproduction repo and checkout the [@stencil-community/eslint-plugin/strict-mutable[1] branch.
  2. Run npm i.
  3. Run npm run lint. Should fail with:
    error  @Prop() "fullName" should not be mutable  @stencil-community/strict-mutable
  4. Open the src/components/my-component/my-component.tsx file.
  5. Move the @Prop({ mutable: true }) fullName: string; line to above line 25.
  6. Run npm run lint. Should pass.

[1] https://github.com/nwhittaker/stencil-component/tree/%40stencil-community/eslint-plugin/strict-mutable

Code Reproduction URL

https://github.com/nwhittaker/stencil-component/tree/%40stencil-community/eslint-plugin/strict-mutable

Additional Information

No response