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.

Home Page:https://www.npmjs.com/package/eslint-plugin-check-file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'KEBAB_CASE' fails on dot notation

joseph-ravenwolfe opened this issue · comments

When using KEBAB_CASE filename convention. It is not uncommon to use the .test.js file extension as a filename convention for tests.

 └── src
     └── my-module.js
 └── tests
     └── my-module.test.js

However, this causes the KEBAB_CASE filename enforcement to fail for { "**/*.js": "KEBAB_CASE" } This can currently be worked around with a custom Regex, however, I wanted to bring attention to this.

Is this desired behavior?

Hi @dukeluo Can we have this option for check-file/folder-naming-convention also

commented

@turker0 could you share a scenario and give me an example?

sure, i have this rule

  'check-file/folder-naming-convention': [
      'error',
      {
        'marketplace.module/**/*': 'CAMEL_CASE',
      },
      {
        ignoreMiddleExtensions: true,
      },
    ],

but it gives this error

Error: .eslintrc.js:
        Configuration for rule "check-file/folder-naming-convention" is invalid:
        Value [{"marketplace.module/**/*":"CAMEL_CASE"},{"ignoreMiddleExtensions":true}] should NOT have more than 1 items.
commented

@turker0 This configs works well in my local.

├── create_folder_file.sh
├── index.js
├── marketplace.module
│   └── aB
│       └── b-c
│           └── a.js
├── package-lock.json
└── package.json
{
  "plugins": ["check-file"],
  "rules": {
    "check-file/folder-naming-convention": [
      "error",
      {
        "marketplace.module/**/": "CAMEL_CASE"
      }
    ]
  }
}
❯ npm run lint

> lint
> eslint "**/*.{ts,tsx,js,jsx,md}"

marketplace.module/aB/b-c/a.js
  1:1  error  The folder "b-c" does not match the "CAMEL_CASE" pattern  check-file/folder-naming-convention

@dukeluo right but i can not pass gnoreMiddleExtensions: true to check-file/folder-naming-convention

commented

@turker0 I mean we don't need this new param gnoreMiddleExtensions: true in this case since rule folder-naming-convention already works.