azat-io / eslint-plugin-perfectionist

🦄 ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
https://eslint-plugin-perfectionist.azat.io
MIT License
1.62k stars 28 forks source link

Bug: TS2729: Property is used before its initialization. #118

Open ElPrudi opened 1 month ago

ElPrudi commented 1 month ago

Describe the bug

Inside classes, if you reuse properties inside other properties, the ordering will lead to an error depending on how they are named.

Code example

class TheClass {
  x = new XProperty()

  // Create model from properties
  model = [this.x]
}

will lead to

class TheClass {
   // Create model from properties
   // Error TS2729: Property 'x' is used before its initialization.
  model = [this.x]
  x = new XProperty()
}

ESLint version

v8.57.0

ESLint Plugin Perfectionist version

v2.7.0

Additional comments

I don't know if this is a good programming standard as I'm just using a framework that generates this kind of code OOB.

Validations