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
544 stars 20 forks source link

Character sets not working? #46

Closed moui72 closed 2 months ago

moui72 commented 3 months ago

Describe the bug

I am trying to create a filename convention that allows something like 1718716204615-memberSurveyAnswerChoices1.ts but not something like `1718716204615-member-survey-answer-choices1.ts

/Users/tyler.peckenpaugh/pager/titan/apps/titan/api/src/drivers/postgres/migrations/1718716204615-memberSurveyAnswerChoices1.ts
  1:1  error  The filename "1718716204615-memberSurveyAnswerChoices1.ts" does not match the "+([0-9])-+([a-zA-Z0-9]).ts" pattern  check-file/filename-naming-convention

Expected behavior

The filename "1718716204615-memberSurveyAnswerChoices1.ts" should match the "+([0-9])-+([a-zA-Z0-9]).ts" pattern

Welcome to Node.js v20.15.0.
Type ".help" for more information.
> const micromatch = require('micromatch');
undefined
> micromatch.isMatch("1718716204615-memberSurveyAnswerChoices1.ts", "+([0-9])-+([a-zA-Z0-9]).ts")
true
> micromatch.isMatch("1718716204615-member-survey-answer-choices1.ts", "+([0-9])-+([a-zA-Z0-9]).ts")
false
> 

Plugin configuration Your configuration of this plugin.

        "check-file/filename-naming-convention": [
          "error",
          {
            "**/!(migrations)/*.{ts,js}": "CAMEL_CASE",
            "**/migrations/*.{ts,js}": "+([0-9])-+([a-zA-Z0-9]).ts"
          },
          {
            "ignoreMiddleExtensions": true
          }
        ],
        "check-file/folder-naming-convention": [
          "error",
          {
            "src/**": "KEBAB_CASE"
          }
        ]

Project structure If applicable, add a minimal reproducible project structure generated by the tree cmd like the one below.

.
├── apps
│   └── titan
│       ├── api
│       │   ├── src
│       │   │   ├── app.module.ts
│       │   │   │   └── postgres
│       │   │   │       ├── migrations
│       │   │   │       │   ├── 1716580425537-blah-blah.ts
└── .eslintrc.json

Desktop (please complete the following information):

Additional context

Use nx for project management in a monorepo, so I execute linting with this command:

> npx nx run titan-api:lint
dukeluo commented 2 months ago

Your custom glob expression should be +([0-9])-+([a-zA-Z0-9]), not +([0-9])-+([a-zA-Z0-9]).ts, it should not include the file extension.