dukeluo / eslint-plugin-check-file

ESLint rules for consistent filename and folder. Allows you to enforce a consistent naming pattern for the filename and folder.
https://www.npmjs.com/package/eslint-plugin-check-file
Apache License 2.0
538 stars 20 forks source link

Ignore folder pattern does not work when folder has subfolders #51

Open webpolis opened 4 days ago

webpolis commented 4 days ago

Describe the bug

The exclamation mark in the glob pattern is used to exclude some path names from being validated, however it is not working as expected. The projects._index folder in my repo is not ignored, thus eslint gives an error, while the users._index folder is correctly ignored.

I guess this issue may be related with the projects._index folder containing sub folders.

  1:1  error  The folder "projects._index" does not match the "SNAKE_CASE" pattern  check-file/folder-naming-convention

Expected behavior Ignore all folders matching the ignore pattern

Plugin configuration

      "check-file/folder-naming-convention": [
        "error",
        {
          "app/**/!(_index|[a-z_]+._index|[a-z_]+.$[a-z_]+)/": "SNAKE_CASE"
        }
      ],

I tried as well by adding a * at the end but that makes the others fail as well:

app/**/!(_index|[a-z_]+._index|[a-z_]+.$[a-z_]+)/*

Project structure

app/routes/
├── _index
│   └── route.tsx
├── projects._index
│   ├── new
│   │   └── route.tsx
│   └── route.tsx
└── users._index
    └── route.tsx
dukeluo commented 13 hours ago

how about this one?

    "check-file/folder-naming-convention": [
      "error",
      {
        "app/**/!(*._index)": "SNAKE_CASE"
      }
    ],