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: (sort-object): Cannot read properties of undefined (reading 'getTokensBefore') #121

Open bab2683 opened 1 month ago

bab2683 commented 1 month ago

Describe the bug

Getting that error when running the linter

Code example

const something = {
  b: false,
  a: true,
};

ESLint version

8.36

ESLint Plugin Perfectionist version

2.7.0

Additional comments

Apple M3 Pro macOS Sonoma 14.3

Validations

azat-io commented 1 month ago

Looks like a problem with the typescript-eslint version. What package manager are you using?

bab2683 commented 1 month ago

We're using yarn@1.22.211 and @typescript-eslint/utils@6.8.0

bab2683 commented 1 month ago

BTW, I just tried upgrading @typescript-eslint/eslint-plugin, @typescript-eslint/parser and @typescript-eslint/utils to latest non breaking version 6.21.0 and the issue is still reproducible

azat-io commented 1 month ago

Do you have the ability to create a small repository to reproduce the problem?

bab2683 commented 1 month ago

Hi, sorry for the delay, you can reproduce it here: https://github.com/bab2683/perfectionist-121

azat-io commented 1 month ago
image

Looks like the removing parser fix this issue.

bab2683 commented 1 month ago

To use typescript however, is necessary due to the differences in AST format. at least that's what they say right in the first line https://typescript-eslint.io/packages/parser/. I thought this eslint plugin was compatible with the whole @typescript-eslint suite due to the sort-interfaces rule and also because it's listed as dependency.

We use the parser in the overwrites because we have both js and ts files in the project