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

Feature: implement ignore-pattern based on word before, not object name #137

Open rtatarinov opened 3 weeks ago

rtatarinov commented 3 weeks ago

What rule do you want to change?

ignore-inline-pattern

Describe the problem

I have the following problem. When I use for example effector library (store managment) I have a strict order in the specific cases. For example:

import { sample } from "effector";

sample({
      clock: event,
      source: $store,
      filter: isNotNil,
      fn: (sourceData => sourceData.id,
      target: effectFx,
});

This is a right ordering in the sample operator from effector. But it conflicts with asc ordering from sort-objects The library allows to ignore-pattern for any object with specific name/file name. But I don't use name at all. So, the following implementation doesn't work:

"perfectionist/sort-objects": [
       "error",
        {
             "order": "asc",
             "type": "natural",
             "ignore-pattern": ["sample(*"]
        }
  ],

Proposal Implement inline code cheching by regex to check symbol by symbol string and exclude anything matches the specific pattern

Code example

"perfectionist/sort-objects": [
            "error",
            {
                "order": "asc",
                "type": "natural",
                "ignore-inline-pattern": ["sample(*"]
            }
],

Additional comments

No response

Validations